Bug 374564 - File search opens multiple sessions of the same file
Summary: File search opens multiple sessions of the same file
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: search (show other bugs)
Version: 16.08
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-04 21:57 UTC by Ferdinand Gruber
Modified: 2017-01-25 20:18 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 Ferdinand Gruber 2017-01-04 21:57:35 UTC
If I use the "search in files" feature of kate I establish an annoying problem only if the search text is found in a file that is symbolically linked.

Each mouse click in the search result shown at the bottom of the editor window opens a new session of the same file.
If the search result is found in 5 lines, I get 5 sessions of the same file (after clicking on each line).

This unwanted behaviour occurs only, if the search text was found in a file that is symbolically linked. 

I think that should be fixed.
Comment 1 Ferdinand Gruber 2017-01-05 20:49:34 UTC
May be that I have not expressed clearly:
Each mouse click in the search result shown at the bottom of the editor window opens a new tab of the same file, for example:
file.php, file.php(2), file.php(3), file.php(4) ... 
The files are numbered and they are identical.
If I change something in one of theese files I get trouble with saving the changes because of the other opened instances. Very annoying!
Comment 2 Kåre Särs 2017-01-08 12:22:54 UTC
Hi,

The problem here is that KTextEditor resolves symbolic links, while Kate's document manages does not. There are two solutions:

1) We add sym-link resolving in Kate
2) We stop resolving sym-links in KTextEditor


Alternative 2 is a change in behavior and might not be the best option, but it is a bit strange to try to open foo.txt and get baar.txt...
Comment 3 Ferdinand Gruber 2017-01-10 21:36:59 UTC
(In reply to Kåre Särs from comment #2)

> it is a bit strange to try to open foo.txt and get baar.txt ...

Sorry, I cannot quite understand this argument.

If a particular file is already opened, why it gets reopended after each click on a line in the search result?
I cannot understand, why it is not possible to find out, whether a particular file is already opened or not.

If it is already opened, there is no need to open it a second time ...
Comment 4 Kåre Särs 2017-01-11 07:09:54 UTC
Hi,

I already have a review request (https://git.reviewboard.kde.org/r/129792/) to fix it using alternative 1)

What I'm saying is that with alternative 1) you open foo.txt, but you get baar.txt which is the target of the soft-link.
Comment 5 Ferdinand Gruber 2017-01-11 14:06:07 UTC
Thank you very much.

But please excuse my stupid questions: 
How can I get the changes to work an my system? Where can I get a new binary file of kate?

Sorry, this is my first experience with such matters.
Comment 6 Kåre Särs 2017-01-11 14:53:45 UTC
At the moment the only place this is fixed is on my computer.

When the patch is accepted, it goes to the public repo and then you have to wait for your distro to package the new version or compile it your self.

For the distro it might take quite some time...
Comment 7 Ferdinand Gruber 2017-01-11 16:58:18 UTC
Thank you for this information.

Ferdinand
Comment 8 Kåre Särs 2017-01-25 20:12:38 UTC
Git commit 4059d29f1d4499a067706248747ba6339ff5bdf0 by Kåre Särs.
Committed on 25/01/2017 at 20:11.
Pushed by sars into branch 'master'.

Resolve symbolic links in findDocument() just as KTextEditor does.

Not resolving the links resulted in multiple instances of the same
file when opened multiple times.
REVIEW: 129792

M  +8    -0    kate/katedocmanager.cpp

https://commits.kde.org/kate/4059d29f1d4499a067706248747ba6339ff5bdf0
Comment 9 Kåre Särs 2017-01-25 20:18:19 UTC
Git commit ff1ab8bd0fd23f189960d40755354b674ed019ac by Kåre Särs.
Committed on 25/01/2017 at 20:15.
Pushed by sars into branch 'Applications/16.12'.

Resolve symbolic links in findDocument() just as KTextEditor does.

Not resolving the links resulted in multiple instances of the same
file when opened multiple times.
REVIEW: 129792

M  +8    -0    kate/katedocmanager.cpp

https://commits.kde.org/kate/ff1ab8bd0fd23f189960d40755354b674ed019ac