Bug 481719 - When opening the "Find in files" with some text in the search field, it will not close by pressing ESC
Summary: When opening the "Find in files" with some text in the search field, it will ...
Status: RESOLVED INTENTIONAL
Alias: None
Product: kate
Classification: Applications
Component: search (show other bugs)
Version: 24.01.95
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-02-23 11:46 UTC by Oded Arbel
Modified: 2024-02-25 19:45 UTC (History)
2 users (show)

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


Attachments
screenshot showing the find in files panel as it first opens (38.71 KB, image/png)
2024-02-23 15:56 UTC, Oded Arbel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oded Arbel 2024-02-23 11:46:44 UTC
SUMMARY
When opening the "Find in Files" panel, the search field will almost always contain some text - either the "word" the text editor cursor is currently in, a text is selected in the editor, or a previous search (which is OK and not a problem). When that is the case, the text in the search box is pre-selected (which is also very much OK and I appreciate the convenience).

If I want to dismiss the "Find in files" panel, I expect I can do that by pressing ESC, but that does nothing. Pressing ESC a second time dismisses the panel.

STEPS TO REPRODUCE
1. Open kate with some text file.
2. Select some text.
3. Press CTRL+SHIFT+F to open the "Find in files" panel.
4. Press ESC

OBSERVED RESULT
Nothing happens

EXPECTED RESULT
The "Find in files" panel should close.

SOFTWARE/OS VERSIONS
Operating System: KDE neon Testing Edition
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.5.0-17-generic (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics

ADDITIONAL INFORMATION
* Just unselecting the text (for example by pressing the left or right arrow key) does not workaround the issue - you still need two ESC keys to close the panel. 
* Changing the search box text introduces another interesting behavior, which I'm not sure if it is intentional or not (I don't remember if it used to be like that): after typing, the search options part of the panel is replaced with the search results view that shows matches in the current file - if the text entered exists in the current document, the search results will have entries with checkboxes that are all checked, and then pressing ESC will first uncheck all the checkboxes and the second ESC will close the panel. If there are no search results in the current document than the first ESC will close the panel. I have a feeling that this behavior is related to the same issue - maybe after opening the panel there are search results hidden behind the search options and the first ESC clears their invisible checkboxes.

Bug #160696 is where the "close on ESC" functionality was first introduced.
Comment 1 Waqar Ahmed 2024-02-23 12:50:04 UTC
Its working as expected.

When you select a word and hit Ctrl+Shift+F -> it opens the panel and triggers a search.

If you then hit Esc, 
-> it checks if there are results and they are 'checked' and unchecks them
-> If you hit Esc again, it will close the panel because there is nothing to uncheck now.
Comment 2 Oded Arbel 2024-02-23 15:56:16 UTC
Created attachment 166042 [details]
screenshot showing the find in files panel as it first opens

I'm a bit hazy on the purpose of the checkboxes - though I assume they have purpose - but the problem is that when the "Find in files" panel first appears (see screenshot), the search results with the checkboxes are not visible. If the user then presses ESC, nothing changes and it looks like the first ESC is just ignored.
Comment 3 Waqar Ahmed 2024-02-23 16:35:24 UTC
> I'm a bit hazy on the purpose of the checkboxes - though I assume they have purpose

They are used when replacing text.
Comment 4 Kåre Särs 2024-02-25 06:25:14 UTC
The original reason for not closing is that the first Esc removes the search result highlights (in case they are distracting)
Comment 5 Oded Arbel 2024-02-25 10:24:38 UTC
(In reply to Kåre Särs from comment #4)
> The original reason for not closing is that the first Esc removes the search
> result highlights (in case they are distracting)

As noted before - the problem is that when search results are hidden behind the search options view, nothing visible happens when you press ESC the first time. This is very confusing. At least the search options view should be hidden as well, on the first ESC.
Comment 6 Kåre Särs 2024-02-25 19:45:25 UTC
If you have multiple matches visible at the same time and no selected word in the current document, it is quite obvious what happens when you press Esc the first time, but I can agree that if there is only the selected word that matches, it is quite hard to notice as the selection or the common word-highlight covers the match highlight.

Unfortunately, I don't have any idea on how to accommodate both scenarios.... I think the separate de-selection and clearing of highlights are quite important features.