-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coc format behavior differently between Neovim and Vim, create unnecessary empty change in neovim. #4994
Comments
It is this line causing the difference: coc.nvim/src/model/document.ts Line 349 in 2ec3166
|
tracked down to line coc.nvim/autoload/coc/compat.vim Line 18 in 2ec3166
turns out when format without change, the arguments passed to nvim_buf_set_lines is And i test this function on a buffer, it did change the buffer and create empty change. From :h nvim_buf_set_lines:
So |
Thank you for your tracking, but I can't reproduce this with your mini.nivm and formatted demo.lua, with coc-sumneko-lua on nvim nightly. And I couldn't reproduce with other language servers too. |
The checking fix in #4995 is OK, but I couldn't result any format without change, coc.nvim couldn't run to this check. |
@fannheyward Just tested on different version of coc. coc release branch coc.nvim version: 0.0.82-2ec31666 2024-04-23 09:10:14 +0800 have issue. coc tag v0.0.82, v0.0.81 doesn't have issue. |
I believe this issue was introduced after v0.0.82. But in v0.0.82, it works well without the need of You can discard this pr, and i will just stick to version v0.0.82. |
Thank you for your tests with different releases of coc, I don't complain your PR, but how to reproduce this, here's my tests:
Also I've tested the formatting with tsserver, gopls, rust-analyzer servers, won't change on formatted files. |
You can use |
Result from CocInfo
Describe the bug
In Vim, after run
:Format
on already formatted file do not change the file, but it does change the file in Neovim (tested on 0.83,0.9,0.91,nightly versions).The inconvenience result is that:
u
to undo multiple empty changes (0 changes; before#1
1 second ago), and pressu
will always move your cursor to the 2 line at the same column before you pressu
.BufWritePre
autocmd to format this file, sometimes the file is not saved.Reproduce the bug
We will close your issue when you don't provide minimal vimrc and we can't
reproduce it
mini.vim
with:Note, the demo file should be already formated, if it is not, format and save it;
nvim --clean -u mini.vim demo.lua
:Format
[+]
.u
will move cursor to 2 line at the same column before theu
.Screenshots (optional)
2024-04-27.14.29.29.mov
The text was updated successfully, but these errors were encountered: