Skip to content

Fix diagnostics not showing in untitled files and now also show CodeLens #1098

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
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 @@ -867,19 +867,11 @@ private void PublishScriptDiagnostics(
fileLock.Release();
}


var uriBuilder = new UriBuilder
{
Scheme = Uri.UriSchemeFile,
Path = scriptFile.FilePath,
Host = string.Empty,
};

// Always send syntax and semantic errors. We want to
// make sure no out-of-date markers are being displayed.
_languageServer.Document.PublishDiagnostics(new PublishDiagnosticsParams()
{
Uri = uriBuilder.Uri,
Uri = new Uri(scriptFile.DocumentUri),
Diagnostics = new Container<Diagnostic>(diagnostics),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ public class ScriptDocumentSymbolProvider : IDocumentSymbolProvider
IEnumerable<SymbolReference> IDocumentSymbolProvider.ProvideDocumentSymbols(
ScriptFile scriptFile)
{
if (scriptFile != null &&
scriptFile.FilePath != null &&
(scriptFile.FilePath.EndsWith(".ps1", StringComparison.OrdinalIgnoreCase) ||
scriptFile.FilePath.EndsWith(".psm1", StringComparison.OrdinalIgnoreCase)))
{
return FindSymbolsInDocument(scriptFile.ScriptAst);
}

return Enumerable.Empty<SymbolReference>();
// If we have an AST, then we know it's a PowerShell file
// so lets try to find symbols in the document.
return scriptFile?.ScriptAst != null
? FindSymbolsInDocument(scriptFile.ScriptAst)
: Enumerable.Empty<SymbolReference>();
}

/// <summary>
Expand Down