Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Find/replace: regexp is forgotten if searching without dialog open #3568

Open
UffeJakobsen opened this issue Jan 9, 2025 · 4 comments
Assignees

Comments

@UffeJakobsen
Copy link
Contributor

UffeJakobsen commented Jan 9, 2025

What happened?

[Bug]: Find/replace: regexp is forgotten if searching without dialog open

There is a mix-up between Find next/Find prev and Find next at caret/Find previous at caret

= Scenario =

Go to the top of a .cpp file with lots of if-statements in :-)

In Find/replace dialog switch to "Regex" - enter a regex like if .*$

Verify that you can search forwards and backwards using both dialog buttons and Find next and Find previous hotkeys...

Ensure that no text is selected in the editor - then close the Find/Replace dialog...

Now press (once) on either Find next and Find previous hotkey... - it finds a line matching the regex

If you unselect the selected search result you can repeat your search using the regex by pressing on its hotkey

But if you leave the search result selected - then pressing Find next hotkey will no longer search for the regex - it will search for the selection - and that is wrong as I did not invoke Find next at caret

= Summary =
There should be a distinction between Find next/Find prev and Find next at caret/Find previous at caret hotkey functions:

Find next/Find prev should always search for whatever was entered into the Find/replace dialog - no matter what is selected in the editor.

Find next at caret/Find previous at caret should search for the currently selected text

Version

Self compiled

Operating system

Linux

Steps to reproduce

No response

Relevant log output

No response

@eranif
Copy link
Owner

eranif commented Jan 9, 2025

Thanks for reporting this. FYI: this is now a regression, as this is the behavior from the previous view (using embedded panel).
I think that the solution here is to use a control with drop down that will remember the previous searches / replacements

WDYT?

@eranif eranif added 18.2.0 and removed 18.2.0 labels Jan 9, 2025
@UffeJakobsen
Copy link
Contributor Author

Having a history of previous searches / replacements is an extra bonus (I think)

As a minimal solution just distinction between Find next/Find prev and Find next at caret/Find previous at caret hotkey functionality would be more than fine :-)

@eranif
Copy link
Owner

eranif commented Jan 9, 2025

CodeLite logic is:

  • If there is a selection "Find" will use the selection as the "find what", this is how it always worked. This is very useful in 90% of the cases: you just select something and hit F3 no need to open extra windows
  • "Find next at caret" does not require a selection, it detects the word boundaries from the caret position and uses it as the "find what" (so it basically similar to the above with an addition 1 step: it performs the selection by itself)

Tip: to quickly clear selection, you can hit ESCAPE - so what you are suggesting is changing the current behavior (which I like). So as compromise, I would say that we need an extra checkbox somewhere that says: "Use selected text as 'find what'"

@UffeJakobsen
Copy link
Contributor Author

So something like the setting under Preferences / Tab / Find In Files called When searching, don't override search string with current selection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants