diff --git a/src/PowerShellEditorServices/Language/AstOperations.cs b/src/PowerShellEditorServices/Language/AstOperations.cs index 4bbe50176..aa27bead4 100644 --- a/src/PowerShellEditorServices/Language/AstOperations.cs +++ b/src/PowerShellEditorServices/Language/AstOperations.cs @@ -13,6 +13,7 @@ namespace Microsoft.PowerShell.EditorServices { + using System.Diagnostics; using System.Management.Automation; using System.Management.Automation.Language; using System.Management.Automation.Runspaces; @@ -101,6 +102,9 @@ static public async Task GetCompletions( { powerShell.Runspace = runspaceHandle.Runspace; + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + commandCompletion = CommandCompletion.CompleteInput( scriptAst, @@ -108,6 +112,10 @@ static public async Task GetCompletions( cursorPosition, null, powerShell); + + stopwatch.Stop(); + + Logger.Write(LogLevel.Verbose, $"IntelliSense completed in {stopwatch.ElapsedMilliseconds}ms."); } } diff --git a/src/PowerShellEditorServices/Language/CommandHelpers.cs b/src/PowerShellEditorServices/Language/CommandHelpers.cs index 527fc3ac8..82002ba17 100644 --- a/src/PowerShellEditorServices/Language/CommandHelpers.cs +++ b/src/PowerShellEditorServices/Language/CommandHelpers.cs @@ -21,12 +21,13 @@ public class CommandHelpers /// The PowerShellContext to use for running Get-Command. /// A CommandInfo object with details about the specified command. public static async Task GetCommandInfo( - string commandName, + string commandName, PowerShellContext powerShellContext) { PSCommand command = new PSCommand(); command.AddCommand(@"Microsoft.PowerShell.Core\Get-Command"); command.AddArgument(commandName); + command.AddParameter("ErrorAction", "Ignore"); return (await powerShellContext @@ -43,7 +44,7 @@ public static async Task GetCommandInfo( /// The PowerShellContext to use for getting command documentation. /// public static async Task GetCommandSynopsis( - CommandInfo commandInfo, + CommandInfo commandInfo, PowerShellContext powerShellContext) { string synopsisString = string.Empty; @@ -58,6 +59,7 @@ public static async Task GetCommandSynopsis( PSCommand command = new PSCommand(); command.AddCommand(@"Microsoft.PowerShell.Core\Get-Help"); command.AddArgument(commandInfo); + command.AddParameter("ErrorAction", "Ignore"); var results = await powerShellContext.ExecuteCommand(command, false, false); helpObject = results.FirstOrDefault();