Skip to content
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

VS Code Custom URL Scheme supports opening a new window instead of using the current window. #10650

Open
XhosaS opened this issue Jan 22, 2025 · 6 comments
Assignees
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@XhosaS
Copy link

XhosaS commented Jan 22, 2025

I created a button on a webpage that allows entering a specified container on a specified server. Its construction method is as follows:

path={"containerName":"MyContainer","settings":{"host":"ssh://xxx.xxx.xxx.xxx"}}
local hash="$(echo -n "${path}" | xxd -pu - | tr -d '[:space:]')";
vscode://vscode-remote/attached-container+${hash}/dir

However, this method always connects the currently focused window to the container instead of opening a new window.

But in the terminal, I can use the command code --folder-uri vscode-remote://attached-container+${hash}/dir to open a new window instead of using the current one.

Can we provide an extension command for the Custom URL Scheme that allows the URL to open a new window instead of using the current one?

@vs-code-engineering vs-code-engineering bot added the containers Issue in vscode-remote containers label Jan 22, 2025
@chrmarti
Copy link
Contributor

The same folder URI can only be open in a single VS Code window. This is a restriction by VS Code.

@chrmarti chrmarti added the info-needed Issue requires more information from poster label Jan 22, 2025
@XhosaS
Copy link
Author

XhosaS commented Jan 22, 2025

Sorry, I didn't describe it clearly. Suppose I don't have VS Code open, and there is a target container A with the URL vscode://vscode-remote/attached-container+${hashA}/dir. When I use the URL, it successfully opens VS Code and connects to the container. However, if I then use another URL to open container B: vscode://vscode-remote/attached-container+${hashB}/dir2, it does not open a new VS Code window but instead reconnects my current focused window to container B.

@chrmarti
Copy link
Contributor

Can you try adding --new-window to the command arguments?

@XhosaS
Copy link
Author

XhosaS commented Jan 23, 2025

Can you try adding --new-window to the command arguments?

Where should --new-window be added? vscode://vscode-remote/attached-container+${hashA}/dir --new-window?

@chrmarti
Copy link
Contributor

Yes, that should work. The order of options shouldn't matter.

@XhosaS
Copy link
Author

XhosaS commented Jan 23, 2025

Yes, that should work. The order of options shouldn't matter.

This doesn't work, as VSCode will interpret dir --new-window as the name of the workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants