@@ -33,7 +33,8 @@ type internal LexerSymbolKind =
3333 | GenericTypeParameter = 3
3434 | StaticallyResolvedTypeParameter = 4
3535 | ActivePattern = 5
36- | Other = 6
36+ | String = 6
37+ | Other = 7
3738
3839type internal LexerSymbol =
3940 { Kind: LexerSymbolKind
@@ -147,11 +148,14 @@ module internal Tokenizer =
147148 | FSharpGlyph.Variable -> Glyph.Local
148149 | FSharpGlyph.Error -> Glyph.Error
149150
150- let GetImageIdForSymbol ( symbol : FSharpSymbol , kind : LexerSymbolKind ) =
151+ let GetImageIdForSymbol ( symbolOpt : FSharpSymbol option , kind : LexerSymbolKind ) =
151152 let imageId =
152153 match kind with
153154 | LexerSymbolKind.Operator -> KnownImageIds.Operator
154155 | _ ->
156+ match symbolOpt with
157+ | None -> KnownImageIds.Package
158+ | Some symbol ->
155159 match symbol with
156160 | :? FSharpUnionCase as x ->
157161 match Some x.Accessibility with
@@ -345,6 +349,7 @@ module internal Tokenizer =
345349 member token.IsIdentifier = ( token.CharClass = FSharpTokenCharKind.Identifier)
346350 member token.IsOperator = ( token.ColorClass = FSharpTokenColorKind.Operator)
347351 member token.IsPunctuation = ( token.ColorClass = FSharpTokenColorKind.Punctuation)
352+ member token.IsString = ( token.ColorClass = FSharpTokenColorKind.String)
348353
349354 /// This is the information we save for each token in a line for each active document.
350355 /// It is a memory-critical data structure - do not make larger. This used to be ~100 bytes class, is now 8-byte struct
@@ -375,6 +380,7 @@ module internal Tokenizer =
375380 if token.IsOperator then LexerSymbolKind.Operator
376381 elif token.IsIdentifier then LexerSymbolKind.Ident
377382 elif token.IsPunctuation then LexerSymbolKind.Punctuation
383+ elif token.IsString then LexerSymbolKind.String
378384 else LexerSymbolKind.Other
379385 Debug.Assert( uint32 token.Tag < 0xFFFF u)
380386 Debug.Assert( uint32 kind < 0xFF u)
@@ -612,7 +618,8 @@ module internal Tokenizer =
612618 linePos : LinePosition ,
613619 lineStr : string ,
614620 lookupKind : SymbolLookupKind ,
615- wholeActivePatterns : bool
621+ wholeActivePatterns : bool ,
622+ allowStringToken : bool
616623 )
617624 : LexerSymbol option =
618625
@@ -704,6 +711,7 @@ module internal Tokenizer =
704711 | LexerSymbolKind.StaticallyResolvedTypeParameter -> true
705712 | _ -> false )
706713 |> Option.orElseWith ( fun _ -> tokensUnderCursor |> List.tryFind ( fun token -> token.Kind = LexerSymbolKind.Operator))
714+ |> Option.orElseWith ( fun _ -> if allowStringToken then tokensUnderCursor |> List.tryFind ( fun token -> token.Kind = LexerSymbolKind.String) else None)
707715 |> Option.map ( fun token ->
708716 let partialName = QuickParse.GetPartialLongNameEx( lineStr, token.RightColumn)
709717 let identStr = lineStr.Substring( token.LeftColumn, token.MatchedLength)
@@ -767,13 +775,14 @@ module internal Tokenizer =
767775 fileName : string ,
768776 defines : string list ,
769777 lookupKind : SymbolLookupKind ,
770- wholeActivePatterns : bool
778+ wholeActivePatterns : bool ,
779+ allowStringToken : bool
771780 )
772781 : LexerSymbol option =
773782
774783 try
775784 let lineData , textLinePos , lineContents = getCachedSourceLineData( documentKey, sourceText, position, fileName, defines)
776- getSymbolFromSavedTokens( fileName, lineData.SavedTokens, textLinePos, lineContents, lookupKind, wholeActivePatterns)
785+ getSymbolFromSavedTokens( fileName, lineData.SavedTokens, textLinePos, lineContents, lookupKind, wholeActivePatterns, allowStringToken )
777786 with
778787 | :? System.OperationCanceledException -> reraise()
779788 | ex ->
0 commit comments