Bug 472608 - Search in files: Enter key should replace only current item
Summary: Search in files: Enter key should replace only current item
Status: CONFIRMED
Alias: None
Product: kate
Classification: Applications
Component: search (show other bugs)
Version: 22.12.3
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-25 10:45 UTC by Diggory Hardy
Modified: 2023-07-25 12:12 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diggory Hardy 2023-07-25 10:45:02 UTC
In Kate, per-file search-replace works like this:
- Press Ctrl+R to activate
- Type in search query
- Press <Enter> or <F3> to go to next result
- Press Tab to move to the "replace" box
- Type in a replacement text/pattern
- Press <Enter> to replace the current result with the contents of the "replace" box.

In contrast, cross-file search works like this:
- Press <Ctrl+Shift+F> or click the "Search" button to activate
- Type in search query
- Press <Enter> or click "Search" to go to find all results
- Press <F6> to go to the next result
- Press Tab to move to the "replace" box
- Type in a replacement text/pattern
- Press <Enter> to replace all results with the replacement pattern.

The user experience differs, which is not intuitive. Suggestions for changes to the "Find in files" tool follow.

Problem 1 (minor): pressing <Enter> in the query box does not move to the first/next result.
Suggestion: <Enter> should perform the search if the query has changed, then move to the next result.

Problem 2: pressing <Enter> from the replacement box updates all results.
Suggestion: <Enter> should behave like per-file search-and-replace: replace the current result only and move to the next.
Worse, there is no "all files undo". With the current behaviour it is easy to mistakenly run the wrong operation, and hard to revert if many files are affected. In my opinion, only the "Replace Checked" button (which is hard to press accidentally) should replace everything.
Comment 1 Kåre Särs 2023-07-25 12:11:16 UTC
Hi,

Thanks for the report!

It is unfortunate that the searches behaves differently.

Problem 1: 
In the search & replace plugin, a search might be very expensive. That is why a full search is only triggered by enter (the current file is searched after a certain amount of waiting). The plugin also does not move the cursor when the the search is done, so moving on the second enter, feels a bit strange.... (it did jump to the first match at some point, but that was removed at some point)

Problem 2A:
In my experience, the replace all matches is the more common task for the cross-files replace, so making "replace-next" the more prominent one is probably not a good idea. Adding a (configurable) shortcut for Replace-Next is probably a good idea.

Problem 2B:
Undoing the last multi-file replace is definitely something we need! Should be added as a new separate wish-item.