'How to detect VSCode panel visibility from the extension code?
I would like to create an extension to toggle all the currently visible panels by a single shortcut. So something like the command "Hide/show All Tool Windows" from JetBrains IDEs, which I think is still missing in VS Code.
VS Code can have up to 3 panels visible:
- Sidebar (the left-side panel)
- Panel (the bottom panel)
- AuxiliaryBar (the new right-side panel)
For that purpose, I need to detect the current state of all the panels from the extension code, so I can toggle only the panel(s) which are currently visible.
But alas I can't find it anywhere in the documentation. This page (https://code.visualstudio.com/api/references/when-clause-contexts) contains several variables like sideBarVisible, but I really don't get how to access those context variables from the vscode namespace which you can access from the extension.
import * as vscode from 'vscode';
So, is there a way how to detect if the panel is open or closed from the extension code?
Solution 1:[1]
Do you really need to know whether they are open or closed? Can't you just toggle them all?
vscode.commands.executeCommand('workbench.action.toggleSidebarVisibility')
vscode.commands.executeCommand('workbench.action.togglePanel')
vscode.commands.executeCommand('workbench.action.toggleAuxiliaryBar')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | md2perpe |
