Skip to content

Commit 6ea524e

Browse files
authored
Merge pull request #421 from daviwil/fix-416
Fix #416 and #419
2 parents 5ad22be + 2541170 commit 6ea524e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/PowerShellEditorServices/Language/AstOperations.cs

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Microsoft.PowerShell.EditorServices
1515
{
16+
using System.Diagnostics;
1617
using System.Management.Automation;
1718
using System.Management.Automation.Language;
1819
using System.Management.Automation.Runspaces;
@@ -101,13 +102,20 @@ static public async Task<CommandCompletion> GetCompletions(
101102
{
102103
powerShell.Runspace = runspaceHandle.Runspace;
103104

105+
Stopwatch stopwatch = new Stopwatch();
106+
stopwatch.Start();
107+
104108
commandCompletion =
105109
CommandCompletion.CompleteInput(
106110
scriptAst,
107111
currentTokens,
108112
cursorPosition,
109113
null,
110114
powerShell);
115+
116+
stopwatch.Stop();
117+
118+
Logger.Write(LogLevel.Verbose, $"IntelliSense completed in {stopwatch.ElapsedMilliseconds}ms.");
111119
}
112120
}
113121

src/PowerShellEditorServices/Language/CommandHelpers.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public class CommandHelpers
2121
/// <param name="powerShellContext">The PowerShellContext to use for running Get-Command.</param>
2222
/// <returns>A CommandInfo object with details about the specified command.</returns>
2323
public static async Task<CommandInfo> GetCommandInfo(
24-
string commandName,
24+
string commandName,
2525
PowerShellContext powerShellContext)
2626
{
2727
PSCommand command = new PSCommand();
2828
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Command");
2929
command.AddArgument(commandName);
30+
command.AddParameter("ErrorAction", "Ignore");
3031

3132
return
3233
(await powerShellContext
@@ -43,7 +44,7 @@ public static async Task<CommandInfo> GetCommandInfo(
4344
/// <param name="powerShellContext">The PowerShellContext to use for getting command documentation.</param>
4445
/// <returns></returns>
4546
public static async Task<string> GetCommandSynopsis(
46-
CommandInfo commandInfo,
47+
CommandInfo commandInfo,
4748
PowerShellContext powerShellContext)
4849
{
4950
string synopsisString = string.Empty;
@@ -58,6 +59,7 @@ public static async Task<string> GetCommandSynopsis(
5859
PSCommand command = new PSCommand();
5960
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Help");
6061
command.AddArgument(commandInfo);
62+
command.AddParameter("ErrorAction", "Ignore");
6163

6264
var results = await powerShellContext.ExecuteCommand<PSObject>(command, false, false);
6365
helpObject = results.FirstOrDefault();

0 commit comments

Comments
 (0)