MCPcopy Index your code
hub / github.com/VSCodeVim/Vim / advanceCurrentMatch

Method advanceCurrentMatch

src/cmd_line/commandLine.ts:529–541  ·  view source on GitHub ↗

* Called when or is pressed during SearchInProgress mode

(vimState: VimState, direction: SearchDirection)

Source from the content-addressed store, hash-verified

527 * Called when <C-g> or <C-t> is pressed during SearchInProgress mode
528 */
529 public advanceCurrentMatch(vimState: VimState, direction: SearchDirection): void {
530 // <C-g> always moves forward in the document, and <C-t> always moves back, regardless of search direction.
531 // To compensate, multiply the desired direction by the searchState's direction, so that
532 // effectiveDirection == direction * (searchState.direction)^2 == direction.
533 this.currentMatchDisplacement += this.searchState.direction * direction;
534
535 // With nowrapscan, <C-g>/<C-t> shouldn't do anything if it would mean advancing past the last reachable match in the buffer.
536 // We account for this by checking whether getCurrentMatchRange returns undefined once this.currentMatchDisplacement is advanced.
537 // If it does, we undo the change to this.currentMatchDisplacement before exiting, making this command a noop.
538 if (!configuration.wrapscan && !this.getCurrentMatchRange(vimState)) {
539 this.currentMatchDisplacement -= this.searchState.direction * direction;
540 }
541 }
542}

Callers 1

runMethod · 0.80

Calls 1

getCurrentMatchRangeMethod · 0.95

Tested by

no test coverage detected