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

Constant Request textDocument/semanticTokens/range failed. error in vscode #9598

Open
LiamMorrow opened this issue Nov 19, 2023 · 12 comments
Open
Labels
bug Something isn't working vscode

Comments

@LiamMorrow
Copy link

LiamMorrow commented Nov 19, 2023

G'day, I've been using the c# devkit extension in vscode and have noticed that when editing razor files it constantly shows errors as notifications, simply when navigating to any razor file.

Request textDocument/semanticTokens/range failed.
image

Logs

Details [Error - 20:31:23] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=207, Character=17 }, End={ Line=260, Character=0 } }. text.Length=5758. text.Lines.Count=230 ---> System.ArgumentOutOfRangeException: The requested line number 260 must be less than the number of lines 230. (Parameter 'Line') at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67 at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78 at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 287 --- End of inner exception stack trace --- at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 292 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(ClientCapabilities capabilities, Document document, Range[] ranges, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 85 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 50 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 45 at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) [Error - 20:31:23] Request textDocument/semanticTokens/range failed. Message: Range={ Start={ Line=207, Character=17 }, End={ Line=260, Character=0 } }. text.Length=5758. text.Lines.Count=230 Code: -32000 [object Object]

Note this happens on both the current release, and the prerelease.

@LiamMorrow
Copy link
Author

To be honest, I'm not too fazed about the intellisense and that not working. If there was a way to disable these error notifications (you can't disable errors notifications in VSCode without a CSS hack), or downlevel them to warning that'd be immediately much better for me

@davidwengier
Copy link
Contributor

Also reported internally in https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1957989

@phil-allen-msft
Copy link
Contributor

@LiamMorrow , we've recently made some changes that are in the C# Extension for VS Code version 2.22.5 related to the handling of the casing of paths; does that resolve this issue for you?

@lonix1
Copy link

lonix1 commented Mar 28, 2024

I have this even without the c# devkit extension

@chandrashekharjoshi-abb
Copy link

This issue is extremly annoying, first of all intellisense doesn't work and on top of that notification keep popping even when we type a single word. Turn of notification also doesn't work.

@LiamMorrow
Copy link
Author

@LiamMorrow , we've recently made some changes that are in the C# Extension for VS Code version 2.22.5 related to the handling of the casing of paths; does that resolve this issue for you?

Sorry for the delay @phil-allen-msft it's been a hectic couple of weeks as I'm moving rn.

Currently running v2.24.17 (prerelease) and I haven't seen the issue after a brief play around 🎉

@chandrashekharjoshi-abb
Copy link

This issue is extremly annoying, first of all intellisense doesn't work and on top of that notification keep popping even when we type a single word. Turn of notification also doesn't work.

I found the solution for my use case, i had a solution which had Blazor projects from different repos and not part of same workspace, if i open them in separate Workspaces or open the root folder where alll repos exist then no issues.

@ryzngard ryzngard added bug Something isn't working and removed untriaged labels Apr 11, 2024
@SamuelChih
Copy link

This issue is extremely annoying. It keeps spamming these messages in the bottom right:
"Request textDocument/hover failed." and "Request textDocument/semanticTokens/range failed."

@LiamMorrow
Copy link
Author

Yeah unfortunately it is back for me as well. It's not a small repo, but this is where I can reliably reproduce it
https://github.com/LiamMorrow/LiftLog

@Fronix
Copy link

Fronix commented Jun 4, 2024

I've had this issue since start of 2023, it comes and goes. Sometimes it works fine but mostly it's just spitting errors.

Is there any ETA on this fix, I feel like this should be important since the C# DeKit extestension is supposed to be "the new thing" for VSCode C# development and right now it's not very usable.

@LiamMorrow
Copy link
Author

It keeps spamming these messages in the bottom right:

@SamuelChih I just discovered this setting in vscode. It doesn't fix the problem that it is having, but it does stop it from causing that flood of notifications.

  "dotnet.server.suppressLspErrorToasts": true,

@chandrashekharjoshi-abb
Copy link

I have also observed that snap version of vscode has this issue, installed using below commands and after that i faced no issue

echo -e "${Highlight}Installing vs code...${NC}"
# sudo snap install --classic code
# NOTE: Snap confinement causes issues for tools Code uses – using apt install instead.
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

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

No branches or pull requests

8 participants