* Called when or is pressed during SearchInProgress mode
(vimState: VimState, direction: SearchDirection)
| 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 | } |
no test coverage detected