我尝试开发一个执行这个命令的扩展
code $(git diff --no-commit-id --name-only -r HEAD) -r
如果用户调用命令foo
。
这是我的扩展。:
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('git-open-modified-files.foo', () => {
// How can I call my `code $(git diff --no-commit-id --name-only -r HEAD) -r` command here?
vscode.commands.executeCommand('code $(git diff --no-commit-id --name-only -r HEAD) -r'); // does not work
});
context.subscriptions.push(disposable);
}
export function deactivate() {}
vscode.commands.executeCommand
是调用一个VSC命令,你需要一个shell/terminal命令
使用/试
vscode.commands.executeCommand('workbench.action.terminal.sendSequence', { "text": "code $(git diff --no-commit-id --name-only -r HEAD) -ru000D" });