You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
#2
Closed
danielweck opened this issue
Sep 8, 2020
· 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/alexander-yu/vscode-open/blob/a2e73c00d0143e3713294a9d1d795d621e64efed/src/extension.ts#L6-L7
Yeah, seems like a helpful feature to me! I'm imagining a command that brings up an input box to paste the URL into, which will then open the correct file — does that sound like the workflow you're thinking of?
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?
Yeah, makes sense — FWIW this extension doesn't actually use branch/commit sha information to build links, as it's a little naively implemented at the moment. But yeah, that sounds reasonable to me — I'll look into what I can do to support that.
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/alexander-yu/vscode-open/blob/a2e73c00d0143e3713294a9d1d795d621e64efed/src/extension.ts#L6-L7
vscode-open/src/extension.ts
Lines 6 to 7 in a2e73c0
...and to show
src/extension.ts
in VSCode with the code selection line 6-7 (extracted from the URL#L6-L7
).Any thoughts?
The text was updated successfully, but these errors were encountered: