Sublime Forum

[ST3] reverse find direction is a pain

#1

it seems ST3 got rid of the button to toggle search direction (which makes search work from the bottom of a file to the top), which is fine, I never knew it was there til a colleague pointed it out in ST2 while I was bitching about this

but. the feature still exists in code

{ "keys": "super+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse":false} },
{ "keys": "super+shift+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse":true} },

cmd+shift+i will trigger reverse find which is fine but the setting will stick making all future use of find work in the wrong direction

since the only UI I’m aware of was removed, there’s no way to fix it except to use cmd+i which sets it to false

either those shortcuts shouldn’t even exist in ST3 or the reverse:true shouldn’t cause a global flag to be set which can only be un-set by an equally obscure keyboard shortcut

1 Like

#2

thanks for this note! i was going crazy!
i didn’t realise that I’d hit cmd+shift I…

for those coming after, to set direction forwards again, hit Cmd+i to incremental search forwards.

I’ve added:


    { "keys": "super+shift+i"], "command": "noop"}
]

to my Sublime Text > Preferences > Key Bindings - User file to disable the shortcut altogether.

1 Like

#3

should be [“super+shift+i”] (missing bracket)

Thanks for posting this!

1 Like

#4

I’m not sure if this was resolved elsewhere, but they have a “Find Prev” button if you do Ctrl/Command + F.

0 Likes

#5

Brilliant suggestion. I’m amazed this hasn’t been fixed in ST yet. There should be a visual indication of the current default search direction.

0 Likes

#6

Note that the pain is still there with Sublime Text 4.

What is more confusing, I would like to highlight that the hidden reverse flag turned on with the Incremental Find would have an effect the Find panel as well.

For example,

line 300: hello # step 2. (normal) find_next of (normal) Find for “hello” gets you here
line 301: hello # step 1. reverse find of Incremental Find for “hello” gets you here
line 302: # step 0. cursor starts here
line 303: hello

With cursor starting in line 302, if you do a reverse Incremental Find for “hello” with command (macOS default, for example)

{ "keys": ["super+shift+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse": true} },

and hit Enter, you will locate the “hello” in line 301, which is good.

But with the above step, you actually turned on a hidden reverse flag which has an impact on both the Find and Incremental Find panels.

Next, if you bring up the normal Find panel with

{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "find", "reverse": false} },

and do a normal Find Next with

{ "keys": ["enter"], "command": "find_next", "context":[{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]},

you will end up in line 300, which is very confusing!

Until you cancel the reverse flag with a normal (instead of reverse) Incremental Find, the Find Next function (Enter) in the normal Find panel will go backward / upwards, while the normal Find Prev button (Shift + Enter) in the normal Find panel will go forward / downwards.


Suggestion for Users Don’t use the reverse (Incremental) Find.

0 Likes

#7

What version of Sublime Text are you using? I wasn’t able to reproduce this in build 4175 or 4180.

This could also be due to a plugin. Does it happen in safe mode?

0 Likes

#8

Sublime Text 4 build 4178, which is the latest dev build up to date. Platform is macOS.
I confirm that the problem is still there with safe mode subl --safe-mode. (Edit - see update)
To reproduce, let’s use this file

(line 10) hello
(line 11) hello
(line 12) 
(line 13) hello
  1. start Sublime Text (safe-mode) on macOS with subl --safe-mode with the above file
  2. cursor starts at line 12
  3. hit command + shift + I to bring up the reverse incremental find panel
  4. enter “hello” in the panel and hit Enter - you should end up with a selection of “hello” in line 11
  5. hit command + F to bring up the normal find panel
  6. enter “hello” in the panel and hit Enter - you should end up with a selection of “hello” in line 10
0 Likes

#9

In step 5 after typing “hello” and hitting the Enter key, is the “hello” on line 13 highlighted/selected?

If yes, then one way I could see it occurring is that hitting the Enter key will (by default) wrap around to the start and then select the first instance of “hello”.

1 Like

#10

Hi Valerie, thank you for your reply!

You are right and much to my surprise -

  1. the weird behavior indeed does not exist in safe mode with subl --safe-mode, and my previous test is a false alarm
  2. the weird behavior does exist in my plugin-loaded Sublime Text; that is, if my previous test was run in my normal, plugin-loaded Sublime Text, the werid behavior (find_next goes the opposite way) would appear.

Limited by my time, I will not dig into my dozens of plugins to see which one caused the problem. But one day if I have any hint I will reply here in this post.

Thank you Valerie for your reply again.

1 Like