7

命名空间中是否有vscode允许您获取TextDocument当前打开文件的实例的命令?我找到vscode.workspace.onDidOpenTextDocument了,但它不适用于启动时打开的文件

4

1 回答 1

10

几个选项取决于您的需求:

// Single active editor. Editors have a `.document` property
vscode.window.activeTextEditor

// All showing text editors. For a split view, there are two active editors 
vscode.window.visibleTextEditors

// All open documents that vscode knows about. Do not have to be showing
vscode.workspace.textDocuments

有关详细信息,请参阅 vscode API:https ://code.visualstudio.com/docs/extensionAPI/vscode-api

于 2017-07-07T08:35:02.327 回答