How to override Visual Studio Code source - visual-studio-code

I want to be able to extend/override some of the VS Code source in my extension, but I'm not sure how to do so. Is this possible?

Extensions (as the name says) can extend the functionality of the host application (here vscode), but they are separate code parts which have no access to the host application code and structures (except those particularly exported for use by extensions).
If you want to modify vscode source code then clone the repo, change the code and build your own vscode application.

Related

custom vscode extension not working over ssh

I created a vscode extension for the first time..I used LSP(language server protocol) and having both client and server bundled as one extension.
The extension has highlighting and autocomplete features for a custom file type. I packaged it using vsce I got a VSIX file. I installed the extension in my vscode using the .vsix file.
The extension works when i am working on local files.
However, i connected to a remote VM using the ms-vscode-remote.remote-ssh extension such that I can view the remote files in vscode, but here my created extension is not working. I can't even see the file type i created.
Any help is appreciated. Is there some specific setting I need to put in my package.json
For your extension to properly work remotely, either installed on host or on the remote, you have to follow a few guidelines, and yes, there are some settings that you may take care of on package.json.
The first and more complete source of information is Supporting Remote Development and GitHub Codespaces API documentation. It describes the architecture, settings, how to debug, common problems and so on. There is also the Extension Host page, where it describes the Preferred extension location topic, which tells you how to configure your extension to work on the correct location.
Based on your description (a LSP related extension) I understand your extension should be a Workspace Extension. This means that you should have this on your package.json:
"extensionKind": [
"workspace"
]
The Commons Problem section describes how you can evaluate and fix Incorrect execution location. To debug using SSH follow these instructions.
Also, remember that while working with remotes, you rely on local paths anymore. Instead you must always deal with Uri, whenever possible.
I guess after reviewing your settings, based on the docs related above, you should be able to detect what is happening on your extension and fix it. Give debug a try, it will be much easier to detect issues than installing the vsix and look for erros in Console.
Hope this helps

Best practice for centralised management of Visual Studio Code extensions

We're trying to maintain a single set of Visual Studio Code extensions within our organisation, managed centrally. In our ideal scenario all end users have the same extensions installed, those extensions are updated on their behalf, and they are not able to install additional extensions.
We had achieved this to date by:
Installing extensions to a directory under C:\Program Files and setting the (undocumented) VSCODE_EXTENSIONS environment variable to point to that location.
Configuring a scheduled task (run as SYSTEM) that executes a powershell script with a list of extension_ids that calls code install-extension <extension_id> on each.
This solution worked until a breaking change in v1.74 expected to be able to write a new extensions.json file to the extensions directory.
Whilst we can get around this by creating a extensions.json file in that directory, I don't want to go too far down the wrong path. Is there a preferred method for centrally managing extensions for Visual Studio Code?

How to run custom tool from VS2022 extension?

I'm developing a Visual Studio 2022 extension with the Visual Studio Community Toolkit. The extension modifies some resx files and I'd like to run the associated custom tool to regenerate the corresponding *.Designer.cs file after a resx file is modified.
In another extension for a previous VS version, I was able to do it like this:
ProjectItem item = _dte.Solution.FindProjectItem(filename);
VSProjectItem vSProjectItem = item?.Object as VSProjectItem;
vSProjectItem?.RunCustomTool();
With _dte being of type EnvDTE._DTE. However now I can't find a way to get that _dte object. All I have is an static VS that provides some basic features as the ones described here: https://learn.microsoft.com/en-us/visualstudio/extensibility/vsix/tips/files?view=vs-2022
However, I can't find there anything related to running a file's custom tool.

Run dependencies in current folder instead of vscode directory

I am looking to build a VSCode Extension around a CLI tool which we have been working on. An example command would be
myCLI retrieve SourceName
This would be run from a specific directory (for example c:/workspace/myproject) which has been setup and contains a settings.json file for some config arguments.
This CLI has been designed that the methods which are called (for example 'retrieve') are exposed directly so the CLI itself is a wrapper also.
When trying to call these methods directly from a VS Code Extension, it is always checking in the C:/Program Files/Microsoft VS Code directory, which I understand is where the Extension is excuting from.
Now, the question: Is there any way for me to force that any time we call the method (for example 'retrieve') that this would look into the current workspace folder (C:/workspace/myProject) , and not the VS Code one (C:/Program Files/Microsoft VS Code)?
Notes which may change answers
CommonJS (not yet ESM)
We currently cannot pass in a full qualified path (for example C:/workspace/myProject), it is only looking for ./settings.json since it depends on where the CLI has bene run from
I want to avoid calling the CLI directly, as I would like to bring many of the CLI features into the VS Code Extension directly to improve user friendliness.

VS Code Quick File Navigation not working for custom file system provider

I've written a custom FileSystemProvider for VS Code.
When I open the files/folder with my custom FileSystemProvider's schema it works as expected and the files are shown in the workspace explorer.
But even though the files/folders are listed in workspace the following options of vs code are not working anymore for the custom file provider
Quick File Navigation (Ctrl + P) is unable to find the files in my workspace provided by custom FileSystemProvider
Find/Replace - Find replace is also unable to find the contents from the files in the workspace provided by custom FileSystemProvider
Find Symbols/ Declaration/ Definition are also not working
Is there a way to register my custom FileSystemProvider's schema also to these tools?
Remark : My custom FileSystemProvider directly uses the files in the local disc and it uses vscode.workspace.fs to read directories and files from the disc. It just hides few files and directories provided from the disc.
This is already known and there is an proposed VS Code API FileSearchProvider available to fix this.
The API is planed to be stabilized in Stabilize FileSearchProvider API #73524