Bug 434287 - Bug in search in files panel
Summary: Bug in search in files panel
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: search (show other bugs)
Version: unspecified
Platform: unspecified Other
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-11 15:49 UTC by Pozsgay Máté
Modified: 2022-01-10 21:11 UTC (History)
2 users (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 Pozsgay Máté 2021-03-11 15:49:44 UTC
SUMMARY
When double clicking on a search result in the "search in files" results panel, it always activates the first unsaved document instead of the one which have the search results.

STEPS TO REPRODUCE
1. Have two (or more) unsaved documents, and select any other tab which is not created firstly.
2. Open the "Edit->Search in files"
3. Select "in Current File"
4. Populate the result list (tree) by filling the search field and clicking on the search button
5. Double click on a search result

OBSERVED RESULT
The first unsaved document get activated, and the caret jumps to the line where the result was found in the document. (Regardless if there is any mach on the first document)


EXPECTED RESULT
The document should activated which the search results belongs to, and the caret should jump to the proper line.


SOFTWARE/OS VERSIONS
I'm using version 21.03.70 (flatpak release: 20.12.2) on Ubuntu
KDE Frameworks 5.78.0
Qt 5.15.2

ADDITIONAL INFORMATION
I was not able to reproduce it on the Windows (10) store version of Kate (20.08.2)
Comment 1 Kåre Särs 2021-03-11 19:12:52 UTC
I actually noticed this too just some days ago....
Comment 2 Christoph Cullmann 2021-03-16 21:15:23 UTC
Hmm, I can't reproduce this with the master version of Kate..
Comment 3 Kåre Särs 2021-03-17 13:20:01 UTC
The secret is to create two new documents (not saved) add text to them and then search in them....
Comment 4 Christoph Cullmann 2021-05-22 18:52:11 UTC
Hmm, isn't the problem that we match url => document?
For untitled stuff that will fail, I guess we need to use there the document pointer.
Similar to the fixes for quick open here: https://invent.kde.org/utilities/kate/-/merge_requests/400
Comment 5 Bug Janitor Service 2022-01-10 19:06:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/554
Comment 6 Waqar Ahmed 2022-01-10 21:11:59 UTC
Git commit 3ff6e15eca384f9300bfb31c3edc299fd10e7c91 by Waqar Ahmed.
Committed on 10/01/2022 at 19:04.
Pushed by cullmann into branch 'master'.

Fix search for unsaved files

Search for unsaved files doesn't work because we don't have QUrl's for
them. Instead use KTextEditor::Document pointer for such files.

Included is a small fix that I noticed while working on this. If you try
to replace checked after searching, the file that you have opened doesn't
get highlights as it should.

Possible further improvements:
- Ask main window for the "tab title" of the doc so that we can use
  that in the search tree view. Otherwise its kind of really ambigous
Signed-off-by: Waqar Ahmed <waqar.17a@gmail.com>

A  +0    -0    addons/katebuild-plugin/highlighter.cpp     [License: Trivial file]
A  +21   -0    addons/katebuild-plugin/highlighter.h     [License: LGPL(v2.0)]
M  +58   -26   addons/search/MatchModel.cpp
M  +18   -7    addons/search/MatchModel.h
M  +11   -6    addons/search/Results.cpp
M  +4    -3    addons/search/Results.h
M  +1    -1    addons/search/SearchDiskFiles.h
M  +34   -16   addons/search/plugin_search.cpp
M  +1    -1    addons/search/plugin_search.h
M  +2    -2    addons/search/search_open_files.cpp
M  +1    -1    addons/search/search_open_files.h

https://invent.kde.org/utilities/kate/commit/3ff6e15eca384f9300bfb31c3edc299fd10e7c91