Fix PrettierAsync ignored file contents mangling#142
Merged
mitermayer merged 2 commits intoprettier:masterfrom Jun 18, 2018
SamHowie:master
Merged
Fix PrettierAsync ignored file contents mangling#142mitermayer merged 2 commits intoprettier:masterfrom SamHowie:master
mitermayer merged 2 commits intoprettier:masterfrom
SamHowie:master
Conversation
Collaborator
Author
|
I have checked this on Vim 8. @mitermayer could you check on Vim 7.4 and NeoVim? |
Member
|
Hi @SamHowie, Thanks for looking into this! This is great, will do some sanity testing and comment on this issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes #140 where the PrettierAsync command causes the buffer contents to become garbled if the file is ignored by prettier.
It was found to be an issue with more recent versions of prettier that echo the stdin[1] of ignored files back to stdout[2].
Unfortunately, Vim channels do not like this very much. Vim writes NUL bytes to Prettier's stdin to indicate line endings. However, Prettier is echoing them back and then Vim is having trouble reading them back from what it thinks is a string, leading to undefined behaviour.
https://github.com/vim/vim/blob/master/runtime/doc/channel.txt#L407
The work around is to do what the vim documentation suggests and let the job write to a hidden buffer. This doesn't seem to be effected by the segmentation fault issue the input buffer was causing.
I also was having a weird rendering issue if the file contents had not changed. I added a
redraw!to that code path and it fixed it. I am not sure if this issue was pre-existing.Test Plan
foo.js.prettierignorefilefoo.jsto the.prettierignorefilefoo.jsfilefoo.jsfile