Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
279 views
Welcome To Ask or Share your Answers For Others

1 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...