sketchbuch / vsc-workspace-sidebar

An extension for VSCode to switch Workspaces with ease.
https://marketplace.visualstudio.com/items?itemName=sketchbuch.vsc-workspace-sidebar
MIT License
35 stars 3 forks source link

New feature: auto-close the sidebar on workspace switch #58

Closed jtanguy closed 1 week ago

jtanguy commented 2 years ago

I have a small feature request, and I'd like to run it by you first before attempting to code it.

Could it be possible to add a config option to auto-close the sidebar after a workspace change ? Closing the sidebar is often the first action I do after switching workspaces.

This would happen in the current window if the workspace is opened in the current window, or both windows if the workspace is opened on a new window.

sketchbuch commented 2 years ago

How do you mean close the sidebar? You mean the workspace sidebar? This already happens as the explorer view is selected automatically. Or do you mean the whole activity panel sidebar (everything on the left)? There is a command for this (Toogle Primary Side Bar) - same as used by the icon in the top right of the window

Bildschirmfoto 2022-06-23 um 15 46 28

Yeah, this should be an option (off by default), as I do not know how many people need this functionality. .

sketchbuch commented 2 years ago

"Toogle Primary Side Bar" affects only the current window. I'm not sure without looking at the API if you can close all sidebars in all windows, but there is a way to get all windows so maybe they could be iterated over.

sketchbuch commented 2 years ago

Feel free to fork and make a pr as I don't have time for this at the moment. If you need any help let me know.

jtanguy commented 2 years ago

Thanks for the insight. I was not sure about how to do it; it's my first time working on a vscode plugin. I'll try to do it myself

sketchbuch commented 2 years ago

In the command that happens when you click the icon or the item you can execute another command

src/webviews/Workspace/WorkspaceViewProvider.ts (line 195)

Here is where I would do it... get the config value and if true, close the sidebar

sketchbuch commented 2 years ago

I was going to look into removing the commands from src/commands/registerCommands.ts - the switch in the WorkspaceViewProvider is just a call to my commands that execute the relevant inbuilt commands. These are left overs from the treeview class that I used to use before switching to a webview. I do not think they are needed still, so please do not add the calls to close the sidebar here. Do it in the WorkspaceViewProvider