Skip to content
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
2 changes: 1 addition & 1 deletion PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
Task SetupHelpForTests {
# TODO: Check if it must be updated in a compatible way!
Write-Host "Updating help for tests."
Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser
Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser -UICulture en-US
}

Task Build FindDotNet, CreateBuildInfo, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ public static async Task<CommandCompletion> GetCompletionsAsync(
CancellationToken cancellationToken)
{
IScriptPosition cursorPosition = s_clonePositionWithNewOffset(scriptAst.Extent.StartScriptPosition, fileOffset);

logger.LogTrace($"Getting completions at offset {fileOffset} (line: {cursorPosition.LineNumber}, column: {cursorPosition.ColumnNumber})");

Stopwatch stopwatch = new();
logger.LogTrace($"Getting completions at offset {fileOffset} (line: {cursorPosition.LineNumber}, column: {cursorPosition.ColumnNumber})");

CommandCompletion commandCompletion = null;
await executionService.ExecuteDelegateAsync(
CommandCompletion commandCompletion = await executionService.ExecuteDelegateAsync(
representation: "CompleteInput",
new ExecutionOptions { Priority = ExecutionPriority.Next },
(pwsh, _) =>
Expand All @@ -108,35 +105,41 @@ await executionService.ExecuteDelegateAsync(

if (completionResults is { Count: > 0 })
{
commandCompletion = completionResults[0];
return completionResults[0];
}

return;
return null;
}

// If the current runspace is out of process, we can't call TabExpansion2
// because the output will be serialized.
commandCompletion = CommandCompletion.CompleteInput(
return CommandCompletion.CompleteInput(
scriptAst,
currentTokens,
cursorPosition,
options: null,
powershell: pwsh);
},
cancellationToken)
.ConfigureAwait(false);
cancellationToken).ConfigureAwait(false);

stopwatch.Stop();
logger.LogTrace(
"IntelliSense completed in {elapsed}ms - WordToComplete: \"{word}\" MatchCount: {count}",
stopwatch.ElapsedMilliseconds,
commandCompletion.ReplacementLength > 0
? scriptAst.Extent.StartScriptPosition.GetFullScript()?.Substring(
commandCompletion.ReplacementIndex,
commandCompletion.ReplacementLength)
: null,
commandCompletion.CompletionMatches.Count);

if (commandCompletion is null)
{
logger.LogError("Error Occurred in TabExpansion2");
}
else
{
logger.LogTrace(
"IntelliSense completed in {elapsed}ms - WordToComplete: \"{word}\" MatchCount: {count}",
stopwatch.ElapsedMilliseconds,
commandCompletion.ReplacementLength > 0
? scriptAst.Extent.StartScriptPosition.GetFullScript()?.Substring(
commandCompletion.ReplacementIndex,
commandCompletion.ReplacementLength)
: null,
commandCompletion.CompletionMatches.Count);
}
return commandCompletion;
}

Expand Down