Я работаю над расширением и могу с радостью протестировать его в отладчике! Однако после того, как я упаковываю расширение и устанавливаю его вручную, я получаю сообщение об ошибке при попытке выполнить команды:
Не найден обработчик для команды: 'sd.edit' (или другой подходящей команды, sd.edit - это та, которую я тестировал для этого)
Вот мой extension.ts
:
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import * as sd from './sd';
import * as fileutil from './fileutil';
import * as indicator from './sdIndicator';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
let sdIndicator = new indicator.SdIndicator();
context.subscriptions.push(sdIndicator);
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
var editCommand = vscode.commands.registerCommand('sd.edit', () => {
let sdWrapper = new sd.SdWrapper();
sdWrapper.Edit(vscode.window.activeTextEditor.document.fileName);
sdIndicator.UpdateStatusBar();
});
context.subscriptions.push(editCommand);
var sdRevert = vscode.commands.registerCommand('sd.revert', () => {
let sdWrapper = new sd.SdWrapper();
sdWrapper.Revert(vscode.window.activeTextEditor.document.fileName);
sdIndicator.UpdateStatusBar();
});
context.subscriptions.push(sdRevert);
}
и package.json
, который определяет команды:
{
"name": "vscode-sd",
"displayName": "sd",
"description": "SD integration with vscode",
"version": "0.0.1",
"publisher": "ryzngard",
"engines": {
"vscode": "^0.10.1"
},
"categories": [
"Other"
],
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"contributes": {
"commands": [
{
"command": "sd.edit",
"title": "SD Edit File"
},
{
"command": "sd.revert",
"title": "SD Revert File"
}]
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
},
"devDependencies": {
"typescript": "^1.6.2",
"vscode": "0.10.x"
}
}
Для меня все выглядело неуместным, и тот факт, что он работает путем отладки расширения, кажется странным. Как можно отладить установленное расширение? Есть ли другие вещи, на которые мне следует обратить внимание?
Я попытался добавить вывод console.log
в функцию активации, но я тоже не знаю, куда это идет.