【问题标题】:How to find the name the folder of the current activeTextEditor in VSCode?如何在VSCode中找到当前activeTextEditor的文件夹名称?
【发布时间】:2021-03-25 09:01:43
【问题描述】:

这将找到当前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(文件)的文件夹

【问题讨论】:

标签: javascript visual-studio-code vscode-extensions


【解决方案1】:
const path = require('path');

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

【讨论】:

    猜你喜欢
    • 2012-05-23
    • 2011-07-01
    • 2019-04-15
    • 2019-12-04
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多