rightclick->open link doesn't work on file://full/path/filename.cpp:linenumber links

Bug #2048569 reported by Imre Péntek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-terminal (Ubuntu)
New
Undecided
Unassigned

Bug Description

TLDR: I want to be able to open links like file:///full/path/to/filename.cpp:linenumber with rightclick open link

video explanation: https://youtu.be/PmQAx7HF7_c

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: gnome-terminal 3.44.0-1ubuntu1
ProcVersionSignature: Ubuntu 6.2.0-39.40~22.04.1-generic 6.2.16
Uname: Linux 6.2.0-39-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Mon Jan 8 14:05:15 2024
InstallationDate: Installed on 2022-05-05 (612 days ago)
InstallationMedia: Ubuntu 22.04 LTS "Jammy Jellyfish" - Release amd64 (20220419)
SourcePackage: gnome-terminal
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Imre Péntek (pentek-imre) wrote :
Revision history for this message
Imre Péntek (pentek-imre) wrote :

the issue that qt creator can't handle file:///full/path/to/filename.cpp:linenumber on commandline (but supposed to) is known: https://bugreports.qt.io/browse/QTCREATORBUG-30143
however qt creator handles /full/path/to/filename.cpp:linenumber on commandline that's how I made a wrapper restoring the currently unavaliable (buggy) functionality

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

The problem is: according to the URI specification, there is no way to denote the line number. In fact, the URI "file:///full/path/to/filename.cpp:linenumber" refers to a file whose name is literally "filename.cpp:linenumber".

Correspondingly, the entire stack that handles the opening of a URI (the gtk_show_uri() method and anything that's underneath it) doesn't know the concept of line number either. Think of all the .desktop and similar files shipped by text editors and similar software, currently they are unable to specify how to pass on the line number to them.

Getting it modified to support line numbers would require to modify GTK, modify the .desktop file specification, and _all_ the software out there that ship such a .desktop file, that is, practically all the text viewers/editors out there, to conform to a nonstandard (and backwards incompatible!) extension of the URI specification. This is clearly not going to happen.

In order to move forward, first the URI specification would have to be modified to introduce the concept of line number. In a backwards compatible way, that is, the ':' character is out of question, it would need to go to '?query' or '#fragment', probably the latter. Also figure out what to do if the file is in any other format than plain text (what would the given field mean for pdf (page number?), png, music/video (time offset?) etc.) How to distinguish opening an html file as a rendered page (when '#fragment' jumps to the corresponding 'a name' or 'id') vs. opening an html file as raw text (and then jumping to the given line number)?

Then the remaining software components would one by one need to be updated to this spec.

This was also discussed in the user comments in the gist page of the explicit hyperlink feature for terminals, and was similarly inconclusive.

Unfortunately, it's practically a WONTFIX.

You can probably use the nonstandard wrapper that you created for Qt Creator for GNOME Terminal as well. Just have a wrapper script that opens your file that handles this ':' and translates to the line number command line parameter of your preferred text viewer/editor. Unfortunately the world is not ready to standardize this personal hack into a mainstream solution, and such a change cannot begin at GNOME Terminal.

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

What we _could_ perhaps do (because detecting a URI in a text flow is undefined territory, with already quite a few quirks in place, such as stripping off the trailing dot) is to strip off the trailing ":linenumber". That is, the trailing ":" if it's followed by numbers only.

That way you could easily and quickly open the desired file "filename.cpp". Not at the desired position, though.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.