VSCodeVim / VSCodeVim/Vim

Reverse search with `?` command makes the window shift downwards

Open
#3,598 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/search kind/bug
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
When I reverse-search using "?", the result is correctly found. However with large files, the window often (but not always) shifts downward so that the found pattern is displayed at the very top line of the window.

To Reproduce

  1. Open a file with significantly more lines that can fit in the visible window
  2. Scroll to around the middle of the file
  3. Place the cursor below a pattern you want to search for
  4. type $ ?<pattern> $ in the command bar
  5. As you type <pattern>, the window could shift to match whatever partial pattern you've already entered.
  6. Finish typing your <pattern>, and the window will jump back upwards to the match that it found above your cursor position.
  7. Even if <pattern> was originally visible well within the bounds of your starting window, searching for it using "?" could cause the window to shift downwards as it finds matches to the partial pattern as you are typing. When you're done typing, the window finds the correct match, but places it at the top of the window as it shifts back upwards.
  8. The end result is that it appears the window pointlessly shifts downwards so that <pattern> is displayed at the top of the window, when in reality the window shouldn't have moved at all.

Expected behavior
I expect reverse-search "?" to behave the same as forward search "/" with regard to when the window shifts around.

When I forward-search for a pattern, the window only moves if the pattern is found outside of the visible range of the window. If the pattern is already in the visible window, then the cursor moves to the pattern and the window does not change.

When I reverse-search for a pattern, I want the same thing to happen. The window should only shift if the pattern does not exist in the visible window. Otherwise, the cursor should move to the pattern in the visible window and the window should not move at all.

Screenshots
First image: I am forward-searching "/are" to highlight the pattern "are". That is the pattern I'm going to eventually search for using reverse search. Cursor is on line 43.
image

Second image: I have typed"?a", which is part of the eventual search for "?are". The window has shifted elsewhere in my document as it matched "a".
image

Third image: I have finished typing "?are", and the match on line 41 is now annoyingly displayed at the top of my window. What should have happened is that the window should not have moved at all (see image 1), but the cursor should have moved.
image

Environment (please complete the following information):
MacOS 10.14.6
VSCode version 1.32.3
VSCodeVim version 1.2.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the report. Reproduce the issue in VSCodeVim with a large file by comparing reverse search with ? against forward search with /; done means reverse search does not move the window when the completed match is already visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.