Skip to content

Commit 8f8c79f

Browse files
xperiandriclaude
andcommitted
Recognise a mapped name as the file a document holds
Finding the document a range names got the caret to the right file, and then the search for the declaration inside it compared the range's file name to the document's path with `=`. Under a path map the first is relative to a root the assembly never records and the second is absolute, so they never match: the search fell through to a full check of the file, looking for uses of a symbol that belongs to another compilation, and came back with nothing. Both places now go through one rule, `isTheFileAt`, rather than two spellings of it, so a name a path map left relative is matched by its tail wherever a file is identified. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 8075288 commit 8f8c79f

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
355355
let! ct = Async.CancellationToken |> liftAsync
356356

357357
match targetSymbolUse.Symbol.DeclarationLocation with
358-
| Some decl when decl.FileName = filePath -> return decl
358+
| Some decl when decl.FileName |> isTheFileAt filePath -> return decl
359359
| _ ->
360360
let! _, checkFileResults =
361361
document.GetFSharpParseAndCheckResultsAsync("FindSymbolDeclarationInDocument")

‎vsintegration/tests/FSharp.Editor.Tests/PathMapNavigationTests.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ let ``goto definition into a project built with a path map reaches its source``
6666
| ValueSome(FSharpGoToDefinitionResult.NavigableItem item, _) -> Assert.Equal(library.GetFilePath "Library", item.Document.FilePath)
6767
| result -> failwith $"expected a navigable item, got %A{result}"
6868

69+
/// The one rule the document lookup and the search for a declaration inside a document both go through.
6970
/// A mapped name arrives with the separator its replacement doubled (`.\` + `\rest`), which is what the
7071
/// compiler writes and what a build on a path map hands back.
7172
[<Theory>]

0 commit comments

Comments
 (0)