我正在开发一个扩展,并且可以在调试器中愉快地测试它!但是,在我将扩展打包并手动安装后,当我尝试运行命令时出现错误:
找不到命令的处理程序:'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
在激活函数中添加输出,但我也不知道它在哪里。