microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.48k stars 29.37k forks source link

ALT + TAB causes Explorer tree view to fully collapse in multi root workspace #139462

Open bluenote10 opened 2 years ago

bluenote10 commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Create a multi-root workspace with nested workspace folders. I'm using a structure like this:
some_multi_language_project  <-- Workspace folder
├── example.code-workspace
├── python
└── rust                     <-- Workspace folder
    ├── Cargo.toml
    └── src
        └── lib.rs
Small bash script to create the example project ```sh #!/bin/bash mkdir -p some_multi_language_project cd some_multi_language_project mkdir -p python mkdir -p rust/src cd rust cat > Cargo.toml << EOF [package] name = "example" version = "0.1.0" EOF cat > src/lib.rs << EOF pub fn hello_world() { println!("Hello world"); } EOF cd .. cat > example.code-workspace << EOF { "folders": [ { "path": "." }, { "path": "rust" } ], "settings": {} } EOF ```

Or for direct download: some_multi_language_project.zip

  1. Run code --disable-extensions some_multi_language_project/example.code-workspace

  2. Work on a file. Notice that the source tree is unfolded in the Explorer view, and the currently active file is properly selected.

  3. Press <ALT> + <TAB> to switch to a different application, and <ALT> + <TAB> again to go back to VSCode

  4. Notice that the source tree in the Explorer view has fully collapsed. The currently active file is not selected any more.

Peek 2021-12-19 10-46

Note the problem doesn't seem to be fully deterministic. In the tiny example workspace it happens with perhaps ~50% probability. In a bigger real world workspace, it happens with more like ~95%.


From a practical point of view this issue is more disconcerting than I have expected initially, because every time it happens I feel like I have lost my orientation due to the fully collapsed source tree.

YunHsiao commented 2 years ago

Can confirm the same behavior on windows.

And Mac #136258

dynalz commented 2 years ago

For me doesn't even need to be in multi root workspace. Just doing ALT + TAB to anything and coming back to vscode and everything gets collapsed. Its very disruptive.

Is there any setting regard this behavior?

starball5 commented 11 months ago

Related on Stack Overflow: VS Code collapses folder in Explorer View when it gets focus for multi-root workspaces

xaxazak commented 11 months ago

Occurs on linux when building VSCode from source. Happens on both multi-root workspace and regular workspace. Setting "skipRefreshExplorerOnWindowFocus": true, in settings.json doesn't help.

Version: 1.85.0 Commit: Unknown Date: Unknown Electron: 25.9.6 ElectronBuildId: undefined Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Linux x64 6.6.3-arch1-1

bpasero commented 6 months ago

We have logic to refresh the explorer whenever the window gets focus:

https://github.com/microsoft/vscode/blob/34e1f76c491c37fe33f285ab6508b9ea3d235cec/src/vs/workbench/contrib/files/browser/explorerService.ts#L134-L139

I do not see an option to disable this though.

Is there some reliable steps how to reproduce this? In my basic testing I was not able to. Maybe also play around with explorer related settings that could have an impact 🙏