Skip to content

[Bug]: -r opens wrong file in wrong instance #5709

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
4 tasks done
danog opened this issue Oct 26, 2022 · 10 comments · Fixed by #6191
Closed
4 tasks done

[Bug]: -r opens wrong file in wrong instance #5709

danog opened this issue Oct 26, 2022 · 10 comments · Fixed by #6191
Labels
bug Something isn't working
Milestone

Comments

@danog
Copy link
Contributor

danog commented Oct 26, 2022

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Firefox
  • Local OS: Arch
  • Remote OS: Arch
  • Remote Architecture: x86_64
  • code-server --version: 4.7.1 b562d4a with Code 1.71.2

Steps to Reproduce

  1. Open two code-server workspaces for folders a and b in two tabs
  2. In folder a, run code-server -r a.php

Expected

The first tab opens a/a.php

Actual

The second tab opens b/a.php

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

No response

@danog danog added bug Something isn't working triage This issue needs to be triaged by a maintainer labels Oct 26, 2022
@tobycm
Copy link
Contributor

tobycm commented Oct 26, 2022

Probably the second tab is opened after the first tab so code-server favored it over the first one.

@danog
Copy link
Contributor Author

danog commented Oct 26, 2022

Yeah, I imagined this was the case, but vscode automatically opens the file in the correct instance.

@tobycm
Copy link
Contributor

tobycm commented Oct 26, 2022

I opened up 2 a and b folder in vscode, in different windows. Opening a file using the code cli leads me to the b window so I guess this is normal behaviour?

@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 26, 2022

Thank you both for your insight! If the behavior is the same in vscode, then we could classify it as an upstream issue. Let me know if we should close this!

@felipecrs
Copy link

Just to clarify, I believe @danog means that he's using the VS Code integrated terminal. When inside the integrated terminal, code -r ensures to open the file in the current window.

@danog
Copy link
Contributor Author

danog commented Oct 26, 2022

Actually no I opened the files in a separate terminal, and I could've sworn this worked/was recently fixed in vscode, will try again tomorrow

@danog
Copy link
Contributor Author

danog commented Nov 1, 2022

Checked, this works just fine in vscode.

@jsjoeio jsjoeio added needs-investigation This issue needs to be further investigated and removed triage This issue needs to be triaged by a maintainer labels Nov 1, 2022
@jsjoeio jsjoeio added this to the On Deck milestone Nov 1, 2022
@sleexyz
Copy link
Contributor

sleexyz commented Apr 30, 2023

If I understand correctly, the vscode-ipc file can only track the most recently registered vscode ipc socket. This means -r so far can only open files in the most recently registered client.

A possible solution:

Extend vscode-ipc to track multiple socket paths and their corresponding workspaces / folders (i.e. vscode-ipc.json):

[
  {
  "folder": <FOLDER>,
  "socketPath": <SOCKET_PATH>,
  }
]

Basically:

  • Switch from using a single-entry vscode-ipc to using a multi-entry vscode-ipc.json
  • Modify the store_socket.diff patch to have vscode append an entry to vscode-ipc.json
  • Modify "open in existing instance" behavior to find the most relevant vscode ipc socket for a given file.

Happy to make a PR to get this to work :)

@code-asher
Copy link
Member

That sounds like a lovely solution and PRs are definitely welcome.

Just to check, we are talking about the behavior when running code-server -r from an external terminal, right? There we use vscode-ipc but from inside the integrated terminal VS Code does its own thing so if the problem is presenting there we may want to reproduce in Codespaces and raise it upstream.

@sleexyz
Copy link
Contributor

sleexyz commented May 2, 2023

Just to check, we are talking about the behavior when running code-server -r from an external terminal, right?

Correct.

@code-asher code-asher removed the needs-investigation This issue needs to be further investigated label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants