Skip to content

Temporarily mitigate intermittent IntelliSense slowness #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2017
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
11 changes: 7 additions & 4 deletions src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,13 @@ await CommandHelpers.GetCommandInfo(
completionItem.Label,
this.editorSession.PowerShellContext);

completionItem.Documentation =
await CommandHelpers.GetCommandSynopsis(
commandInfo,
this.editorSession.PowerShellContext);
if (commandInfo != null)
{
completionItem.Documentation =
await CommandHelpers.GetCommandSynopsis(
commandInfo,
this.editorSession.PowerShellContext);
}
}

// Send back the updated CompletionItem
Expand Down
28 changes: 28 additions & 0 deletions src/PowerShellEditorServices/Language/CommandHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Utility;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
Expand All @@ -14,6 +16,20 @@ namespace Microsoft.PowerShell.EditorServices
/// </summary>
public class CommandHelpers
{
private static HashSet<string> NounBlackList =
new HashSet<string>
{
"Module",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we won't get info for Import-Module? That is a pretty commonly used command. The rest, less so. But if it is temporary, then let's try it and see if folks complain about missing info for these nouns.

I wonder if it would be worth returning some static text for these nouns like "Intellisense for this noun disabled due to perf issue, will be fixed in the future." or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not worth the extra effort at the moment, I imagine many people won't even notice it. If people do notice and complain, I'll definitely find a way to make it a bit more obvious what's going on.

"Script",
"Package",
"PackageProvider",
"PackageSource",
"InstalledModule",
"InstalledScript",
"ScriptFileInfo",
"PSRepository"
};

/// <summary>
/// Gets the CommandInfo instance for a command with a particular name.
/// </summary>
Expand All @@ -24,6 +40,18 @@ public static async Task<CommandInfo> GetCommandInfo(
string commandName,
PowerShellContext powerShellContext)
{
Validate.IsNotNull(nameof(commandName), commandName);

// Make sure the command's noun isn't blacklisted. This is
// currently necessary to make sure that Get-Command doesn't
// load PackageManagement or PowerShellGet because they cause
// a major slowdown in IntelliSense.
var commandParts = commandName.Split('-');
if (commandParts.Length == 2 && NounBlackList.Contains(commandParts[1]))
{
return null;
}

PSCommand command = new PSCommand();
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Command");
command.AddArgument(commandName);
Expand Down