Enable the menu item of my Visual studio extension only when code window is open

vscode extension settings
visual studio code formatting settings
visual studio code settings
visual studio extension development
visual studio code tutorial
how to run code in visual studio code
visual studio code restore default settings
vscode workspace

I'd like to enable my extension menu item only when code editor is open.

I try to detect when Code window is opening with the following code without successful result...

private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        OleMenuCommand menuCommand = sender as OleMenuCommand;
        if (null != menuCommand)
            IVsMonitorSelection monitorSelection =  this.ServiceProvider.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
            int pfActive;

            Guid codeWindowGuid = VSConstants.UICONTEXT_CodeWindow;
            uint solutionExistCookie;
            monitorSelection.GetCmdUIContextCookie(ref codeWindowGuid, out solutionExistCookie);
            monitorSelection.IsCmdUIContextActive(solutionExistCookie, out pfActive);

            menuCommand.Enabled = (pfActive == 1);

Although IsCmdUIContextActive is returing S_OK, I'm always receiving pfActive as false even if code window is really opened..

What am I doing wrong ?

Maybe you forgot to add out keyword in your IsCmdUIContextActive method signature in the place where it is defined?

It is included as an optional feature in Visual Studio setup. In the experimental instance, open the Extensions > Manage Extensions window. with different versions of your extension code, your experimental environment shown you only a small part of what you can do with a Visual Studio extension. In the Solution Explorer, right-click the project node and select Add > New Item. In the Add New Item dialog, go to Visual C# > Extensibility and select Custom Command. In the Name field at the bottom of the window, change the command file name to FirstCommand.cs. Build the project and start debugging.

Component Diagnostics extension can show you all currently active contexts so that you choose the needed one:

Open files in each editor are displayed with tabbed headers (Tabs) at the top of the "editor.minimap.side": "left" or "editor.minimap.enabled": false in your user or Hovering over the filter box and selecting Enable Filter on Type will show only You can hide the Menu Bar on Windows and Linux with the View > Toggle​  When the project opens, add a tool window item template named MyWindow. In the Solution Explorer, right-click the project node and select Add > New Item. In the Add New Item dialog, go to Visual C# > Extensibility and select Custom Tool Window. In the Name field at the bottom of the window, change the tool window file name to MyWindow.cs. Build the project and start debugging. The experimental instance of Visual Studio appears.

Checking DTE.ActiveWindow.Document is not null is probably the easiest way to check for an active editor.

To open your user and workspace settings, use the following VS Code menu command: Windows %APPDATA%\Code\User\settings.json; macOS colorDecorators": true, // Enable that the selection with the mouse and keys is default: `cursorSurroundingLines` is enforced only when triggered via the keyboard or API. The previous blog post introduced the wonderful world of Visual Studio extensions. Let’s start and do some coding. During the tutorial we are going to build a VS extensions called CodyDocs and place it on GitHub. CodyDocs will save code documentation in a separate file and the extension will allow to view and edit the documentation in the […]

VS Code extensions let you add languages, debuggers, and tools to your You can click on the extension item to display the extension's details page where you it with the Enable or Enable (Workspace) commands in the drop-down menu. Many extensions are open source and have a link to their repository on their  Extensions are code packages that run inside Visual Studio and provide new or improved features. Extensions may be controls, samples, templates, tools, or other components that add functionality to Visual Studio, for example, Live Share or Visual Studio IntelliCode. For information about creating Visual Studio extensions, see Visual Studio SDK.

To extend Visual Studio Code, your extension (plug-in) declares which of the Other types, such as object and array , aren't exposed directly in the settings UI, and can only be or folder, while the ignored repositories list with window scope applies more Contribute a menu item for a command to the editor or Explorer. I’m all about using Visual Studio Code for Node.js development. It is a lightweight code editor and runs on Windows, Mac OS X, and Linux. I enjoy it so much that I also use it for Node.js projects on the Raspberry Pi. To accomplish this, I create a Windows file share on the RasPi as described in my Beginner’s Guide to Installing Node.js on the Raspberry Pi and map a drive on my Windows

Common capabilities that Visual Studio Code extensions (plug-ins) can take advantage of. Common Capabilities are important building blocks for your extensions. You open the Command Palette to execute commands, bind custom An extension can register custom Context Menu items that will be displayed in  Install from a VSIX#. You can manually install a VS Code extension packaged in a .vsix file. Using the Install from VSIX command in the Extensions view command drop-down, or the Extensions: Install from VSIX command in the Command Palette, point to the .vsix file.

  • Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue?
  • Not yet! I think the problem may be in the way of loading the package rather than the visibility fields. I'm investigating!
  • No, it it works. It seems GetCmdUIContextCookie only works with some GUIDs and UICONTEXT_CodeWindow is not in the list... I'm looking for alternatives...
  • Specifying out at a call site when the matching parameter in the method signature is not marked as out should generate a compiler error, not odd runtime behaviour.