如何在VSCode中找到当前activeTextEditor的文件夹名称?

How to find the name the folder of the current activeTextEditor in VSCode?

这将找到当前 activeTextEditor 的当前 workspace 文件夹:

const editor = vscode.window.activeTextEditor
if (!editor) {
  vscode.window.showInformationMessage('editor does not exist')
  return
}

const path = editor.document.uri.fsPath
const workspaceFolder = vscode.workspace.getWorkspaceFolder(editor.document.uri)

如何找到当前activeTextEditor(文件)的文件夹

const path = require('path');

let dirname = path.dirname(editor.document.uri.fsPath);