Open nipatriknilsson opened 1 week ago
I can reproduce, we are actually not having the exact same workspace in multiple windows (which is prohibited generally) but we simply create a new ad-hoc untitled workspace and open that.
I think what is missing here is a way on startup to figure out if a previous untitled workspace with the same folders is already being restored and then use that instead of opening another untitled workspace.
Opening this up for help wanted. The entry point for deciding which windows to open is here:
[...] untitled workspace with the same folders is already being restored [...]
There is another use case here:
mkdir -p Documents/a
mkdir -p Documents/b
mkdir -p Documents/c
mkdir -p Documents/d
touch Documents/a/1.txt
touch Documents/b/2.txt
touch Documents/c/3.txt
touch Documents/d/4.txt
code --password-store=basic --wait --user-data-dir test1 Documents/a
code --password-store=basic --wait --user-data-dir test2 Documents/b Documents/c
code --password-store=basic --wait --user-data-dir test1 Documents/a
code --password-store=basic --wait --user-data-dir test2 Documents/b Documents/c
code --password-store=basic --wait --user-data-dir test2 Documents/b Documents/c Documents/d # add a new folder to the workspace
The last line adds a new folder to the untitled workspace.
We do have a --add
option to add a folder to the last opened workspace. I think in your example I would not expect that to happen automatically without this parameter.
We do have a
--add
option to add a folder to the last opened workspace. I think in your example I would not expect that to happen automatically without this parameter.
Another way of solving it would be a "--list-workspaces" option:
code --password-store=basic --wait --user-data-dir test1 --list-workspaces
If that option is given create user-data-dir if it doesn't exist, print workspaces (or nothing) and exit. Then I can handle all cases of above, by bash logic.
This would actually have to be addressed somewhere here where we know which paths to restore from the last session and then right after decide on creating untitled workspace:
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
When you open
code
with multiple workspaces on the command line, you get two code windows opened after the first time. Demonstration code in bash:After each
code
session opens, close it to proceed. The last line opens two windows, although it is exactly the same as the secondcode
line.