Navigation Menu

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

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

Comments

@danielweck
Copy link

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

const EXTENSION = 'vscode-open';
const EXTENSION_CONFIG_NAMESPACE = 'open';

...and to show src/extension.ts in VSCode with the code selection line 6-7 (extracted from the URL #L6-L7).

Any thoughts?

@alexander-yu
Copy link
Owner

alexander-yu commented Sep 9, 2020

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?

@danielweck
Copy link
Author

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?

@alexander-yu
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants