Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/FsAutoComplete.Core/ParseAndCheckResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ type ParseAndCheckResults
let logger = LogProvider.getLoggerByName "ParseAndCheckResults"

let getFileName (loc: range) =
if Ionide.ProjInfo.ProjectSystem.Environment.isWindows then
UMX.tag<NormalizedRepoPathSegment> loc.FileName
else
UMX.tag<NormalizedRepoPathSegment> (Path.GetFileName loc.FileName)
// Keep the full FCS path, just normalize backslashes to forward slashes.
// FCS may prepend a workspace prefix if the PDB path isn't absolute on this platform.
// The comparison in Sourcelink.compareRepoPath will handle the prefix via suffix matching.
let normalized = loc.FileName.Replace('\\', '/')
UMX.tag<NormalizedRepoPathSegment> normalized

member __.TryFindDeclaration (pos: Position) (lineStr: LineStr) =
async {
Expand Down
46 changes: 36 additions & 10 deletions src/FsAutoComplete.Core/Sourcelink.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,42 @@ type private Document =
Language: System.Guid
IsEmbedded: bool }

let private compareRepoPath (d: Document) targetFile =
if Environment.isWindows then
let s = UMX.untag d.Name
let s' = normalizePath s |> UMX.untag
let s' = UMX.tag<NormalizedRepoPathSegment> s'
s' = targetFile
else
let t = UMX.untag targetFile |> UMX.tag<RepoPathSegment>
let t' = normalizeRepoPath t
normalizeRepoPath d.Name = t'
let private compareRepoPath (d: Document) fcsPath =
// The fcsPath is the full path from FCS (normalized, backslashes converted to forward slashes).
// FCS may prepend a workspace prefix if the PDB path wasn't absolute on this platform.
// The d.Name is a PDB document entry (the original path from when the DLL was compiled).
//
// The PDB document should be a SUFFIX of (or equal to) the FCS path:
// - FCS path: /workspaces/project/D:/a/_work/1/s/src/FSharp.Core/list.fs
// - PDB doc: D:/a/_work/1/s/src/FSharp.Core/list.fs
// → fcsPath.EndsWith("/" + pdbDoc) = true
//
// - FCS path: /__w/1/s/src/fsharp/src/FSharp.Core/list.fs
// - PDB doc: /__w/1/s/src/fsharp/src/FSharp.Core/list.fs
// → fcsPath == pdbDoc = true

let docNormalized: string<NormalizedRepoPathSegment> =
if Environment.isWindows then
let s = UMX.untag d.Name
let normalized = normalizePath s |> UMX.untag
UMX.tag<NormalizedRepoPathSegment> normalized
else
normalizeRepoPath d.Name

let fcsNormalized: string<NormalizedRepoPathSegment> =
if Environment.isWindows then
fcsPath
else
let t: string = UMX.untag fcsPath
let tagged: string<RepoPathSegment> = UMX.tag<RepoPathSegment> t
normalizeRepoPath tagged

let docStr = UMX.untag docNormalized
let fcsStr = UMX.untag fcsNormalized

// PDB doc should be suffix of (or equal to) FCS path
fcsStr = docStr
|| fcsStr.EndsWith("/" + docStr, System.StringComparison.Ordinal)

let private pdbForDll (dllPath: string<LocalPath>) =
UMX.tag<LocalPath> (Path.ChangeExtension(UMX.untag dllPath, ".pdb"))
Expand Down