vscode-copy-github-url icon indicating copy to clipboard operation
vscode-copy-github-url copied to clipboard

Feature request: inverse operation, start with a GitHub URL which contains hash line number(s), and open the file in VSCode at the designated line / code selection

Open danielweck opened this issue 5 years ago • 3 comments

Hello, great extension, thank you! Very useful for code peer reviews over Slack / instant messaging, to exchange URLs whilst working locally from VSCode. However the inverse functionality would be very useful too.

For example I would like to be able to copy such URL: https://github.com/differentmatt/vscode-copy-github-url/blob/ad85a468eb8f1b05979591335ba391c58abeb5a7/src/main.js#L6-L8

https://github.com/differentmatt/vscode-copy-github-url/blob/ad85a468eb8f1b05979591335ba391c58abeb5a7/src/main.js#L6-L8

...and to show src/main.js in VSCode with the code selection line 6-8 (extracted from the URL #L6-L8).

Any thoughts?

danielweck avatar Sep 08 '20 12:09 danielweck

Cool idea. What do you think the user experience would be to enter this URL into VSCode and open the correct file with selection?

differentmatt avatar Mar 23 '22 05:03 differentmatt

Could it be a command that would prompt the user to paste?

acovrig avatar Mar 30 '22 18:03 acovrig

Hello again! Disclosure: some months ago I settled on https://github.com/d4rkr00t/vscode-open-in-github for the vscode-to-browser operation, but I am glad other alternatives such as differentmatt/vscode-copy-github-url exist :)

For the reverse browser-to-vscode operation I have been using https://github.com/alexander-yu/vscode-open but the experience is not totally friction-free due to necessary configuration, e.g.:

    "open.uriMappings": [
        {
            "pattern": "https://github.com/owner1/repo1/(?<blob>[^/]+)/(?<ref>[^/]+)/${regex:file}${regex:lines}",
            "output": "/Users/danielweck/GitHub/owner1/repo1/${match:file}${match:lines}",
            "lineSeparator": "#"
        },
        {
            "pattern": "https://github.com/(?<owner>[^/]+)/(?<repo>[^/]+)/(?<blob>[^/]+)/(?<ref>[^/]+)/${regex:file}${regex:lines}",
            "output": "${match:file}${match:lines}",
            "lineSeparator": "#"
        }
    ]

danielweck avatar Mar 30 '22 19:03 danielweck