1

Im working on a VSCode extension to get all paths to the files that are open in the editor.

Lets say I have these tabs open. One focused and another is not:

open tabs

Is there a way to get the file paths to each file? A array of path strings for example. I found a answer that gave me the path to files that are opened and "focused": var currentlyOpenTabfilePath = vscode.window.activeTextEditor?.document.uri.fsPath; But how do I get the other paths?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Kulio
  • 145
  • 1
  • 10
  • I answered that here: https://stackoverflow.com/questions/64611182/when-opening-multiple-files-in-vscode-only-the-first-is-actually-loaded-in-memo – boocs Jan 06 '21 at 19:31

1 Answers1

1

The workspace has all the required info:

    for (const document of workspace.textDocuments) {
            const theName = document.fileName;
...
        }
    }

Note: this works only for text documents. Others like webviews are not enumerated here (and they usually are not associated with an own file).

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • Also, it may be an issue or not, but documents can be opened (for editing, for example) but not shown - so not in a tab. `workspace.textDocuments` will report opened documents, not shown documents. Again, for the situation this may or may not be an issue, but one should be aware of this difference. – Mark Jan 10 '21 at 01:30