code-server icon indicating copy to clipboard operation
code-server copied to clipboard

command to open file at line number

Open bpmct opened this issue 4 years ago • 6 comments

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 avatar Apr 12 '21 14:04 bpmct

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.

jkaster avatar Apr 12 '21 16:04 jkaster

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[bot] avatar Oct 10 '21 08:10 stale[bot]

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

jkaster avatar Oct 11 '21 16:10 jkaster

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[bot] avatar Apr 09 '22 17:04 stale[bot]

Oh well. Disappointing.

jkaster avatar Apr 11 '22 18:04 jkaster

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.

AndrewChe7 avatar Aug 12 '22 13:08 AndrewChe7

At long last implemented in https://github.com/coder/code-server/pull/5620 released in v4.8.0.

code-asher avatar Feb 09 '23 22:02 code-asher

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

jkaster avatar Feb 09 '23 23:02 jkaster

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.

code-asher avatar Feb 13 '23 19:02 code-asher

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

jkaster avatar Feb 13 '23 19:02 jkaster

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 https://github.com/coder/code-server/issues/1964 for when that gets implemented.

code-asher avatar Feb 13 '23 20:02 code-asher

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.

code-asher avatar Feb 13 '23 20:02 code-asher

No worries at all! Thanks for the reply and the work

On Mon, Feb 13, 2023, 12:58 PM Asher @.***> wrote:

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 https://github.com/coder/code-server/issues/1964 since I think it would make sense to implement it all at once.

— Reply to this email directly, view it on GitHub https://github.com/coder/code-server/issues/3106#issuecomment-1428671695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABORGASV64F4GNPEGAG6YVLWXKN6TANCNFSM42ZNZSAQ . You are receiving this because you were mentioned.Message ID: @.***>

jkaster avatar Feb 13 '23 20:02 jkaster