diff --git a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs index ea2b41ca3d0..f70a6bbdb25 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs @@ -361,7 +361,7 @@ module internal Tokenizer = type FSharpTokenInfo with member token.IsIdentifier = (token.CharClass = FSharpTokenCharKind.Identifier) - member token.IsOperator = (token.ColorClass = FSharpTokenColorKind.Operator) + member token.IsOperator = (token.CharClass = FSharpTokenCharKind.Operator) member token.IsPunctuation = (token.ColorClass = FSharpTokenColorKind.Punctuation) member token.IsString = (token.ColorClass = FSharpTokenColorKind.String) member token.IsComment = (token.ColorClass = FSharpTokenColorKind.Comment) diff --git a/vsintegration/tests/FSharp.Editor.Tests/FindReferencesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/FindReferencesTests.fs index 50c9d7fbf7c..7f3d4d0e804 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/FindReferencesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/FindReferencesTests.fs @@ -129,3 +129,44 @@ module FindReferences = foundReferences.Count <> 2 // One in signature file, one in Third file then failwith $"Expected 2 references but found {foundReferences.Count}" + + [] + [=>")>] + [++")>] + let ``Find references to operators start with >`` operator = + + let project2 = + SyntheticProject.Create( + { sourceFile "First" [] with + SignatureFile = No + ExtraSource = + "let compose x = fun y -> x - y\n" + + $"let ({operator}) = compose\n" + + $"let test t = t {operator} 5\n" + }, + { sourceFile "Second" [ "First" ] with + ExtraSource = "open ModuleFirst\n" + $"let z = 4 {operator} 5\n" + } + ) + + let solution2, _ = RoslynTestHelpers.CreateSolution project2 + + let context, foundDefinitions, foundReferences = getContext () + + let documentPath = project2.GetFilePath "Second" + + let document = + solution2.TryGetDocumentFromPath documentPath + |> Option.defaultWith (fun _ -> failwith "Document not found") + + findUsagesService + .FindReferencesAsync(document, getPositionOf operator documentPath, context) + .Wait() + + // We cannot easily inspect what exactly was found here, but that should be verified + // in FSharp.Compiler.ComponentTests.FSharpChecker.FindReferences + if foundDefinitions.Count <> 1 then + failwith $"Expected 1 definition but found {foundDefinitions.Count}" + + if foundReferences.Count <> 2 then + failwith $"Expected 2 reference but found {foundReferences.Count}"