vscode-extension-samples | Sample code illustrating the VS Code extension API
kandi X-RAY | vscode-extension-samples Summary
kandi X-RAY | vscode-extension-samples Summary
Sample code illustrating the VS Code extension API.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of vscode-extension-samples
vscode-extension-samples Key Features
vscode-extension-samples Examples and Code Snippets
Community Discussions
Trending Discussions on vscode-extension-samples
QUESTION
I have troubles adding icons to a TreeItem
in my VSCode extension. When I load the extension, the item has a blank space where the icon ought to be.
I have tried to mimic the nodeDependency
example. I have the following in extension.ts
:
ANSWER
Answered 2021-Jun-03 at 11:18Webpack changes __filename
, so your attempt to go to the resource directory fails.
Add the following to webpack.config.js
to leave __filename
unchanged:
QUESTION
I am new to VSC extension development.
I started with the extension hello world and I want to add an icon to the activity bar and get a notification when it is clicked.
I add these lines to package.json
...ANSWER
Answered 2021-May-09 at 20:45You must also specify a "views"
item that matches the id
of your viewContainer
Try adding the following right after the "viewsContainers"
object in the "contributes"
section of package.json
QUESTION
I am trying to develop a VSCode extension which requires the current open file and same file from previous git revision/commit. Which is same as clicking the open changes button in vs code.
I Tried using SCM and QuickDiffProvider as shown in this sample-extension, but its giving "unable to resolve resource" when trying to open the old file in vscode.
snippet from extension.ts
...ANSWER
Answered 2021-Apr-28 at 11:52After struggling so much to find alternative solution to get the diff of file, I found that we can use vscode.editors
, to access all the open editors.
Example: In git diff we will have 2 editors (left: old and right: new), so we can use the following code to access old and new content.
QUESTION
I'm building a Tree View VSCode extension and would like to highlight a portion of my tree item's labels in certain situations. It seems like a TreeItemLabel supports this functionality via the highlights
property.
The API docs specify that one of the constructor signatures for TreeItem
accepts a TreeItemLabel
as the first argument. The docs for TreeItemLabel only show two properties for this object (hightlights?
and label
) without any constructor. I'm fairly new to the JS/TS world, and am not sure of how to "pass in" a TreeItemLabel
to the constructor of a TreeItem
.
I can't seem to import TreeItemLabel
from anywhere in the vscode
namespace, which eliminates the possibility of using a constructor.
I found a sample test that seems to manually construct a TreeItem
with a highlights
property by explicitly defining an object with those properties, but I'm not sure how to translate this to my use case.
In my case, I have a class that extends TreeItem
and passes some values to super()
to make the TreeItem:
ANSWER
Answered 2021-Apr-20 at 20:26Just define an object with the properties you need. You might need to change the numbers based on the name
string.
QUESTION
as you see above, the building process never finishes and no extension host window appears.
the problem also exists when all extensions all disabled
but this problem doesn't exist when creating project with javascript (the problem is only with typescript)
the steps that I follow is from this tutorial and I also tried the hello world sample from github. but none of them worked.
EDIT:
I tried to open extension development host window manually by code --extensionDevelopmentPath="path/to/my/project"
and it worked.
- I think the issue is with some of vscode's configurations
possible fix: I should check the configurations such as npm: watch
. but I don't know where are they and what should I do with them??
so any idea?
EDIT 2:
task.json
ANSWER
Answered 2021-Apr-18 at 10:27Finally I caught the issue. that was because of the locale of my system that was set to Persian
which typescript problem matcher couldn't recognize(Persian digits).
By setting system locale to English the problem solved and everything now works fine as expected.
QUESTION
I'm coding a vscode extension following the guide and I came accross an import problem in my server.ts file. Here is the file tree:
...ANSWER
Answered 2021-Mar-03 at 11:41The vscode
package has been deprecated. It has now been split up into two packages which are @types/vscode
and vscode-test
. The reason for this refactoring can be found here.
You have included the @types/vscode
dependency but not vscode-test
.
Adding the vscode-test
dependency should fix your issue i.e.
QUESTION
I am getting some odd behavior when updating gutter icons in VSCode using TextEditor.setDecorations() https://code.visualstudio.com/api/references/vscode-api#TextEditor.
On activate of my VSCode extension the class below is instantiated and it's constructor called which "one-time" creates 3 TextEditorDecorationType's https://code.visualstudio.com/api/references/vscode-api#TextEditorDecorationType, one for each state that a test result can be in represented by a NONE, PASS, FAIL icon and finally triggerUpdateDecorations()
is called to collect the current globalResults
within 3 arrays and set the gutter icons with vscode.window.activeTextEditor.setDecorations()
So far everything works as expected. No tests have been run and every test shown in the editor is updated with a NONE gutter icon.
Now as each test is run in the editor, on completion, triggerUpdateDecorations()
is called once again to collect results and update the gutter icons.
If there are for example 10 tests in the editor, each with a NONE gutter icon, if I run a single test that test correctly updates with either a PASS or FAIL gutter icon. This behavior repeats itself for all subsequent tests run, except for the last one. The last test run remains set with its NONE gutter icon. It's not tied to a specific test as I can jump around and the behavior follows the last test run.
I've tried adding a dummy NONE icon to a random place in the gutter not tied to a test and that allows all gutter icons tied to a test to be updated with PASS or FAIL gutter icons.
I've been experimenting a lot to try and solve this and can't seem to find the root cause. Greatly appreciate any insights on how to solve this.
Note some of this code stems from the VSCode Samples shown here https://github.com/microsoft/vscode-extension-samples/blob/main/decorator-sample/src/extension.ts#L58
...ANSWER
Answered 2021-Feb-24 at 22:35You never clear a Decorator type, remove the if (rangePass.length > 0)
parts
QUESTION
I have these lines in the settings.json:
...ANSWER
Answered 2021-Feb-19 at 06:31Finally, using both textmate and the semantic customization, and writing the two rules "separately" seems to work(The textmate method is the older (original) tokenization method of the visual studio code, while the semantic one was added recently):
QUESTION
I've created a vscode extension which handle some Rakefile
tasks.
Now I want to limit that the extension will be displayed in the explorer only when user
open a Rakefile
for that I use the following entry in the package.json
...ANSWER
Answered 2020-Nov-18 at 11:18You need to use the context, when the editor changes set a context variable to signal the current file is a Rakefile
In your activate
function
QUESTION
We have a (internal) VS Code extension implementing the Language Server Protocol for a language. I've checked out the VS Code LS sample to enable debugging on the server, however in the sample, the ServerOptions
used to initialize the LanguageClient
is always a type:
ANSWER
Answered 2020-Nov-18 at 02:40The mechanism I found is to add "--inspect" as the first argument to args
in child_process.spawn(...)
, so args
now has the value:
["--inspect", "path/to/server/main.js", "path/to/log/output"]
This launches the debug listener on the default node port (9229) on 127.0.0.1
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install vscode-extension-samples
Hello World Minimal Sample: A minimal version of Hello World Sample written in JavaScript.
Hello World Test Sample: Hello World sample with extension integration test. See Testing Extensions documentation.
Hello World Web Sample: The Hello World sample for VS Code Web. See the Web Extensions guide.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page