Bug 431895 - Direct click on file in grep result doesn't open file
Summary: Direct click on file in grep result doesn't open file
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 20.12.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-21 20:47 UTC by Piotr Mierzwinski
Modified: 2022-01-04 19:19 UTC (History)
2 users (show)

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


Attachments
konsole - bash_profile - mouse (30.78 KB, image/png)
2021-01-21 20:47 UTC, Piotr Mierzwinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2021-01-21 20:47:23 UTC
SUMMARY
For profile "bash", which starts shell Bash, I checked option "Open by direct click" to get possibility of jump directly to line of code in the file I found by grep command. 
All setting in Mouse tab please find in attached screenshot.

I opened new tab with profile "bash". and started grep command to find proper string. One of result was:
work.txt:820:           ASSERT: "index.isValid()" in file
I pressed Ctrl and clicked left mouse button on it. In result I got error that file doesn't exists, where in path was line number (this was reason that file cannot be found)

"Unable to run the command specified. The file or folder /path/to/my/file/work.txt:820: does not exist."

STEPS TO REPRODUCE
1. Define and open bash profile running shell Bash
2. In configuration for bash profile check following options:
Path: "Settings -> Edit current profile -> Mouse -> Miscellaneous":
"Underline files", "Open by direct click"
3. run for example "grep -n qt *" in directory where is present file which you want to search
4. in result you should get long list (10 positions) of matching lines in searched file, where file name doesn't start with path. My result was following:
"work.txt:820:     something qt what matches to search"
5. hold Ctrl (or other configured key short) and click on any file

OBSERVED RESULT
Cannot open file, because error "The file /path/work.txt:820 does not exist.".
Looking at error message it seems that file name is not recognized correctly.

EXPECTED RESULT
Open file and jump to given line.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: YES
(available in About System)
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
$ grep --version
grep (GNU grep) 3.6
Comment 1 Piotr Mierzwinski 2021-01-21 20:47:55 UTC
Created attachment 135040 [details]
konsole - bash_profile - mouse
Comment 2 Piotr Mierzwinski 2021-01-21 21:22:35 UTC
I think this is related with:
https://invent.kde.org/utilities/konsole/-/merge_requests/224
Comment 3 Maciej Stanczew 2022-01-04 19:19:55 UTC
This now (mostly) works for me with Konsole 21.12.0, Frameworks 5.89.0, and Plasma 5.23.5.
I can ctrl-click results of grep -n, like:
    test.txt:5:    match
and the file test.txt is opened in Kate at line 5, just as expected.

This also works for paths which include subdirectories (previously those were not even clickable):
    dir/test.txt
    /tmp/dir/test.txt
    dir/test.txt:5:    match
    /tmp/dir/test.txt:5:    match

It doesn't however work reliably if the line which matches doesn't start with a whitespace. For example, if I grep for "match" and the line is:
    test.txt:5:match-n
then ctrl-click will work; however if there is a digit in the output:
    test.txt:5:match-1
then I get "The file or folder /tmp/dir/test.txt:5:match-1 does not exist".
It seems to be a problem only for digits, all other printable ASCII characters are fine.