代码如下:
export function activate(context:any) {
// 注册一个命令
let disposable = vscode.commands.registerCommand('codeStat.countCurFile', function () {
let editor = vscode.window.activeTextEditor;
if (editor) {
const currentDocumentUri = editor.document.uri;
const selectedWorkspaceFolder = vscode.workspace.getWorkspaceFolder(currentDocumentUri);
if (selectedWorkspaceFolder) {
vscode.window.showInformationMessage(selectedWorkspaceFolder.uri.fsPath);
}
}
});
context.subscriptions.push(disposable); // 插件退出时释放资源
}
标签:selectedWorkspaceFolder,插件,打开文档,vscode,editor,根目录
From: https://www.cnblogs.com/huzhongqiang/p/17456499.html