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
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/chdsbd/vscode-githubinator/blob/57cbb22276fddb62f83e2926199a42bedacdaf8d/src/test/index.ts#L13-L15
https://github.com/chdsbd/vscode-githubinator/blob/57cbb22276fddb62f83e2926199a42bedacdaf8d/src/test/index.ts#L13-L15
...and to show src/test/index.ts in VSCode with the code selection line 13-15 (extracted from the URL #L13-L15).
Any thoughts?
Thanks for the suggestion.
I was thinking either we allow the user to paste a link or we could try reading the user's clipboard and prompting them to open the file.
Did you have a workflow in mind?
Yes. Parsing the components / segments of the URL is effectively the reverse operation of the extension’s current routine which builds the links based on information from the Git repository (branch, commit sha, etc.). However I think this is unnecessarily complicated. My feature request could in fact be implemented more “naively”, whilst still remaining very useful.
To make the implementation simpler, the “left” part of the URL could be ignored. The “right” part which contains the file path and line number(s) could be parsed (e.g. src/test/main.ts#L8-L23), and the extension could simply attempt to load the targeted file, and scroll + select the targeted code fragment (I say “attempt”, because if the left part of the URL doesn’t actually match the current repo/commit hash/branch, then of course VSCode might not be able to locate the targeted file, or to sync to the requested line numbers).
VSCode already takes strings like src/test/main.ts via the CTRL-SHiFT-P keyboard shortcut (command input), so I am hoping that implementing support for line numbers src/test/main.ts#L8-L23 is not too complicated?
This is fixed with #64