-
Notifications
You must be signed in to change notification settings - Fork 24
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
"Roslyn server stopped" when the file doesn't have a new line at EOF #27
Comments
I can't reproduce. What is the log from the server? |
Ok, I tried to reproduce it in a personal project just by removing the last line, but I couldn't.
Then after running the The LspLog: [ERROR][2024-08-02 12:00:53] ...lsp/handlers.lua:623 "[LanguageServerHost] System.ArgumentException: Range={ Start={ Line=11, Character=1 }, End={ Line=12, Character=0 } }. text.Length=209. text.Lines.Count=12\n ---> System.ArgumentOutOfRangeException: The requested line number 12 must be less than the number of lines 12. (Parameter 'Line')\n at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67\n at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330\n --- End of inner exception stack trace ---\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.ContentChangeEventToTextChange(TextDocumentContentChangeEvent changeEvent, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 365\n at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()\n at System.Collections.Immutable.ImmutableArray`1.Builder.AddRange(IEnumerable`1 items)\n at Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1.AddRange(IEnumerable`1 items) in /_/src/Dependencies/PooledObjects/ArrayBuilder.cs:line 624\n at Roslyn.Utilities.EnumerableExtensions.SelectAsArray[TSource,TResult](IEnumerable`1 source, Func`2 selector) in /_/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs:line 355\n at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidChangeHandler.GetUpdatedSourceText(TextDocumentContentChangeEvent[] contentChanges, SourceText text) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs:line 70\n at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidChangeHandler.HandleRequestAsync(DidChangeTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs:line 33\n at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 187"
[ERROR][2024-08-02 12:00:53] ...lsp/handlers.lua:623 "[LanguageServerHost] System.ArgumentException: Range={ Start={ Line=11, Character=1 }, End={ Line=12, Character=0 } }. text.Length=209. text.Lines.Count=12\n ---> System.ArgumentOutOfRangeException: The requested line number 12 must be less than the number of lines 12. (Parameter 'Line')\n at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67\n at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330\n --- End of inner exception stack trace ---\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335\n at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.ContentChangeEventToTextChange(TextDocumentContentChangeEvent changeEvent, SourceText text) in /_/src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 365\n at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()\n at System.Collections.Immutable.ImmutableArray`1.Builder.AddRange(IEnumerable`1 items)\n at Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1.AddRange(IEnumerable`1 items) in /_/src/Dependencies/PooledObjects/ArrayBuilder.cs:line 624\n at Roslyn.Utilities.EnumerableExtensions.SelectAsArray[TSource,TResult](IEnumerable`1 source, Func`2 selector) in /_/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs:line 355\n at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidChangeHandler.GetUpdatedSourceText(TextDocumentContentChangeEvent[] contentChanges, SourceText text) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs:line 70\n at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidChangeHandler.HandleRequestAsync(DidChangeTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs:line 33\n at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 187\n at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 241\n at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueCoreAsync[TRequest,TResponse](IQueueItem`1 work, IMethodHandler handler, RequestHandlerMetadata metadata, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 349\n at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.InvokeProcessCoreAsync(IQueueItem`1 work, RequestHandlerMetadata metadata, IMethodHandler handler, MethodInfo methodInfo, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 302\n at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueAsync() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 254"
|
@seblj I found out about this fork yesterday, thanks a lot for it. One other issue, I'm using the latest LanguageServer version, and the diagnostics are not showing, should I open another issue? What version should I use? $ dotnet Microsoft.CodeAnalysis.LanguageServer.dll --version
4.12.0-2.24401.2+eafb7892671c3917bc1c060c185211740eeb55ce Saw this error in LspLog:
|
Okay I was able to reproduce with the |
This is probably a bug in neovim as I cannot reproduce this in vscode, and this plugin is mostly just a thin wrapper to be able to start the server (and a couple of extra handlers implemented). It looks like neovim is sending a It might also be that neovim is behaving correctly (I am not sure), and the server just not adhering to the LSP spec. Wouldn't be the first time if so. |
Got it, I imagined that this was not an issue with this plugin... thanks for the investigation anyways. Would be good if the |
Yeah I agree, but I think that only works with language servers setup via I think we can just leave this issue open if it's okay for you? Then I can potentially investigate it more if I get time at some point, and then potentially at least raise an issue where it belongs. Or maybe someone else notices the same thing, and they can easily see it, and maybe help if they want |
@seblj sure, I'd appreciate that. About that other error: 2024-08-02.13-08-33.mp4
|
Hmm, that is weird because it works in my projects at work🤔 it looks like the project is public, so I can have a look at testing it with that project. Could you could open another issue, attach the video and the output of the entire lsp log? |
Sure, Ill do it in a sec, but that's happening for all my projects, not just that one. Just to be sure I'm not doing something completely stupid, that's all I did when moving from the other repo to this fork (+ upgrading to the latest CodeAnalysis.LanguageServer): I'll also try to downgrade the CodeAnalysis.LanguageServer version. |
Ahaaaaa, I know what is wrong... To fix this in no time for you, you can just remove However, this really is a bug in my plugin though. No need to create a new issue if you haven't already. I will fix this right away. UPDATE: Fixed in the latest commit |
@seblj Thanks a lot man, now everything is perfect! Keep it up with the good work! |
Hi, I am also experiencing the server crashing when adding an empty line to the end of the file. This happens with server version
|
Haven't had any time/prioritized to look into this yet as there is nothing I can do in this repo. The issue must be in either neovim or roslyn. |
I did some more testing and I think we can rule out neovim's relevant options. The error seems to happen regardless of their value. I tested |
Yeah I think an issue to roslyn would be great. The issue should have some details in it though. For example, the logs for the request, what neovims response is, and such. It would also be interesting to see the logs of the communication between vscode and roslyn, to see how they deal with this. However, I don't know vscode well enough to configure it to see the logs for requests and response. I could also be open to a PR with a hacky fix, if it is very self container, doesn't break anything, and does not require a lot of code. I have no idea how it could look like though |
The server can crash in other scenarios without any editorconfig, they are very likely related to each other and possibly the original issue 1Yank / copy a line, a whole file, whatever you want If even the first or last line is excluded from the selection, it doesn't crash anymore. Interestingly, if I paste from the terminal emulator with control + shift + v, it doesn't crash and the lsp works. That is, unless you delete the last line or undo the paste, at which point the server crashes. 2Delete the content of a cs file 3Create a new cs file Simply adding an empty line at the end in normal scenarios is somehow not enough for it to crash for me |
In the company where I work, they have this weird lint rule of not allowing any file to have an empty line at the end of the file.
Every time I go to the end of the file and add a new line, the LSP server crashes, and as
:LspRestart
doesn't work, I have to quit and re-open neovim.To reproduce:
G
ando
to go to the EOF and add a new line:messages
The text was updated successfully, but these errors were encountered: