Skip to content

Make opening in an existing instance work outside code-server #2099

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

Merged
merged 10 commits into from
Oct 12, 2020
Merged

Conversation

code-asher
Copy link
Member

Closes #2036

Refactored the wrapper a little bit as well so we don't have to do all the socket checking stuff in both the parent and the child.

Copy link
Contributor

@nhooyr nhooyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor makes the code a lot clearer!

Feels more appropriate there to me.
- Immediately create ipcMain so it doesn't have to be a function which I
  think feels cleaner.
  - Move exit handling to a separate function to compensate (otherwise
    the VS Code CLI for example won't be able to exit on its own).
- New isChild prop that is clearer than checking for parentPid (IMO).
- Skip all the checks that aren't necessary for the child process (like
  --help, --version, etc).
  - Since we check if we're the child in entry go ahead and move the
    wrap code into entry as well since that's basically what it does.
- Use a single catch at the end of the entry.
- Split out the VS Code CLI and existing instance code into separate
  functions.
This will allow cliArgs to be only the actual arguments the user passed
which will be used for some logic around opening in existing instances.
Otherwise it outputs when trying to open a file in an existing instance
externally. Externally there isn't an environment variable to branch on
to skip this line so instead output it with the other info lines in the
child process.
It'll always be zero here.
Now that the exception handling happens further up there doesn't seem to
be an advantage in having this in a separate method.
@code-asher code-asher force-pushed the open-in branch 2 times, most recently from cccc525 to 466a04f Compare October 9, 2020 22:23
@code-asher code-asher requested a review from nhooyr October 9, 2020 23:30
@code-asher
Copy link
Member Author

Rebased, also added two commits (remove tryParse and update the standalone test).

@nhooyr nhooyr merged commit 00383b7 into master Oct 12, 2020
@nhooyr nhooyr deleted the open-in branch October 12, 2020 05:14
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

Successfully merging this pull request may close these issues.

Allow opening files in existing code-server instance from a terminal outside code-server
2 participants