razor
razor copied to clipboard
Constant Request textDocument/semanticTokens/range failed. error in vscode
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.
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.
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
Also reported internally in https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1957989
@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?
I have this even without the c# devkit extension
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 , 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 🎉
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.
This issue is extremely annoying. It keeps spamming these messages in the bottom right: "Request textDocument/hover failed." and "Request textDocument/semanticTokens/range failed."
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
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.
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,
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
Validated