Holm76
Holm76

Reputation: 326

How to get a list of all open files?

Writing a VSCode extension.

I'm looking for a way to get all currently open files. vscode.window.activeTextEditor only deals with the file in focus. Not all other open tabs. vscode.window.visibleTextEditors returns editor groups which only again deals with the file in focus. Not all open tabs.

I need it to search for a specific file that my code is making changes to. If the file is open and has been changed (isDirty) then my changes will make conflicts.

What I'd like to do is to be able to check if the file is open and if it is dirty. If dirty I will present a dialog to the user to inform them to save the file before activating the command that edits the file on disc.

Upvotes: 5

Views: 6481

Answers (1)

Holm76
Holm76

Reputation: 326

The anwser is to use vscode.workspace.textDocuments to get all open document.

Upvotes: 2

Related Questions