Esc key after incremental search loses file position

Oleg Smolsky 7 years ago updated by Ken Chatfield 7 years ago 4

Repro steps:

  1. open a decently sized file (a few screens worth of text)
  2. start the incremental search, type some term
  3. observe the working search, the first match is highlighted
  4. press Esc
  5. observe the current position being lost, as the editor moves back to the beginning of the file

IE it would be a lot nicer if Esc key just stopped the increment search. 

P.S. it would be nicer still if cursor keys canceled the search too, as that is what VisualStudio does :)

I feel this behaviour is desirable, as it allows you to cancel a search with 'Esc' and go back to where you were before. This also mirrors how incremental search works in Emacs.

I agree with your comments about the cursor keys cancelling the search however (at least the up and down keys)

Well, this feature is inconsistent with other search options that I use interchangeably: search next (F3), search prev (Shift-F3), search selected forward (Ctrl-F3) and search selected backward (Ctrl-Shift-F3). All of these let me use cursor keys.

Or specifically, I end up with the following cycle every time:

  •  search incrementally for a word
  •  F3 a few times
  •  try the cursor (left/right/down do nothing) D'OH!
  • try the cursor (up changes the search query) D'OH
  • press down to search for the last thing again, find the appropriate place again
  • press Esc. The editor jumps away. D'OH!

From here:

  • press F3 to find the right spot
  • use cursor keys to move around
  • actually perform the edit

So, my beef is with both the increment search "edit" box and, much more so, with the Esc key.

I agree that an option to make the arrow keys end the search and move left/right/up/down at the current position would be desirable. To me, this would remove the need for ESC placing the cursor at the currently highlighted point.