Skip to content

Commit a878a99

Browse files
authored
Merge pull request #341 from PowerShell/daviwil/fix-vsc-390-408
Minor 0.9.0 fixes
2 parents 1b77d3e + 8f82095 commit a878a99

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/Diagnostics.cs

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class Diagnostic
7171
/// Gets or sets the diagnostic message.
7272
/// </summary>
7373
public string Message { get; set; }
74+
75+
/// <summary>
76+
/// Gets or sets the source of the diagnostic message.
77+
/// </summary>
78+
public string Source { get; set; }
7479
}
7580
}
7681

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.Server
2727
public class LanguageServer : LanguageServerBase
2828
{
2929
private static CancellationTokenSource existingRequestCancellation;
30+
private readonly static string DiagnosticSourceName = "PowerShellEditorServices";
3031

3132
private bool profilesLoaded;
3233
private EditorSession editorSession;
@@ -994,7 +995,9 @@ protected async Task HandleCodeActionRequest(
994995
{
995996
foreach (var diagnostic in codeActionParams.Context.Diagnostics)
996997
{
997-
if (markerIndex.TryGetValue(diagnostic.Code, out correction))
998+
if (string.Equals(diagnostic.Source, DiagnosticSourceName, StringComparison.CurrentCultureIgnoreCase) &&
999+
!string.IsNullOrEmpty(diagnostic.Code) &&
1000+
markerIndex.TryGetValue(diagnostic.Code, out correction))
9981001
{
9991002
codeActionCommands.Add(
10001003
new CodeActionCommand
@@ -1333,9 +1336,9 @@ private static Diagnostic GetDiagnosticFromMarker(ScriptFileMarker scriptFileMar
13331336
Severity = MapDiagnosticSeverity(scriptFileMarker.Level),
13341337
Message = scriptFileMarker.Message,
13351338
Code = Guid.NewGuid().ToString(),
1339+
Source = DiagnosticSourceName,
13361340
Range = new Range
13371341
{
1338-
// TODO: What offsets should I use?
13391342
Start = new Position
13401343
{
13411344
Line = scriptFileMarker.ScriptRegion.StartLineNumber - 1,

src/PowerShellEditorServices/Workspace/Workspace.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,15 @@ internal static bool IsPathInMemory(string filePath)
301301
// When viewing PowerShell files in the Git diff viewer, VS Code
302302
// sends the contents of the file at HEAD with a URI that starts
303303
// with 'inmemory'. Untitled files which have been marked of
304-
// type PowerShell have a path starting with 'untitled'. Files
305-
// opened from the find/replace view will be prefixed with
306-
// 'private'.
304+
// type PowerShell have a path starting with 'untitled'.
307305
return
308306
filePath.StartsWith("inmemory") ||
309307
filePath.StartsWith("untitled") ||
310-
filePath.StartsWith("private");
308+
filePath.StartsWith("private") ||
309+
filePath.StartsWith("git");
310+
311+
// TODO #342: Remove 'private' and 'git' and then add logic to
312+
// throw when any unsupported file URI scheme is encountered.
311313
}
312314

313315
private string GetBaseFilePath(string filePath)

0 commit comments

Comments
 (0)