You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
workspace.textDocuments includes closed documents #47140
In #10304 I was advised that workspace.textDocuments was the correct way to get open files; however I'm trying to write tests that rely on documents being closed and finding that they still exist in there despite being closed (I can see in the extension host there there are no open editors).
Here's a sample test:
it.only("test",async()=>{// Open two filesawaitvs.workspace.openTextDocument(emptyFile);awaitvs.workspace.openTextDocument(everythingFile);console.log(`There are ${vs.workspace.textDocuments.length} documents`);// Close all fileswhile(vs.window.activeTextEditor){awaitvs.commands.executeCommand("workbench.action.closeActiveEditor");}console.log(`There are ${vs.workspace.textDocuments.length} documents`);// Wait a short period just in case...awaitnewPromise((resolve)=>setTimeout(resolve,1000));console.log(`There are ${vs.workspace.textDocuments.length} documents`);});
This outputs:
There are 2 documents
There are 2 documents
There are 2 documents
Please ask your question on StackOverflow. We have a great community over there. They have already answered thousands of questions and are happy to answer yours as well. See also our issue reporting guidelines.
Johannes Rieken (@jrieken) Then the answer to my original question is not satisfied :( How do I get a list of the documents that are open? I want to provide my language server with a list of priority documents, which are first the visible text editors, and then any editors that are open but not visible.
Activity
DanTup commentedon Apr 3, 2018
Also weird, the
whileloop seems to only execute once.Improve tests
Improve tests
jrieken commentedon Apr 3, 2018
You cannot assume the opposite and closing an editor doesn't mean that we close the document too.
vscodebot commentedon Apr 3, 2018
Please ask your question on StackOverflow. We have a great community over there. They have already answered thousands of questions and are happy to answer yours as well. See also our issue reporting guidelines.
Happy Coding!
DanTup commentedon Apr 3, 2018
Johannes Rieken (@jrieken) Then the answer to my original question is not satisfied :( How do I get a list of the documents that are open? I want to provide my language server with a list of priority documents, which are first the visible text editors, and then any editors that are open but not visible.
Improve tests
Improve tests
Improve tests
Improve tests
Improve tests