From 8bd5ee3b3066f7b4bbedffed8a6080be866bcd93 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Wed, 19 Aug 2020 07:51:08 -0700 Subject: [PATCH] Fixed range from lexer API (#9963) --- src/fsharp/service/ServiceLexing.fs | 1 + .../src/FSharp.Editor/Classification/ClassificationService.fs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsharp/service/ServiceLexing.fs b/src/fsharp/service/ServiceLexing.fs index 20f05760f33..8a6ae6e6687 100755 --- a/src/fsharp/service/ServiceLexing.fs +++ b/src/fsharp/service/ServiceLexing.fs @@ -1534,6 +1534,7 @@ module Lexer = use _unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse use _unwindEL = PushErrorLoggerPhaseUntilUnwind (fun _ -> DiscardErrorsLogger) + resetLexbufPos "" lexbuf while not lexbuf.IsPastEndOfStream do ct.ThrowIfCancellationRequested () onToken (getNextToken lexbuf) lexbuf.LexemeRange diff --git a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs index 61f297fed7d..77d349e091e 100644 --- a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs +++ b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs @@ -75,6 +75,7 @@ type internal FSharpClassificationService static let userOpName = "SemanticColorization" static let getLexicalClassifications(filePath: string, defines, text: SourceText, textSpan: TextSpan, ct) = + let text = text.GetSubText(textSpan) let result = ImmutableArray.CreateBuilder() let tokenCallback = fun (tok: FSharpSyntaxToken) -> @@ -94,7 +95,7 @@ type internal FSharpClassificationService | _ -> () let flags = FSharpLexerFlags.Default &&& ~~~FSharpLexerFlags.Compiling &&& ~~~FSharpLexerFlags.UseLexFilter - FSharpLexer.Lex(text.GetSubText(textSpan).ToFSharpSourceText(), tokenCallback, filePath = filePath, conditionalCompilationDefines = defines, flags = flags, ct = ct) + FSharpLexer.Lex(text.ToFSharpSourceText(), tokenCallback, filePath = filePath, conditionalCompilationDefines = defines, flags = flags, ct = ct) result.ToImmutable()