Missing onDidOpenTextDocument/onDidCloseTextDocument events for documents opened with openTextDocument #138924
Labels
*question
Issue represents a question, should be posted to StackOverflow (VS Code)
Issue Type: Bug
During extension development I noticed that
opening files with
openTextDocument
didn't always fire the
didOpenTextDocument
events I was expecting.This test suite is there to explore and reproduce the problem.
Reproduction
In the reproduction repo:
npm ci
npm test
Expected results
All tests in the suite succeed.
Actual results
The test for events fired by
openTextDocument
followed by
showTextDocument
for an existing file fails.
It seems like closing the editor with the text document
doesn't actually close the document
(and doesn't fire
onDidCloseTextDocument
),so subsequent attempts to open the document
don't fire
onDidOpenTextDocument
.The same sequence of events works for nonexistent files
(with the
untitled
uri scheme),as does opening the file with the
vscode.open
command.Other commands for closing editors (like
workbench.action.closeAllEditors
)don't improve the situation,
and the API doesn't seem to provide any other method to close documents.
For more details, see the test suite in
src/test/suite/extension.test.ts
.VS Code version: Code 1.63.0 (7db1a2b, 2021-12-07T05:16:45.441Z)
OS version: Linux x64 5.15.6-200.fc35.x86_64
Restricted Mode: No
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Extensions (38)
(6 theme extensions excluded)
The text was updated successfully, but these errors were encountered: