vscode-extensions

Why is JS/CSS not loaded in my VSC extension webview

半城伤御伤魂 提交于 2020-05-17 06:21:31
问题 I'm writing a vsc extenion that uses a webview. The extension itself works fine but the JS and CSS in my webview are not being loaded. I keep getting errors in the webview console like: VM102 main.js:12 Refused to load the stylesheet 'vscode-resource://file///full/disc/path/to/vsc-extension/resources/css/webview-package.css' because it violates the following Content Security Policy directive: "style-src nonce-LSAOCrvSSPay9prF40mc5JyRJ9BzFUKR". Note that 'style-src-elem' was not explicitly set

Do we have any sample ui integration tests for vscode extensions

人盡茶涼 提交于 2020-05-15 08:27:05
问题 I am trying to write e2e integration tests for a vscode extension. I didn't find any ui integration tests. Can you please provide me the links if any 回答1: I recommend using extensions/vscode-api-tests/src/singlefolder-tests/editor.test.ts in the vscode sources as a starting point for integration tests. If that particular test isn't quite what you want, there are a bunch of tests adjacent to it that might be. See also this answer I gave to a related question about using the API from within

How to extend VSCode code completion with a third-party JavaScript library

旧巷老猫 提交于 2020-05-13 14:31:06
问题 In my projects I use a third-party JavaScript library. I cannot import it explicitly in my code, this library is provided by JavaScript engine at runtime. I want to make coding easier by extending VSCode Intellisense by this library on all my project. I have a JavaScript file with function signatures of this library. What are the ways to do this? I already tried: write /// <reference path=''> to file in project. It works but it’s not very convenient to write it in all files. use jsconfig.json

Opening VS Code settings window from extension with specific search query

守給你的承諾、 提交于 2020-05-09 05:22:05
问题 I am writing a VS Code extension where I want to open the settings window programmatically from my extension. I want the window to already have the search filled out to only show the settings my extension provides, and also a way to select workspace settings vs user settings when opening the window. I know how to run vscode commands from my extension, but I cannot figure out which commands open that window. 回答1: You can now pass an argument to the search, e.g. vscode.commands.executeCommand(

Activate command on TreeViewItem click, VSCode Extension

不羁岁月 提交于 2020-03-21 19:26:16
问题 I would like to run a command on the click of a tree view item, rather than in a menu that comes up. Right now in my package.json, I have this: { "command": "test.view.showError", "when": "view == test.view && viewItem == test", "group": "inline" } Right now, "inline" will put an icon next to the words which you have to click to run the command, but I would like the command to run when I click on the node itself. What do I change "group" to? Or do I do something different entirely? Thanks 回答1

VSCode: activeTextEditor encoding

空扰寡人 提交于 2020-03-02 04:22:05
问题 Is there any way to get current document encoding (that is in the bottom bar) in my extension code? Something like vscode.window.activeTextEditor.encoding 回答1: This does not appear to be possible. Since it's nearly impossible to prove a negative, the rest of this answer documents what I explored. The string "encoding" does not appear (in this sense) anywhere in the API docs nor in the index.d.ts file it is derived from. (With VSCode 1.37.1, current as of writing.) I dug into the vscode

Simple Example to implement VS Code TreeDataProvider with JSON data

纵饮孤独 提交于 2020-02-13 04:06:10
问题 I'm trying to add a Tree View to my VS Code extension. Data is a complex JSON object. I stuggle to get this to working as the examples aren't straight forward to me. Lets say I have a simple object: "cars": [ { "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] }, { "name":"BMW", "models":[ "320", "X3", "X5" ] } ] I would like to render this in the treeview as follows: Cars > Ford > Fiesta > Focus > Mustang > BMW > 320 > X3 > X5 Any pointers how to achieve this, or know of an repo I can

Simple Example to implement VS Code TreeDataProvider with JSON data

怎甘沉沦 提交于 2020-02-13 04:03:03
问题 I'm trying to add a Tree View to my VS Code extension. Data is a complex JSON object. I stuggle to get this to working as the examples aren't straight forward to me. Lets say I have a simple object: "cars": [ { "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] }, { "name":"BMW", "models":[ "320", "X3", "X5" ] } ] I would like to render this in the treeview as follows: Cars > Ford > Fiesta > Focus > Mustang > BMW > 320 > X3 > X5 Any pointers how to achieve this, or know of an repo I can

how to use vscode CompletionItemProvider by keybinding

邮差的信 提交于 2020-02-07 02:00:12
问题 I tried to write an extension to vscode to help me import lib by keyboard shortcuts I've tried many things, but two questions remain unanswered 1.How to use CompletionItemProvider by shortcut key Normally, CompletionItemProvider is triggered by a character,But I want to be able to use the shortcut to bind commands.Ideally, I could press the shortcut to display the CompletionItems directly.But the only thing I know so far is through vscode.com command.excute('trugger suggest'), which can be

how to use vscode CompletionItemProvider by keybinding

一世执手 提交于 2020-02-07 01:59:07
问题 I tried to write an extension to vscode to help me import lib by keyboard shortcuts I've tried many things, but two questions remain unanswered 1.How to use CompletionItemProvider by shortcut key Normally, CompletionItemProvider is triggered by a character,But I want to be able to use the shortcut to bind commands.Ideally, I could press the shortcut to display the CompletionItems directly.But the only thing I know so far is through vscode.com command.excute('trugger suggest'), which can be