konsole click to open file uses default rather than custom text editor command

I’ve got Underline files & Open files/links by direct click set.

When I click a valid, relative file path such as imports/utils/test.js:100:10, I get an error about it trying to open that exact path, which does not exist, since there is a line & col # in there.

The ‘text editor command’ accounts for this, and I’ve got: webstorm --line LINE --column COLUMN PATH

However, neither regular click nor ctrl+click runs this command. I always get the error described, where it attempts to open a ‘…test.js:100:10’ explicitly, rather than parsing the line/col # and running it through the custom command.

I’m definitely applying to the correct profile, and have even tried restarting konsole entirely.

Thanks.

Hi! After reading your message, I tried out a few different ways of using the “Underline files” option on my device. It was a bit challenging for me to get it to work in the ways that I intuitively expected, and in checking the KDE Bugtracking System, there are a couple other examples of folks running into unexpected behavior with that feature:

If I’m thinking of it correctly, parsing line numbers as you’re describing is distinct from those issues, though - so it’s likely worthy of its own report.

One question to narrow that down, though - does the custom command work when you click on the path to a text file that isn’t appended by a line and column number reference?

Hey, thanks for taking the time to look into this.

OK, I just discovered something interesting, which is that if I do:

echo "some/test/path.txt"

then click, it runs the custom command, which is confusing because I was quite sure it wasn’t doing this before (even after reboot).

If I do

echo "some/test/path.txt:2"

This also works! Lands me on line 2 in webstorm (which is not the default for .txt files, so I know it’s using the custom command).

So we’re almost there, but this is where things fail:

echo "some/test/path.txt:2:2"

Clicking on this pops up an error: The file or folder /home/.../some/test/path.txt:2 does not exist.

So it would appear that it simply does not parse the column number correctly, and sadly this is what cripples my developer experience with Konsole, since all errors/stacks include both a line # and column #.

I’m on Konsole, Version 21.12.3 by the way.

Interesting - the details of this one are going to need someone more knowledgeable to offer their thoughts :slight_smile:

As a general note, though, if this is a bug that you’re experiencing, it would be helpful to try the specific steps you’re taking on an up-to-date version - Konsole 21.12.3 is about three years old, so it is possible that things may function differently on a currently-supported version.

OK, so I’m on konsole 23.08.5 now and have an update.

Setting my custom command to

echo PATH LINE COLUMN > ~/test.txt

and

  • clicking on some/path/file.js:70 writes /the/full/path/file.js 70 0 to ~/test.txt.
  • clicking on some/path/file.js:70:10 writes nothing to ~/test.txt
  • clicking on /some/abs/path/file.js:70 writes /some/abs/path/file.js 70 0 to ~/test.txt.
  • clicking on /some/abs/path/file.js:70:10 writes nothing to ~/test.txt

So it would appear what we have is a bug in the way konsole parses columns.

Bug #2? Valid, absolute paths within ()'s are not underlined and are not clickable. Example (/etc/profile) is not underlined but /etc/profile is. This is important for developers often filenames are printed in ()'s.

I had a look at the code. Oh, I can’t link because my account is new, I guess. Let me try anyway: github dot com/KDE/konsole/blob/dc93ba3fa5c262509058b817d72cd9d89266920d/src/filterHotSpots/FileFilterHotspot.cpp#L82

konsole does not support the format (PATH:LINE:COLUMN), which is commonly output by Node when there’s a stack trace. There will be no RegEx match in this case.

However, the code does support the format PATH:LINE:COLUMN: (NB trailing colon).

There’s no way to post an issue on the konsole GitHub, which is unusual. Instead, I guess I have to subscribe to a developer mailing list in order to post a bug? I’m not going to do that. It looks like a developer named Ahmad Samir worked on this code last, 5 years ago.

Here’s the relevant comment & code:

    // Output of e.g.:
    // - grep with line numbers: "path/to/some/file:123:"
    //   grep with long lines e.g. "path/to/some/file:123:void blah" i.e. no space after 123:
    // - compiler errors with line/column numbers: "/path/to/file.cpp:123:123:"
    // - ctest failing unit tests: "/path/to/file(204)"
    static const QRegularExpression re(QStringLiteral(R"foo([:\(](\d+)(?:\)\])?(?::(\d+):|:[^\d]*)?$)foo"));

Possible fix:

    static const QRegularExpression re(QStringLiteral(R"foo([:\(](\d+)(?:\)\])?(?::(\d+)(?::[^\d]*)?)?$)foo"));
1 Like

GitHub repositories are mirrors for convenience of the official code repositories at KDE Invent, hosted on GitLab: Utilities / Konsole · GitLab

KDE developers use a Bugzilla instance for handling bug reports and feature requests - the Community Wiki guide to getting started there and creating a report is located here: Get Involved/Issue Reporting - KDE Community Wiki No need to navigate mailing lists for that :slight_smile:

2 Likes

Thanks for the info. I submitted a bug report, which can be found here: 501004 – custom command for file paths does not correctly parse COLUMN for Node.js stack traces