Skip to content
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

The abnormal behavior in neovim when use csharp-ls #18147

Closed
Decodetalkers opened this issue Apr 17, 2022 · 6 comments
Closed

The abnormal behavior in neovim when use csharp-ls #18147

Decodetalkers opened this issue Apr 17, 2022 · 6 comments
Labels
bug issues reporting wrong behavior lsp status:blocked-external Needs a third-party / external change or fix
Milestone

Comments

@Decodetalkers
Copy link

Neovim version (nvim -v)

0.7.0

Vim (not Nvim) behaves the same?

no

Operating system/version

Arch Linux kernel 5.17.3-arch1-1

Terminal name/version

foot

$TERM environment variable

foot

Installation

archlinux repo

How to reproduce the issue

put this line into your config

autocmd FileType cs autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()

mkdir test
cd test
dotnet new console --language "C#"
nvim Program.cs

namespace Main
{
    class Test {
        static void Main() {
        }
    }
}

copy the line above to the file and exit
reopen the file
enter "using System."
the menu will not popup
Then save the file
then the format will wrong

Expected behavior

Format right and does not report wrong thing when use csharp-ls

Actual behavior

I use format and cmp here. but cmp work not well. After "System", it should has menu before.But there is no menu. In neovim 0.6.1 it work. and when delete the line where it report bugs, the warning is not fade.

And I use the format. In neovim 0.6.1, the format work well, but It format wrong in neovim 0.7

test.mp4
@Decodetalkers Decodetalkers added the bug issues reporting wrong behavior label Apr 17, 2022
@Decodetalkers
Copy link
Author

Decodetalkers commented Apr 17, 2022

I don't know if it is the bug of neovim or the server, because before 0.7, it works well..

@razzmatazz
Copy link

razzmatazz commented Apr 24, 2022

This looks like incremental document sync error to me -- i.e. the editor things the contents of the file are different from what the server does.

  • Maybe we could try disabling incremental sync in nvim (or csharp-ls) to see if this fixes the issue?
  • Also, is this deterministic? Does it always happen like this, but what happens if you type slower or perform the edits in some other other?

@Decodetalkers
Copy link
Author

Maybe we could try disabling incremental sync in nvim (or csharp-ls) to see if this fixes the issue?

After I disable the incremental sync, It works, however, the neovim cannot diagnose and format the script

yes this is deterministic, and I type slower,It may works

@razzmatazz
Copy link

razzmatazz commented May 18, 2022

Hmm, I believe csharp-ls has broken behaviour wr.t. incremental sync..

I was trying to replicate the problem and managed to setup packer+nvim-lspconfig and immediately hit the problem where typing things too fast in nvim triggers document sync problems.

My plan here is to:

  • update csharp-ls to properly handle full sync behaviour from the client (via negotation)
  • add a command line param to force full sync
  • add a PR to nvim-lspconfig to set this param until we have this partial sync bug diagnosed (whether this is csharp-ls or nvim at fault)
    • for some reason partial sync works for me in emacs, but it breaks in nvim; most probably a bug in csharp-ls if this is not observerved on other servers;
  • fix the actual problem

@justinmk justinmk added the status:blocked-external Needs a third-party / external change or fix label May 18, 2022
@justinmk justinmk added this to the backlog milestone May 18, 2022
@razzmatazz
Copy link

razzmatazz commented May 19, 2022

So apparently were was a bug in csharp-ls that was related to incremental sync which was being hit by nvim (more often than by other clients):

I have released a new version of csharp-ls that should fix the bug:

@Decodetalkers
Copy link
Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior lsp status:blocked-external Needs a third-party / external change or fix
Projects
None yet
Development

No branches or pull requests

4 participants