Skip to content

command to open file at line number #3106

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

Closed
bpmct opened this issue Apr 12, 2021 · 13 comments
Closed

command to open file at line number #3106

bpmct opened this issue Apr 12, 2021 · 13 comments
Labels
feature New user visible feature

Comments

@bpmct
Copy link
Member

bpmct commented Apr 12, 2021

suggested by @jkaster

Currently a file can be opened in an existing window: #1994

VS Code itself supports opening a file with line number with the -g (goto?) flag (see microsoft/vscode#39891):

code -g file.txt:4
# works :)

code-server -r -g file.txt:4
# error Unknown option -g

It would probably make sense to reuse this schema.

@bpmct bpmct added the feature New user visible feature label Apr 12, 2021
@jkaster
Copy link

jkaster commented Apr 12, 2021

Thanks for creating the follow-up issue. It's a modest enhancement of #1964

My use case is for the "protocol" or url version of code-server. Our API Explorer can direct link to source code declarations and example files. Currently, those open as GitHub permalinks.

My goal is to support opening the relevant file at the correct line number in whatever editor the user prefers, so having (e.g.) http://code-server:port/path=/dir/sub/file.ext:line would address this use case for code-server.

@jsjoeio jsjoeio added this to the On Deck milestone Apr 12, 2021
@stale
Copy link

stale bot commented Oct 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale bot added the stale label Oct 10, 2021
@jkaster
Copy link

jkaster commented Oct 11, 2021

I hope this gets implemented some day, since it was deemed relatively easy and it would be great for integration

@stale stale bot removed the stale label Oct 11, 2021
@stale
Copy link

stale bot commented Apr 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale bot added the stale label Apr 9, 2022
@jkaster
Copy link

jkaster commented Apr 11, 2022

Oh well. Disappointing.

@stale stale bot removed the stale label Apr 11, 2022
@AndrewChe7
Copy link

It would be great if this feature will be implemented. There was already lots of requests, but it wasn't implemented yet. #1292 and #2179 was closed.

@code-asher
Copy link
Member

At long last implemented in #5620 released in v4.8.0.

@jkaster
Copy link

jkaster commented Feb 9, 2023

This is exciting! What's the protocol syntax version of "open folder/file[at line]"?

@code-asher
Copy link
Member

code-asher commented Feb 13, 2023

If you are using the integrated terminal we delegate to Code's own CLI so it will look like:

code-server -r -g test.txt:4
code-server -r -g test.txt:4:1

If you are running outside code-server in an external terminal it goes through our own CLI and we just always assume -g there apparently:

code-server -r test.txt:4
code-server -r test.txt:4:1

We should eventually remove our CLI and directly delegate to Code's in external terminals to remove the disparity at some point.

@jkaster
Copy link

jkaster commented Feb 13, 2023

Sorry for not being clear. By "protocol" I meant URL syntax

@code-asher
Copy link
Member

Ahh my bad, this is only for the command-line :line:col syntax. I will add that we also want line/col syntax for the URL method in #1964 for when that gets implemented.

@code-asher
Copy link
Member

I think I am just being dumb, seems this issue was originally for the URL method but I misread the first post. Sorry for the noise.

Still, I think we can keep this in #1964 since I think it would make sense to implement it all at once.

@jkaster
Copy link

jkaster commented Feb 13, 2023 via email

@code-asher code-asher removed this from the On Deck milestone Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New user visible feature
Projects
None yet
Development

No branches or pull requests

5 participants