Visual Studio Code -如何从命令运行' Code '命令?



我尝试开发一个执行这个命令的扩展

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" });

相关内容

  • 没有找到相关文章

最新更新