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

LSP no text synchronization. #1498

Open
ElayneB opened this issue May 15, 2019 · 7 comments
Open

LSP no text synchronization. #1498

ElayneB opened this issue May 15, 2019 · 7 comments
Labels

Comments

@ElayneB
Copy link

ElayneB commented May 15, 2019

Text synchronization does not appear to be working when running roslyn in -lsp mode. I've attached a log from the server showing this error.

The log shows my client initializing the server, opening a document, and then making some changes. It ends with an error when it requests autocompletion from a cursor position that the server believes does not exist.

lsp-textsync-errorlog.txt

@Aayush04
Copy link

I am also getting the same issue.
This error is coming when the rootUri path at the server side having less number of lines than what is coming in the didOpen message.
So, for the current workaround, I have done 2 things:

  1. I have added as many as blank lines as there are in didOpen message.
  2. Sending a didChange message containing the full text as changes. ( I have to do this because the server in lsp mode not handling incremental changes properly. )

I think this issue could be related to #1490

@ElayneB
Copy link
Author

ElayneB commented May 17, 2019

I think we are experiencing the same issue, but your workaround hasn't fixed it for me. I can save the file with many blank lines, but as soon as my client gets beyond the saved state of the file I get the out of bounds exception. I also only get proper completion responses based on the saved state of the file.

This maybe expected behavior for omnisharp in lsp mode. Omnisharp responds to initialization with a textDocumentSync: 0. According the spec, this response indicates that the server does not synchronize files. However, the logs indicate that the language server is trying to sync the files, and it sounds like you have found some success in getting this working.

It would be great to get some insight from a contributor as to the current state of lsp mode.

@bjorkstromm
Copy link
Member

I've seen issues with incremental changes with *.cake files and therefore only supporting full changes for Cake.

if (selector.ToString().IndexOf(".cake") > -1) documentSyncKind = TextDocumentSyncKind.Full;

It could it be so that incremental changes is broken also for plain C# as @Aayush04 suggests.

@ElayneB does it work if you send only full changes from your client?

@Aayush04
Copy link

@mholo65 So, I am working with .cs file. In my case, incremental changes are not working. And yes, in case of full changes. You can see my issue details #1490 where when I am sending full changes it started working.

@ElayneB
Copy link
Author

ElayneB commented May 20, 2019

@mholo65 My client is sending full changes and I am still getting the error. Here's an example didChange request my client is sending.

{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///srv/app/language_servers/csharp/Program.cs","version":39},"contentChanges":[{"text":"using System;\n\nnamespace csharp\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Console.WriteLine(\"dsfsf\");\n          \n          \n          \n          \n          \n          \n          Console\n          \t\n        }\n    }\n}\n\n\n"}]}}

@ElayneB
Copy link
Author

ElayneB commented May 20, 2019

@Aayush04, do you have logs of it working with full changes that you can share? I'd like to compare them to mine and see if I see differences in the workflow / formatting.

@filipw filipw added the lsp label Jun 4, 2019
@razzmatazz
Copy link
Contributor

I believe sync issues (at least partially) are fixed with:

The underlying issue was in LSP library:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants