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

VScode Avalonia XAML autocompletion doesn't work #110

Open
RegreTTO opened this issue Feb 13, 2024 · 26 comments
Open

VScode Avalonia XAML autocompletion doesn't work #110

RegreTTO opened this issue Feb 13, 2024 · 26 comments
Assignees
Labels
bug Something isn't working

Comments

@RegreTTO
Copy link

RegreTTO commented Feb 13, 2024

Describe the bug

After triggering autocomplete it doesn't work and throws errors in "Avalonia Client" log section in VScode

To Reproduce

Steps to reproduce the behavior:

  1. Create new project with dotnet new install Avalonia.Templates
  2. Go to .axaml
  3. Click on "<" for example
  4. See error

Expected behavior

I get autocompletion

Environment

  • OS: Arch Linux
  • Avalonia-Version: 11.0.6
  • Avalonia VScode extension version: 0.0.31

Additional context

Error itself
2024-02-13 20:07:23.837 [info] [Trace - 20:07:23] Sending notification 'textDocument/didChange'.
2024-02-13 20:07:23.843 [info] [Trace - 20:07:23] Sending request 'textDocument/completion - (2)'.
2024-02-13 20:07:23.853 [info] [Trace - 20:07:23] Received notification 'window/logMessage'.
2024-02-13 20:07:23.853 [info] [Error - 20:07:23] OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/completion 2 - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<b__5>d.MoveNext() | Method='textDocument/completion' RequestId='2'
2024-02-13 20:07:23.854 [info] [Trace - 20:07:23] Received response 'textDocument/completion - (2)' in 11ms. Request failed: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<b__5>d.MoveNext() (-32603).
2024-02-13 20:07:23.855 [info] [Error - 20:07:23] Request textDocument/completion failed.
2024-02-13 20:07:23.855 [info]   Message: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<b__5>d.MoveNext()
  Code: -32603 
2024-02-13 20:07:24.854 [info] [Trace - 20:07:24] Sending notification 'textDocument/didSave'.
2024-02-13 20:07:24.856 [info] [Trace - 20:07:24] Received notification 'window/logMessage'.
2024-02-13 20:07:24.857 [info] [Info  - 20:07:24] AvaloniaLanguageServer.Handlers.TextDocumentSyncHandler: DidSaveTextDocumentParams OmniSharp.Extensions.LanguageServer.Protocol.Models.DidSaveTextDocumentParams | Request='OmniSharp.Extensions.LanguageServer.Protocol.Models.DidSaveTextDocumentParams'
2024-02-13 20:07:25.169 [info] [Trace - 20:07:25] Sending notification 'workspace/didChangeWatchedFiles'.
@RegreTTO RegreTTO added the bug Something isn't working label Feb 13, 2024
@timunie
Copy link

timunie commented Feb 13, 2024

@RegreTTO please make sure you have all the latest versions of the extension and Avalonia. If the issue persistets file a minimum repo.

Note: that the extension has its own repo where issues should be reported.

@MikeCodesDotNET MikeCodesDotNET transferred this issue from AvaloniaUI/Avalonia Feb 13, 2024
@prashantvc
Copy link
Collaborator

@RegreTTO This is fixed in the version v0.0.30, could you confirm that you have latest version of the extension?

@prashantvc prashantvc self-assigned this Feb 14, 2024
@RegreTTO
Copy link
Author

@prashantvc Yes. I've checked the version right now and it is exactly v0.0.30

@RegreTTO
Copy link
Author

@timunie It was the first time I installed all avalonia-related plugins, so they are exactly last version

@timunie
Copy link

timunie commented Feb 14, 2024

11.0.6 is outdated. 11.0.9 is recent.

@RegreTTO
Copy link
Author

RegreTTO commented Feb 14, 2024

I installed it as said in the docs with dotnet new install Avalonia.Templates. I took version from my .csproj file.

@timunie
Copy link

timunie commented Feb 15, 2024

The templates were maybe not updated yet. They are not always in sync with latest minor version, so please try to update your nugets 🙏

@calee88
Copy link

calee88 commented Feb 17, 2024

@timunie Hello!
How can I update my nugets? I tried

dotnet new install Avalonia.Templates::11.0.9

I got

Warning: Avalonia.Templates::11.0.9 is not found in NuGet feeds https://api.nuget.org/v3/index.json.
Avalonia.Templates::11.0.9 could not be installed, the package does not exist.

I also searched for the Avalonia.Templates and found that the latest version is 11.0.6.
https://www.nuget.org/packages?q=Avalonia.Templates

@calee88
Copy link

calee88 commented Feb 17, 2024

I tried to update the package versions by manually changing the versions in .csproj file, and rebuild the project. However, the problem persists.

@calee88
Copy link

calee88 commented Feb 17, 2024

I changed the extension to v0.0.29, and the problem has been resolved.

@RegreTTO
Copy link
Author

Thanks, I'll try downgrading later

@RegreTTO
Copy link
Author

@calee88 Indeed, downgrading fixes this problem

