Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/PowerShellEditorServices/Extensions/EditorObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public EditorContext GetEditorContext()
internal void SetAsStaticInstance()
{
EditorObject.Instance = this;
s_editorObjectReady.SetResult(true);
s_editorObjectReady.TrySetResult(true);
}
}
}
18 changes: 12 additions & 6 deletions src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal static string GetUniqueIdFromDiagnostic(Diagnostic diagnostic)

private readonly ConfigurationService _configurationService;

private readonly WorkspaceService _workplaceService;
private readonly WorkspaceService _workspaceService;

private readonly int _analysisDelayMillis;

Expand Down Expand Up @@ -115,7 +115,7 @@ public AnalysisService(
_logger = loggerFactory.CreateLogger<AnalysisService>();
_languageServer = languageServer;
_configurationService = configurationService;
_workplaceService = workspaceService;
_workspaceService = workspaceService;
_analysisDelayMillis = 750;
_mostRecentCorrectionsByFile = new ConcurrentDictionary<ScriptFile, CorrectionTableEntry>();
_analysisEngineLazy = new Lazy<PssaCmdletAnalysisEngine>(InstantiateAnalysisEngine);
Expand Down Expand Up @@ -223,9 +223,15 @@ public async Task<string> GetCommentHelpText(string functionText, string helpLoc
/// </summary>
/// <param name="documentUri">The URI string of the file to get code actions for.</param>
/// <returns>A threadsafe readonly dictionary of the code actions of the particular file.</returns>
public async Task<IReadOnlyDictionary<string, MarkerCorrection>> GetMostRecentCodeActionsForFileAsync(ScriptFile scriptFile)
public async Task<IReadOnlyDictionary<string, MarkerCorrection>> GetMostRecentCodeActionsForFileAsync(DocumentUri uri)
{
if (!_mostRecentCorrectionsByFile.TryGetValue(scriptFile, out CorrectionTableEntry corrections))
ScriptFile file = null;
if (!_workspaceService.TryGetFile(uri, out file))
{
return null;
}

if (!_mostRecentCorrectionsByFile.TryGetValue(file, out CorrectionTableEntry corrections))
{
return null;
}
Expand Down Expand Up @@ -334,7 +340,7 @@ private bool TryFindSettingsFile(out string settingsFilePath)
return false;
}

settingsFilePath = _workplaceService.ResolveWorkspacePath(configuredPath);
settingsFilePath = _workspaceService.ResolveWorkspacePath(configuredPath);

if (settingsFilePath == null
|| !File.Exists(settingsFilePath))
Expand All @@ -349,7 +355,7 @@ private bool TryFindSettingsFile(out string settingsFilePath)

private void ClearOpenFileMarkers()
{
foreach (ScriptFile file in _workplaceService.GetOpenedFiles())
foreach (ScriptFile file in _workspaceService.GetOpenedFiles())
{
ClearMarkers(file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams
{
if (cancellationToken.IsCancellationRequested)
{
_logger.LogDebug("CodeAction request canceled at range: {0}", request.Range);
_logger.LogDebug($"CodeAction request canceled at range: {request.Range}");
return Array.Empty<CommandOrCodeAction>();
}

// On Windows, VSCode still gives us file URIs like "file:///c%3a/...", so we need to escape them
IReadOnlyDictionary<string, MarkerCorrection> corrections = await _analysisService.GetMostRecentCodeActionsForFileAsync(
_workspaceService.GetFile(request.TextDocument.Uri)).ConfigureAwait(false);
IReadOnlyDictionary<string, MarkerCorrection> corrections = await
_analysisService.GetMostRecentCodeActionsForFileAsync(request.TextDocument.Uri).ConfigureAwait(false);

if (corrections == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ await _powerShellContextService.SetWorkingDirectoryAsync(
private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingSettings)
{
var configChanges = new Dictionary<string, bool>();
if (incomingSettings == null)
{
this._logger.LogTrace("Incoming settings were null");
return;
}

// Send telemetry if the user opted-out of ScriptAnalysis
if (incomingSettings.Powershell.ScriptAnalysis.Enable == false &&
_configurationService.CurrentSettings.ScriptAnalysis.Enable != incomingSettings.Powershell.ScriptAnalysis.Enable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public bool TryGetFile(DocumentUri documentUri, out ScriptFile scriptFile)
{
// List supported schemes here
case "file":
case "inmemory":
case "untitled":
case "vscode-notebook-cell":
break;
Expand Down