vscode-extensions

VsCode extension - get list of dark/light themes

末鹿安然 提交于 2021-01-29 07:49:18
问题 Is it possible to get list of installed light/dark themes in extension programmatically. I want to make an extension that will switch next color theme on key command. 回答1: You can get all extensions and search for the ones that contribute a theme: vscode.extensions.all.forEach(ext => { console.log(ext.packageJSON.contributes.themes); } 来源: https://stackoverflow.com/questions/54772368/vscode-extension-get-list-of-dark-light-themes

VSCode extension runs from development but does not work when packaged using webpack

荒凉一梦 提交于 2021-01-29 07:35:15
问题 I've built, run, packaged, and published an extension but the packager complains about 2509 files, 4.28MB and suggested using a bundler. I've followed the instructions on Bundling Extension and finally got it to build and run in my development environment using the extensionHost. After publishing this new package (14 files, 303.51KB) I find that while my contributed viewContainer and views are visible, it appears that my activate() function is never called. I've put vscode.window

Change text by Command with VS-Code-Extension

陌路散爱 提交于 2021-01-28 12:30:34
问题 I want to implement a second code formatting. This formatting should be executable by an additional command. I have already registered a DocumentFormattingEditProvider and that is fine. vscode.languages.registerDocumentFormattingEditProvider({ language: 'sosse' }, { provideDocumentFormattingEdits(document: vscode.TextDocument) { return formattingAction(document); }, }); But in my case I need a second formatting action for one-liners, which is executed by an command. I thought about using:

Get focused Explorer folder or file in an extension when command triggered by a shortcut, not by context menu

三世轮回 提交于 2021-01-28 12:11:57
问题 A follow-on to this question: How to get file name or path in vscode extension when user right click on file in explorer/context? My command expects to receive the uri to the item selected with a right-click; and in fact it does if I invoke the command by choosing it from the context menu.... If, however, I bind a shortcut key to this command (and correctly set the "when" context to only activate when explorer has focus) I do not receive the uri; that parameter is undefined . Obviously there

VSCode extension Installation Dependency activation order

懵懂的女人 提交于 2021-01-28 06:47:33
问题 I have a VSCode extension which has an installationDependency in the package.json: "extensionDependencies": [ "publisher.packagename" ] this works well - it runs the activation event for the dependency before the one I have written as you would expect: export async function activate(context: vscode.ExtensionContext) {... however - I would like my extension to first reset an environment variable before the dependency activates. Is it possible to determine (in my case reverse) the order of

Scoping of keys in vscode extension global scope

给你一囗甜甜゛ 提交于 2021-01-28 05:33:25
问题 The context of a vscode extension provides access to globalState which is a Memento object with key/value pairs. My question is: does each extension get its own memento object, or is there one shared by all extensions? Just wondering whether I need to make my keys more specific (e.g., my.extension.foo ), or if I can keep the keys simple (e.g., foo ). 回答1: It's scoped to your extension, so you can keep them simple: However, when an extension uses storage, it will always get it's data stored

VSCode: Tests won't proceed after using executeCommand to open a sample project

蹲街弑〆低调 提交于 2021-01-28 05:26:56
问题 I'm trying to add some unit tests to a Visual Studio Code extension I'm developing. I've followed the recipe for setting up extension testing described here: https://code.visualstudio.com/api/working-with-extensions/testing-extension This recipe, however, doesn't show anything useful being done to actually test an extension, just the skeleton for getting set up to do so. For the testing I want to do, one of the first things I want to do is open a sample project . And that's where I get stuck.

How do I create a file for a Visual Studio Code Extension?

泪湿孤枕 提交于 2021-01-28 02:50:48
问题 I'm trying to create a file as a part of one of the commands in my extension and can't seem to get it right. let wsedit = new vscode.WorkspaceEdit(); const file_path = vscode.Uri.file(value + '/' + value + '.md'); vscode.window.showInformationMessage(file_path.toString()); wsedit.createFile(file_path, {ignoreIfExists: true}); vscode.workspace.applyEdit(wsedit); vscode.window.showInformationMessage('Created a new file: ' value + '/' + value + '.md); value is a string input from the user. The

VSCode Extenstion how to get Position of last character of line

删除回忆录丶 提交于 2021-01-28 02:19:22
问题 I am developing a VSCode plugin, and now want to get the position of the last character of a line. Now I want to get it through a known Position object, using "with" method. The official reference is here: https://code.visualstudio.com/api/references/vscode-api#Position You see "with" method has 2 overloads. Now I want to use the "with(change: {line: number, character:number})" method: const endPos = startPos.with({ line: 1, character: -1 }); startPos is a "Position" object. But this code is

Multiple formatters in Visual Studio Code

末鹿安然 提交于 2021-01-27 22:15:08
问题 In my team, some people are using VS Code and others WebStorm. To align code format, I've written an extension for VS Code that adds some missing rules. My plan was to run my extension along with the native formatters that ship with VS Code. I provide my edits using the API: vscode.languages.registerDocumentFormattingEditProvider('typescript', { provideDocumentFormattingEdits(document: vscode.TextDocument) { const textEdit: vscode.TextEdit[]; return textEdit; } } But it seems I can't run this