@RegreTTO
Copy link
Author

Or not. After rebooting it started to infinitely ask me to build project, but nothing changes. It asks, I build, it asks again and so on

@timunie
Copy link

timunie commented Feb 18, 2024

@RegreTTO please upload a minimum sample for us to reproduce.

@RegreTTO
Copy link
Author

@timunie There is no need me to upload such. It is just dotnet new avalonia.mvvm, nothing more

@microhobby
Copy link
Collaborator

I'm having the same issue 😓

@microhobby
Copy link
Collaborator

microhobby commented Feb 27, 2024

Interesting, if I downgrade the extension to the v0.0.29 it works 🤔

Edit: yeah, now I see that this was already proposed, then confirmed.

@LeadManPL
Copy link

LeadManPL commented Mar 5, 2024

I can confirm. Just follow Avalonia docs to reproduce this error. Avalonia.Templates::11.0.6 is the newest version available.

Might be related to this OmniSharp issue #2525 or #2550

2024-03-05 15:52:27.694 [info] [Trace - 15:52:27] Sending request 'textDocument/completion - (1)'.
2024-03-05 15:52:27.729 [info] [Trace - 15:52:27] Received notification 'window/logMessage'.
2024-03-05 15:52:27.729 [info] [Error - 15:52:27] OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/completion 1 - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() | Method='textDocument/completion' RequestId='1'
2024-03-05 15:52:27.736 [info] [Trace - 15:52:27] Received response 'textDocument/completion - (1)' in 41ms. Request failed: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() (-32603).
2024-03-05 15:52:27.736 [info] [Error - 15:52:27] Request textDocument/completion failed.
2024-03-05 15:52:27.736 [info]   Message: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
  Code: -32603 

@doxxx
Copy link

doxxx commented Mar 5, 2024

I have the same problem, even after updating all the Avalonia packages in my project to 11.0.9 and with extension v0.0.31.

I'm running VS Code on Windows but connected to WSL.

@doxxx
Copy link

doxxx commented Mar 5, 2024

However, the same happens for a project opened from the Windows filesystem.

@prashantvc
Copy link
Collaborator

@doxxx the WSL support is untested. Let me check this one windows

@AedDev
Copy link

AedDev commented May 18, 2024

I changed the extension to v0.0.29, and the problem has been resolved.

Same issue here. Installed the latest versions of Avalonia.Templates which is 11.0.11 at the time of writing and the Avalonia VS Code Extension in version 0.0.31. Downgraded to 0.0.29 resolved the issue.

I am working on Pop!OS Linux by System76. VS Code is installed via flatpak.

Steps to reproduce:

  • Install .NET 8 SDK
  • Install VS Code from Flatpak (latest version)
  • Install the Avalonia VS Code Extension (0.0.31 in my case, or 0.0.30 as stated in the comments above)
  • Install Avalonia.Templates
  • Create new MVVM Project dotnet new avalonia.mvvm
  • Open up the MainWindow.axaml file
  • Type a < somewhere in the document
  • Error message will pop up:
2024-05-18 14:33:05.639 [info] [Trace - 2:33:05 PM] Sending notification 'textDocument/didChange'.
2024-05-18 14:33:05.639 [info] [Trace - 2:33:05 PM] Sending request 'textDocument/completion - (1)'.
2024-05-18 14:33:05.674 [info] [Trace - 2:33:05 PM] Received notification 'window/logMessage'.
2024-05-18 14:33:05.674 [info] [Error - 2:33:05 PM] OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/completion 1 - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() | Method='textDocument/completion' RequestId='1'
2024-05-18 14:33:05.679 [info] [Trace - 2:33:05 PM] Received response 'textDocument/completion - (1)' in 40ms. Request failed: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() (-32603).
2024-05-18 14:33:05.680 [info] [Error - 2:33:05 PM] Request textDocument/completion failed.
2024-05-18 14:33:05.680 [info]   Message: Internal Error - System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AvaloniaLanguageServer.Services.Buffer.GetTextTillLine(Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs:line 8
   at AvaloniaLanguageServer.Services.BufferService.GetTextTillPosition(DocumentUri key, Position position) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Services/BufferService.cs:line 22
   at AvaloniaLanguageServer.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in /Users/prashantvc/Avalonia/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs:line 29
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
  Code: -32603

@aneeskA
Copy link

aneeskA commented Jul 5, 2024

If this helps anyone, 0.0.31 had issues. Downgrading to 0.0.29 resolved the issue.

image image

@tmp64
Copy link

tmp64 commented Nov 2, 2024

Can confirm that the issue is fixed in latest commits. But you have to build the latest AvaloniaLSP manually.

@marcin-przywoski
Copy link

@tmp64 how do I do that?

@tmp64
Copy link

tmp64 commented Nov 26, 2024

@tmp64 how do I do that?

Clone this repo, build src/AvaloniaLSP (in Visual Studio or with dotnet build) and replace the original version in C:\Users\user.vscode\extensions\avaloniateam.vscode-avalonia-0.0.31\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests