MCPcopy Create free account
hub / github.com/VSCodeVim/Vim / run

Method run

src/cmd_line/commandLine.ts:467–502  ·  view source on GitHub ↗
(vimState: VimState)

Source from the content-addressed store, hash-verified

465 }
466
467 public async run(vimState: VimState): Promise<void> {
468 // Repeat the previous search if no new string is entered
469 if (this.text === '') {
470 const prevSearchString = SearchCommandLine.previousSearchStates.at(-1)?.searchString;
471 if (prevSearchString !== undefined) {
472 this.text = prevSearchString;
473 }
474 }
475 Logger.info(`Searching for ${this.text}`);
476
477 this.cursorIndex = 0;
478 Register.setReadonlyRegister('/', this.text);
479 void SearchCommandLine.addSearchStateToHistory(this.searchState);
480 globalState.hl = true;
481
482 if (this.searchState.getMatchRanges(vimState).length === 0) {
483 StatusBar.displayError(vimState, VimError.PatternNotFound(this.text));
484 return;
485 }
486
487 const currentMatch = this.getCurrentMatchPosition(vimState);
488
489 if (currentMatch === undefined) {
490 StatusBar.displayError(
491 vimState,
492 this.searchState.direction === SearchDirection.Backward
493 ? VimError.SearchHitTop(this.text)
494 : VimError.SearchHitBottom(this.text),
495 );
496 return;
497 }
498
499 vimState.cursorStopPosition = currentMatch.pos;
500
501 reportSearch(currentMatch.index, this.searchState.getMatchRanges(vimState).length, vimState);
502 }
503
504 public async escape(vimState: VimState): Promise<void> {
505 vimState.cursorStopPosition = this.searchState.cursorStartPosition;

Callers

nothing calls this directly

Calls 10

reportSearchFunction · 0.90
infoMethod · 0.80
setReadonlyRegisterMethod · 0.80
getMatchRangesMethod · 0.80
displayErrorMethod · 0.80
PatternNotFoundMethod · 0.80
SearchHitTopMethod · 0.80
SearchHitBottomMethod · 0.80

Tested by

no test coverage detected