razor icon indicating copy to clipboard operation
razor copied to clipboard

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

Open LiamMorrow opened this issue 2 years ago • 4 comments
trafficstars

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 avatar Nov 19 '23 10:11 LiamMorrow

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

LiamMorrow avatar Feb 20 '24 05:02 LiamMorrow

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

davidwengier avatar Mar 14 '24 03:03 davidwengier

@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?

phil-allen-msft avatar Mar 28 '24 21:03 phil-allen-msft

I have this even without the c# devkit extension

lonix1 avatar Mar 28 '24 23:03 lonix1

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.

chandrashekharjoshi-abb avatar Apr 03 '24 05:04 chandrashekharjoshi-abb

@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 🎉

LiamMorrow avatar Apr 03 '24 23:04 LiamMorrow

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.

chandrashekharjoshi-abb avatar Apr 04 '24 05:04 chandrashekharjoshi-abb

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

dawnFirefly avatar Apr 15 '24 18:04 dawnFirefly

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

LiamMorrow avatar Apr 15 '24 23:04 LiamMorrow

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.

Fronix avatar Jun 04 '24 08:06 Fronix

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,

LiamMorrow avatar Jun 04 '24 22:06 LiamMorrow

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

chandrashekharjoshi-abb avatar Jun 05 '24 03:06 chandrashekharjoshi-abb

Validated

micgo1995 avatar Nov 19 '25 21:11 micgo1995