(vimState: VimState)
| 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; |
nothing calls this directly
no test coverage detected