Long completion tooltips freezes the console for a while

Open
#4,020 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp, powershell
Domain
cli

Research direction

Reproduce the issue with Register-ArgumentCompleter and menu completion via Ctrl+Space, using the long-tooltip example in the report. Trace the completion tooltip handling and verify that long tooltips are truncated, the console remains responsive, and the second completion can be selected without another freeze.

Written by the indexing model from the issue text.

Description

Needs-Triage :mag:
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.

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.