Closed pjg closed 2 years ago
I ran into the same issue, not sure if this is just a COC issue or this is a COC issue that's only surfaced for coc-prettier
- but I was able to git bisect
and it looks like this started happening with this commit: https://github.com/neoclide/coc.nvim/commit/9c54590c6dd37f06a27768a5c3e22615795a0ae9.
Here's a minimal vimrc I was able to reproduce this with (along with having coc-prettier
installed and coc.preferences.formatOnSaveFiletypes
set for the filetype I'm using):
call plug#begin()
Plug 'neoclide/coc.nvim', {'commit': '9c54590c', 'do': 'yarn install --frozen-lockfile'}
call plug#end()
noremap <silent> <C-s> <Esc>:write<CR>
noremap! <silent> <C-s> <Esc>:write<CR>
And here's what the issue looks like for me when using this vimrc, where you can see me delete a line and then it be re-added when Prettier runs. I'm hitting dd<C-s>
several times rapidly to cause this; it seems like this only occurs when an edit and then a write occur in very quick succession.
https://user-images.githubusercontent.com/7476523/137039639-43c46634-5a68-43e8-bc26-3c9a4e419b76.mp4
I was able to work around this though by just pinning COC to the parent commit of the commit that introduced the issue, like this: https://github.com/bobwhitelock/dotfiles/commit/44a749b3f939f05452ee6601a7170a8de4077336
Any ideas @chemzqm?
I'm seeing the same issue. It was hard to diagnose because the delay needed to ensure a good save is pretty short. I thought that it might be some sort of plugin conflict or the result of my becoming more comfortable in vim (and therefore typing faster).
It has become enough of a problem that I finally decided to diagnose with a minimal install and .vimrc.
If I type dd
and then sdf
in quick succession, the line is deleted, but then it reappears as soon as prettier runs. If I run those two commands with ~500ms between them, they work as expected.
Similarly, if I type u
and sdf
in quick succession, the undo executes, but is then reverted when prettier runs.
~/.vimrc:
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
inoremap df <ESC>
noremap sdf <ESC>:w<CR>
inoremap sdf <ESC>:w<CR>
~/.vim/coc-settings.json:
{
"coc.preferences.formatOnSaveFiletypes": ["scss"],
}
I can confirm the problem. Steps to reproduce for me:
<ESC>
then immediately type :w
File gets messed up.
It happens frequently enough that I cannot use the plugin because of it. :(
Might be fixed by https://github.com/neoclide/coc.nvim/commit/4a1cc23b4d1a708eb0b887ef538b7e8dda36bf63, try latest coc.nvim
Looks like this is fixed the issue for me, thanks @chemzqm!
Open another issue with :CocInfo
if you still experience this bug.
Seems to work for me as well, thx @chemzqm!
This is now fixed. Thank you @chemzqm!
Fixed for me too, thanks @chemzqm!
Fixed it for me too! Thanks
I make a change and quickly hit the combination for
:w
. What happens is that my change is reverted and shortly after pretter runs and "Formatted by prettier" message is being displayed.It's hard to diagnose as it might be the result of my config/plugins/etc. but I was unable to trace it. I only know this happens after I tried switching to
prettier-eslint
.When showing command debug for
prettier
I can see thenewText
is incorrect, with the reverted change.