File tree 2 files changed +35
-4
lines changed
PowerShellEditorServices/Language
PowerShellEditorServices.Protocol/Server
2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -758,10 +758,13 @@ await CommandHelpers.GetCommandInfo(
758
758
completionItem . Label ,
759
759
this . editorSession . PowerShellContext ) ;
760
760
761
- completionItem . Documentation =
762
- await CommandHelpers . GetCommandSynopsis (
763
- commandInfo ,
764
- this . editorSession . PowerShellContext ) ;
761
+ if ( commandInfo != null )
762
+ {
763
+ completionItem . Documentation =
764
+ await CommandHelpers . GetCommandSynopsis (
765
+ commandInfo ,
766
+ this . editorSession . PowerShellContext ) ;
767
+ }
765
768
}
766
769
767
770
// Send back the updated CompletionItem
Original file line number Diff line number Diff line change 3
3
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
4
//
5
5
6
+ using Microsoft . PowerShell . EditorServices . Utility ;
7
+ using System . Collections . Generic ;
6
8
using System . Linq ;
7
9
using System . Management . Automation ;
8
10
using System . Threading . Tasks ;
@@ -14,6 +16,20 @@ namespace Microsoft.PowerShell.EditorServices
14
16
/// </summary>
15
17
public class CommandHelpers
16
18
{
19
+ private static HashSet < string > NounBlackList =
20
+ new HashSet < string >
21
+ {
22
+ "Module" ,
23
+ "Script" ,
24
+ "Package" ,
25
+ "PackageProvider" ,
26
+ "PackageSource" ,
27
+ "InstalledModule" ,
28
+ "InstalledScript" ,
29
+ "ScriptFileInfo" ,
30
+ "PSRepository"
31
+ } ;
32
+
17
33
/// <summary>
18
34
/// Gets the CommandInfo instance for a command with a particular name.
19
35
/// </summary>
@@ -24,6 +40,18 @@ public static async Task<CommandInfo> GetCommandInfo(
24
40
string commandName ,
25
41
PowerShellContext powerShellContext )
26
42
{
43
+ Validate . IsNotNull ( nameof ( commandName ) , commandName ) ;
44
+
45
+ // Make sure the command's noun isn't blacklisted. This is
46
+ // currently necessary to make sure that Get-Command doesn't
47
+ // load PackageManagement or PowerShellGet because they cause
48
+ // a major slowdown in IntelliSense.
49
+ var commandParts = commandName . Split ( '-' ) ;
50
+ if ( commandParts . Length == 2 && NounBlackList . Contains ( commandParts [ 1 ] ) )
51
+ {
52
+ return null ;
53
+ }
54
+
27
55
PSCommand command = new PSCommand ( ) ;
28
56
command . AddCommand ( @"Microsoft.PowerShell.Core\Get-Command" ) ;
29
57
command . AddArgument ( commandName ) ;
You can’t perform that action at this time.
0 commit comments