Skip to content

Long completion tooltips freezes the console for a while #4020

Open
@MartinGC94

Description

@MartinGC94

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

N/A

Environment data

PS Version: 7.5.0-preview.2
PS HostName: ConsoleHost
PSReadLine Version: 2.3.4
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 282
BufferHeight: 9001

Steps to reproduce

  1. Register an argument completer where at least one of the completions has a really long tooltip
  2. Trigger it with menu completion (Ctrl+Space)
  3. Watch the console freeze and CPU usage rise as the long string is processed

Here's an example of this:

Register-ArgumentCompleter -CommandName Get-ChildItem -ParameterName Filter -ScriptBlock {
    [System.Management.Automation.CompletionResult]::new("CompletionText", "ListItem", [System.Management.Automation.CompletionResultType]::ParameterValue, "T$("o" * 1mb)ltip")
    [System.Management.Automation.CompletionResult]::new("OtherRes1", "OtherRes2", [System.Management.Automation.CompletionResultType]::ParameterValue, "OtherRes3")
}
Get-ChildItem -Filter <Ctrl+Space>

If you wait for it to fully load and move the cursor over to the second result and then back it will freeze again.

Obviously this is a silly example but PowerShell can generate really long tooltips in more realistic scenarios. For example if you parse a long script and hover over the scriptblock Ast the tooltip will contain the entire script, so if you've parsed a really big script you will see this freeze.

Expected behavior

No freezes and a truncated tooltip is visible.

Actual behavior

Freeze for several seconds and no tooltip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions