Large files getting emptied if you quit + save too fast (before Prettier runs)
See original GitHub issueHere’s a gif with the visual keyboard open so that you can see which keys I’m pressing (slowed down)…
Full speed GIF
Reproduction steps:
- Add a lot of whitespace in a large file (seems to work best with JSX but it’s also happening in files without any JSX)
- Press CMD + S and then CMD + W. This will show the “do you want to save your file before quitting” prompt (since Prettier is still running after having pressed CMD + S). Press enter to save the file.
- Re-open the file, it should not have been formatted.
- Press CMD + S and then CMD + W again. This won’t show the prompt but the next time you open the file, it will be empty.
Obviously, it’s not only an issue when you add “a lot of whitespace”. It happens to me quite a lot but this is the only way I managed to reproduce it.
Notice how the second time I re-open the file, it hasn‘t been formatted by Prettier after I quit it (even though I pressed Enter to save the file and formatOnSave
is activated).
This wasn’t an issue before so I assume there was a Prettier update (or on your side?) that would cause those problems… I haven’t changed my VS Code config or installed extensions in a while.
I would really appreciate if someone could try and reproduce! Happy to help and provide more informations if needed.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
How it works:
It would be interesting to have the stack trace of Cannot read property ‘read’ of null or any other stack trace you may have during your test.
It could be empty at
document.getText()
which is where this extension reads the content https://github.com/prettier/prettier-vscode/blob/v1.3.1/src/PrettierEditProvider.ts#L252 But I don’t know why.Can you reproduce something like that without any extension but the default formatter ? or only this extension?
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.