File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed
PowerShellEditorServices.Protocol/Server
PowerShellEditorServices/Language Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -758,10 +758,13 @@ await CommandHelpers.GetCommandInfo(
758758 completionItem . Label ,
759759 this . editorSession . PowerShellContext ) ;
760760
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+ }
765768 }
766769
767770 // Send back the updated CompletionItem
Original file line number Diff line number Diff line change 33// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44//
55
6+ using Microsoft . PowerShell . EditorServices . Utility ;
7+ using System . Collections . Generic ;
68using System . Linq ;
79using System . Management . Automation ;
810using System . Threading . Tasks ;
@@ -14,6 +16,20 @@ namespace Microsoft.PowerShell.EditorServices
1416 /// </summary>
1517 public class CommandHelpers
1618 {
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+
1733 /// <summary>
1834 /// Gets the CommandInfo instance for a command with a particular name.
1935 /// </summary>
@@ -24,6 +40,18 @@ public static async Task<CommandInfo> GetCommandInfo(
2440 string commandName ,
2541 PowerShellContext powerShellContext )
2642 {
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+
2755 PSCommand command = new PSCommand ( ) ;
2856 command . AddCommand ( @"Microsoft.PowerShell.Core\Get-Command" ) ;
2957 command . AddArgument ( commandName ) ;
You can’t perform that action at this time.
0 commit comments