How to detect VSCode panel visibility from the extension code? - visual-studio-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')

Related

Is it possible to go back one level of breadcrumbs using hotkey in VS Code?

VSCode has breadcrumbs feature that looks like this:
Is it possible to go back one level in these breadcrumbs using a hotkey? So in the case above, I am inside propTypes. I press hotkey and I go to BatchTypesTable.
I can achieve this already by clicking on the breadcrumb itself but I want to have a hotkey to do this.
On MacOS, my keyboard workflow is:
open breadcrmb with shiftcommand.
then navigate the top level with option← and option→
use plain arrows to navigate inside the drop-down list
So, I guess on windows top-level navigation would be alt←?
Relevant VSC documentation here. Although it seems to be incomplete and partially incorrect?

How to show frequently used commands in toolbars under the menu bar in VScode

How to show frequently used commands in toolbars under the menu bar in VScode?
In Visual Studio, frequently used commands are placed in some toolbars. We can click them easily with a mouse, not using keyboard shortcuts.
Is there a way to set up toolbars in VScode like Visual Studio?
No, this is currently not possible (VSCode doesn't have one built-in, and the extension API is rather limited when it comes to customizing UI). There was a feature request for this, but it was considered "out of scope":
Support a real toolbar below the window title with actions (#18042)
Note that the extension API does allow you to customize the buttons shown in the upper right of editors, so that could be a workaround in the meantime:
The contribution point is the editor/title mentioned here. This is how the built-in markdown extension adds the additional Open preview to the Side button for .md files:
The third-party Markdown Shortcuts extension takes this even further, adding controls for editing such as Toggle bold, Toggle italic etc:
I made the extension just for this purpose.. you can add buttons like beautify, list files, undo, redo, save all etc to the editor menu bar in the VSCode. checkout
Shortcut Menu Bar

Visual Studio Code: How to have both Debug window and Explorer window open together?

I'm new to Visual Code and I have a small question.
You have two buttons circled in red line. The first button opens the Explorer window and the second circled button opens the Debug window.
I want to have both of these windows open. Do you know how to do it?
This is not possible as of VSCode 1.13
A feature request for showing multiple panels was tracked here but the issue has been closed as as-designed. If you are passionate about the problem, please file a new issue to see if thinking on this has changed in the past year
V1.43 will have the ability to move various views, like Variables, Watch and Callstack from the sidebar to the panel (it works nicely in the Insiders' Build v.1.43). Demo:
See v1.43 release notes: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#easier-moving-of-even-more-views with a demo gif of dragging views to and from the panel.
and this setting:
We've introduced a new command to make moving views easier
with the keyboard: View: Move Focused View
(workbench.action.moveFocusedView).
And finally, this is a preview feature. So, in case you get into a
state that you can't fix, there is a command to reset all views to
their original locations: View: Reset View Locations
(workbench.action.resetViewLocations).

Eclipse Back/Forward navigation using mouse buttons

There is an addin for Visual Studio called MouseNavi that allows you to use mouse thumb buttons to navigate your history.
Does a similar extension exist for Eclipse?
I don't know of any Eclipse plugin that does this, but assuming you're using Windows:
This one should enable you to do what you want: http://www.highrez.co.uk/downloads/XMouseButtonControl.htm
With that tool you can assign each mouse button a sequence of keys (Alt+Left for example) and because it can be made application specific it won't interfere with other programs where you don't want that mapping.
Alt+Left and Alt+Right to navigate through the latest opened editors.
Also, Alt+L to open up the shortcuts popup, so you can see what's available.
No real mouse navigation control though (not that I know of... at least). Although, should not be very difficult to create one and attach it to the same handlers that deal with the navigation commands.
^Q takes you to last edited location. You can cycle using it. No mouse bindings.

How to Display Current Function in Eclipse

I miss a certain functionality in Eclipse. I would like to know the name of the current function the cursor is currently inside. This is useful when browsing unknown code using the search function, for example.
Any idea how to show it? Maybe a plugin?
I'm using the "Toggle Breadcrumb" option from toolbar:
It shows a nice breadcrumb, ending with current function name.
It's quite handy for me, as Outline becomes cumbersome to use if you have zilions of functions.
It produces the following structure above your Java Editor (truncated at the picture below):
The "Outline" view shows the current function.
It may be necessary to enable the 'Link to Editor' option in the Outline View dropdown menu. This might be off by default for CDT.
I was looking for something similar (Xcode-like bar at the top showing the current function, where you can also go to another function by clicking on it to open a popup list of functions). Here is what I settled on with Eclipse 3.5.1 CDT:
I moved the Outline view to the top, resized it to make it a 1-line horizontal strip (don't make it too narrow), and selected "Link With Editor" in its menu, so that it always shows the current function. However, this doesn't open a popup list like Xcode. For that functionality, I assigned a shortcut to the "Show Outline" command which does open a popup list of all functions.
The Eclipse function 'show outline' will pop up a list of outline objects, and it will highlight the object your cursor is inside in grey. It's typically bound to 'ctrl-o' (the letter 'o', not zero), but you can re-bind it as you see fit. I'm running Eclipse with the CDT plugin and it works pretty well for me.
To enable the breadcrumb invoke Toggle Java Editor Breadcrumb in the toolbar or press Alt+Shift+B in the Java editor.
You can also display the Quick Outline (ctrl+o). This way you see the context quickly without having to have a permanent Outline Window linked to the Editor.
Use the "Link With Editor" option on the outline menu
Press Ctrl+o (cursor is currently inside a function at a particular line).
It highlights the current method, or name of the class if the cursor is outside the method body.
You can click on highlighted method.
It has got inline search feature ...start typing name of the method to navigate to the specified method or method with matching search pattern.
If you press again Ctrl+o to shows the inherited members/methods.
Using outline with "link with editor" option worked also for me, thanks!
Just an addition, you can move outline pane in to the same window group as search, progress etc. saves the space in your perspective instead of keeping it at another group.