简体   繁体   中英

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?

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM