Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "hyperlink" matching for arbitrary patterns and adding custom handlers #8849

Open
Tracked by #5001
mikemaccana opened this issue Jan 22, 2021 · 13 comments
Open
Tracked by #5001
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@mikemaccana
Copy link
Contributor

Description of the new feature/enhancement

A lot of developer tools print errors in:

dir/dir/filename:lineNumber:columnNumber

format. For example:

image

Terminal should make these clickable.

Proposed technical implementation details (optional)

Leverage any relevant bits about how http links work in the current version of Terminal.

@mikemaccana mikemaccana added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jan 22, 2021
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jan 22, 2021
@zadjii-msft
Copy link
Member

How would that work though? Do editors have any sort of unified way of requesting "please open this file, to this row/column"? Because I'm pretty sure they don't. VsCode might have one way, emacs another, vim a third - but I'm not sure there's any way for the terminal to know which program is the user's editor for a given filetype.

Plus like, if we ShellExecute a .py file, isn't the default behavior to run the file with the python interpreter? So that's even less likely to work!

I think VSCode's integrated terminal gets away with this because they know the editor is VsCode, and they know exactly how to tell themself how to open a file to a given row/column.

If there's a way of doing this that's supposed to be standard across editors, I'm happy to throw our weight behind it. But I'm not sure how feasible this request is without some sort of standard way of doing this.

@zadjii-msft zadjii-msft added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. labels Jan 22, 2021
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Jan 26, 2021
@ghost
Copy link

ghost commented Jan 26, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@KalleOlaviNiemitalo
Copy link

Do editors have any sort of unified way of requesting "please open this file, to this row/column"?

Nano, vim, emacs (or emacsclient), and less support +42 file for opening file and selecting line 42. I don't think there is a common syntax for column numbers in argv.

@ghost ghost removed the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Jan 26, 2021
@mikemaccana
Copy link
Contributor Author

mikemaccana commented Jan 26, 2021

How would that work though?

As a vscode user

✅ Open file:lineNumbers in editor
Editor command. $FILE is the file name, $COLUMN is the column name
[ code.exe --goto "$FILE:$LINE" ]

As a vi user

✅ Open file:lineNumbers in editor
Editor command. $FILE is the file name, $COLUMN is the column name
[ vi $FILE +$LINE ]

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jan 26, 2021
@DHowett
Copy link
Member

DHowett commented Jan 26, 2021

This is just a specific case of #8902 (which somebody just filed!). We should consolidate.

@zadjii-msft
Copy link
Member

Okay, I'll work on consolidating this with 8902, and comments we've mentioned elsewhere.

@mikemaccana
Copy link
Contributor Author

Thanks!

@zadjii-msft
Copy link
Member

And what about support editor:// protocol handler?
aik099/PhpStormProtocol

image


As of Windows Terminal Preview 1.4 (I think) you can Ctrl+click on text that matches a URL and it will open in a browser. This feature request would be to match on certain text and turn that into a clickable link using some of the text as a parameter.

Example

Let's say the following is on the terminal, from the output of git log

Fixes issue in T1234

I would like to setup a regex \b(T\d+)\b and when I Ctrl+click on T1234, open up https://example.com/tasks/T1234.

I would like this to be configured in settings.json something like

"arbitrarylinks": [
    {
        "pattern": "\\b(T\\d+)\\b",
        "link": "https://example.com/tasks/$1"
    }
]

So lets say we wanted to solve both these cases. What we need is a way to specify:

  • I want to match an arbitrary pattern of text in the Terminal, and
  • When I click on such a pattern, what do we do?
    • Right now, we just ShellExecute the hyperlink.
    • We need to also be able to ShellExecute links that users specify, with contents from the match
    • We also need to be able to execute arbitrary executables that the user has specified, again using contents from the match

So we couldn't just do this automatically for all editors in one unified fashion, unfortunately. But we could allow users to add config for their specific editor.

@zadjii-msft zadjii-msft changed the title Terminal should make filename:linenumber links clickable Allow "hyperlink" matching for arbitrary patterns and adding custom handlers Jan 26, 2021
@DHowett DHowett removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jan 28, 2021
@DHowett DHowett added Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) labels Jan 28, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jan 28, 2021
@DHowett
Copy link
Member

DHowett commented Jan 28, 2021

This could also be an extension point. /cc @zadjii-msft triaged into backlog.

@stinos
Copy link

stinos commented Mar 24, 2021

How would that work though?

Could have a look at how ConEmu does it: supply a bunch of 'macros' which are fed into a custom command and replaced there. Activated with Ctrl key but that's minor. See https://conemu.github.io/en/SettingsHighlight.html.

This is the only reason I'm still not on Terminal fulltime: it's not interesting to have to manually copy/paste file/line from the terminal to the editor.

@Klaster1
Copy link

Any updates on this? Not baing able to click on file paths in output like in ConEmu is a huge deal breaker, I do this all the time while working with tests and TypeScript.

@zadjii-msft
Copy link
Member

zadjii-msft commented Jan 30, 2024

Nothing since I posted the spec draft in #15700. Alas, been too busy with other priorities to loop back on that one.

From that spec:

Turn text into clickable links

A similar request from [#8849] that should also be captured. People want the
ability to configure the regexes that are used for turning text into clickable
links. Currently, we only match on a predefined set
into clickable text.

// I did not test these regexes
{
    "match": "(^(.+)\\/([^\\/]+)$):(\\d):(\\d)",
    "action": "clickableLink",
    "target": "code.exe --goto \"${match[1]}:${match[2]}\""
},
{
    "match": "git push --set-upstream origin ([^\\w]*)",
    "action": "clickableLink",
    "target": "vi \"${match[1]}\" +${match[2]}\""
},
{
    "match": "\\b(T\\d+)\\b",
    "action": "clickableLink",
    "target": "https://example.com/tasks/${match[1]}"
},

@trajano
Copy link

trajano commented May 14, 2024

I'd also like a simple pattern to translate the SSH azure devops links to HTTP equivalents.

e.g. ssh.dev.azure.com:v3/ORG/PROJ/REPO to https://dev.azure.com/ORG/PROJ/_git/REPO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

7 participants