vscode-open-in-github icon indicating copy to clipboard operation
vscode-open-in-github 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 • 1 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/d4rkr00t/vscode-open-in-github/blob/917e4c6506d87b99cbc0c4c560d846434e819684/src/file.ts#L12-L20

https://github.com/d4rkr00t/vscode-open-in-github/blob/917e4c6506d87b99cbc0c4c560d846434e819684/src/file.ts#L12-L20

...and to show src/file.ts in VSCode with the code selection line 12-20 (extracted from the URL #L12-L20).

Any thoughts?

danielweck avatar Sep 08 '20 11:09 danielweck

Just so you know, your "Open in GitHub" extension has improved my dev workflow so I am really thankful. Note that for the reverse operation I now use this "Open" extension: https://github.com/alexander-yu/vscode-open The filesystem absolute paths (e.g. VSCode workspace) must currently be hard-coded, but configuring the extension for my local personal use is easy enough:

    "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": "#"
        }
    ]

I use the two VSCode extensions together during peer code reviews, as we use GitHub's own source browser a lot to communicate over Slack. So being able to convert a GitHub source tree URL to VSCode file (and vice-versa) is great!

danielweck avatar Sep 15 '20 08:09 danielweck