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

`--wait` command-line option

Open bsiegert opened this issue 4 years ago • 13 comments

If you are working in the terminal, the suggested way of using VS Code itself as your editor for commit messages and such is to set

export EDITOR="code --wait"

This does not work within code-server obviously. You can set EDITOR to code-server but it does not have a --wait option, so git (or whatever) will not wait for you to close the window.

The --wait option, together with one or more files, should make the code-server binary only exit when these files are closed.

bsiegert avatar Sep 18 '20 11:09 bsiegert

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 27 '21 02:10 stale[bot]

This is a legitimate feature request, please don't close it.

bsiegert avatar Oct 27 '21 05:10 bsiegert

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 25 '22 16:04 stale[bot]

Repeating myself: please do not close this legitimate feature request.

bsiegert avatar Apr 26 '22 17:04 bsiegert

Is this something that vanilla VS Code supports already?

jsjoeio avatar Apr 26 '22 17:04 jsjoeio

Yes, it does, with code --wait.

bsiegert avatar Apr 26 '22 17:04 bsiegert

Interesting! Well if that's the case, I wonder if we could just pass it through and it would just work 🤔

How does this work in practice?

  1. change EDITOR
  2. git add . stage changes
  3. git commit start commit

Then it opens VS Code, you edit message, then it exits VS Code?

Understanding how this works in practice would help us find time to investigate this faster.

jsjoeio avatar Apr 26 '22 19:04 jsjoeio

Vscode has the '--wait' option exactly like Sublime and Atom before it. (Notepad++ and most other multi-tab editors have a similar but differently named switch). They basically tell the editor to open the specified file in a separate thread and that there is a process waiting for that thread to exit.

In git you typically configure your editor with: 'git config --global core.editor "code --wait"' So every time git tries to edit the "hidden" COMMIT_MESSAGE file it does that with the '--wait' switch.

It would be very useful to have the same feature available in the server version of VSCode.

JKrag avatar Apr 27 '22 06:04 JKrag

Ah okay, thank you @JKrag! If it's supported in VS Code, then it does seem like something we should be able to support in code-server without too much work. But that's me guessing. We'd have to investigate as well.

jsjoeio avatar Apr 27 '22 17:04 jsjoeio

I guess the question might be whether it is "ok" for code-server to be spawning new processes on the host it is running on. I don't know if this is a challenge or security risk or anything, but the the thought did come to mind.

JKrag avatar Apr 28 '22 08:04 JKrag

Not only VS Code supports it, but also their "remote" implementation (i.e. Codespaces/Containers) and even Gitpod's OpenVSCode Server.

In my opinion, this is a huge feature which is missing in the code-server CLI, which essentially makes me unable to use code-server's VS Code to edit git commit messages, or to edit anything else which is spawned on the command line.

felipecrs avatar Jul 19 '22 20:07 felipecrs

@code-asher how difficult would this be to implement?

Thinking out loud:

  1. add CLI flag
  2. when passed, open code-server with git commit message
  3. when commit message is finished and file is closed, close code-server and stop process

Screenshots

image image

jsjoeio avatar Jul 20 '22 16:07 jsjoeio

If we can get their script working we might not need to implement anything. I think all we have to do is update the Node path.

code-asher avatar Jul 21 '22 00:07 code-asher