diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index 50bac22ad..f630c7979 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs @@ -113,9 +113,18 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) continue; } + DocumentUri uri = DocumentUri.From(foundReference.FilePath); + // For any vscode-notebook-cell, we need to ignore the backing file on disk. + if (uri.Scheme == "file" && + scriptFile.DocumentUri.Scheme == "vscode-notebook-cell" && + uri.Path == scriptFile.DocumentUri.Path) + { + continue; + } + acc.Add(new Location { - Uri = DocumentUri.From(foundReference.FilePath), + Uri = uri, Range = foundReference.ScriptRegion.ToRange() }); } diff --git a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs index 8a40b04e7..6f65dd629 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs @@ -217,8 +217,10 @@ internal static List GetLinesInternal(string text) internal static bool IsUntitledPath(string path) { Validate.IsNotNull(nameof(path), path); - - return path.ToLower().StartsWith("untitled:"); + return string.Equals( + DocumentUri.From(path).Scheme, + Uri.UriSchemeFile, + StringComparison.OrdinalIgnoreCase); } /// diff --git a/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs b/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs index 44f8b8820..b9fa7f018 100644 --- a/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs +++ b/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs @@ -195,6 +195,7 @@ public bool TryGetFile(DocumentUri documentUri, out ScriptFile scriptFile) // List supported schemes here case "file": case "untitled": + case "vscode-notebook-cell": break; default: