Skip to content

Minor 0.9.0 fixes #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public class Diagnostic
/// Gets or sets the diagnostic message.
/// </summary>
public string Message { get; set; }

/// <summary>
/// Gets or sets the source of the diagnostic message.
/// </summary>
public string Source { get; set; }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.Server
public class LanguageServer : LanguageServerBase
{
private static CancellationTokenSource existingRequestCancellation;
private readonly static string DiagnosticSourceName = "PowerShellEditorServices";

private bool profilesLoaded;
private EditorSession editorSession;
Expand Down Expand Up @@ -994,7 +995,9 @@ protected async Task HandleCodeActionRequest(
{
foreach (var diagnostic in codeActionParams.Context.Diagnostics)
{
if (markerIndex.TryGetValue(diagnostic.Code, out correction))
if (string.Equals(diagnostic.Source, DiagnosticSourceName, StringComparison.CurrentCultureIgnoreCase) &&
!string.IsNullOrEmpty(diagnostic.Code) &&
markerIndex.TryGetValue(diagnostic.Code, out correction))
{
codeActionCommands.Add(
new CodeActionCommand
Expand Down Expand Up @@ -1335,9 +1338,9 @@ private static Diagnostic GetDiagnosticFromMarker(ScriptFileMarker scriptFileMar
Severity = MapDiagnosticSeverity(scriptFileMarker.Level),
Message = scriptFileMarker.Message,
Code = Guid.NewGuid().ToString(),
Source = DiagnosticSourceName,
Range = new Range
{
// TODO: What offsets should I use?
Start = new Position
{
Line = scriptFileMarker.ScriptRegion.StartLineNumber - 1,
Expand Down
10 changes: 6 additions & 4 deletions src/PowerShellEditorServices/Workspace/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ internal static bool IsPathInMemory(string filePath)
// When viewing PowerShell files in the Git diff viewer, VS Code
// sends the contents of the file at HEAD with a URI that starts
// with 'inmemory'. Untitled files which have been marked of
// type PowerShell have a path starting with 'untitled'. Files
// opened from the find/replace view will be prefixed with
// 'private'.
// type PowerShell have a path starting with 'untitled'.
return
filePath.StartsWith("inmemory") ||
filePath.StartsWith("untitled") ||
filePath.StartsWith("private");
filePath.StartsWith("private") ||
filePath.StartsWith("git");

// TODO #342: Remove 'private' and 'git' and then add logic to
// throw when any unsupported file URI scheme is encountered.
}

private string GetBaseFilePath(string filePath)
Expand Down