From cdea6f1683ab3eab84894bdddd1a90f0b324ff76 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 24 Apr 2020 11:36:56 -0700 Subject: [PATCH 1/3] more vscode-notebook --- .../Services/TextDocument/ScriptFile.cs | 2 +- .../Services/Workspace/WorkspaceService.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs index 8a40b04e7..c690ef4f3 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs @@ -218,7 +218,7 @@ internal static bool IsUntitledPath(string path) { Validate.IsNotNull(nameof(path), path); - return path.ToLower().StartsWith("untitled:"); + return path.ToLower().StartsWith("untitled:") || path.StartsWith("vscode-notebook:"); } /// diff --git a/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs b/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs index 44f8b8820..c07d0c831 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": break; default: From 8671d341647846c04fb73f265e0ef09442193ae1 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 8 Jun 2020 10:39:42 -0700 Subject: [PATCH 2/3] no more extra codelenses --- .../Services/CodeLens/ReferencesCodeLensProvider.cs | 11 ++++++++++- .../Services/TextDocument/ScriptFile.cs | 3 +-- .../Services/Workspace/WorkspaceService.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index 50bac22ad..07cbcf10f 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 (scriptFile.DocumentUri.Scheme == "vscode-notebook-cell" && + uri.Path == scriptFile.DocumentUri.Path && + uri.Scheme == "file") + { + 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 c690ef4f3..0cdfaac02 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs @@ -217,8 +217,7 @@ internal static List GetLinesInternal(string text) internal static bool IsUntitledPath(string path) { Validate.IsNotNull(nameof(path), path); - - return path.ToLower().StartsWith("untitled:") || path.StartsWith("vscode-notebook:"); + return DocumentUri.From(path).Scheme.ToLower() != Uri.UriSchemeFile; } /// diff --git a/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs b/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs index c07d0c831..b9fa7f018 100644 --- a/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs +++ b/src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs @@ -195,7 +195,7 @@ public bool TryGetFile(DocumentUri documentUri, out ScriptFile scriptFile) // List supported schemes here case "file": case "untitled": - case "vscode-notebook": + case "vscode-notebook-cell": break; default: From 5045b8dcc69d411cf8ef8d7d42fd80d881e5f5ed Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 1 Jul 2020 17:34:13 -0700 Subject: [PATCH 3/3] rob's feedback --- .../Services/CodeLens/ReferencesCodeLensProvider.cs | 6 +++--- .../Services/TextDocument/ScriptFile.cs | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index 07cbcf10f..f630c7979 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs @@ -115,9 +115,9 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) DocumentUri uri = DocumentUri.From(foundReference.FilePath); // For any vscode-notebook-cell, we need to ignore the backing file on disk. - if (scriptFile.DocumentUri.Scheme == "vscode-notebook-cell" && - uri.Path == scriptFile.DocumentUri.Path && - uri.Scheme == "file") + if (uri.Scheme == "file" && + scriptFile.DocumentUri.Scheme == "vscode-notebook-cell" && + uri.Path == scriptFile.DocumentUri.Path) { continue; } diff --git a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs index 0cdfaac02..6f65dd629 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs @@ -217,7 +217,10 @@ internal static List GetLinesInternal(string text) internal static bool IsUntitledPath(string path) { Validate.IsNotNull(nameof(path), path); - return DocumentUri.From(path).Scheme.ToLower() != Uri.UriSchemeFile; + return string.Equals( + DocumentUri.From(path).Scheme, + Uri.UriSchemeFile, + StringComparison.OrdinalIgnoreCase); } ///