Skip to content

Support tooltip rendering in the prediction list view #3667

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 3 commits into from
May 2, 2023

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented May 2, 2023

PR Summary

Support tooltip rendering in the prediction list view. Fix #3638.

  • By default, the list view can use up to 4 lines for tooltip rendering:

    tooltip1

  • For tooltip that spans more than 4 lines, we allow the user to see the full tooltip in the alternate screen buffer with the keybinding F4

    tooltip2

  • When terminal size shrinks, the maximum lines can be used for tooltip also decreases -- it uses up to 2 lines for tooltip when the max list height is reduced to 5.

    tooltip3

  • When the terminal size is even smaller and the max list view height becomes 3, it uses up to 1 line for tooltip.

    tooltip4

  • You can change the tooltip color by Set-PsreadLineOption -Colors @{ ListPredictionTooltip = "green" }, for example.

    tooltip5

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

@daxian-dbw daxian-dbw requested a review from andyleejordan May 2, 2023 01:16
@daxian-dbw daxian-dbw self-assigned this May 2, 2023
@daxian-dbw daxian-dbw requested a review from StevenBucher98 May 2, 2023 01:17
@StevenBucher98
Copy link
Collaborator

Love the UI! Is there a way to disable the tooltip?

@daxian-dbw
Copy link
Member Author

Same as disabling tooltip in menu completion today: Set-PSReadLineOption -showToolTips:$false

Copy link
Collaborator

@StevenBucher98 StevenBucher98 left a comment

Choose a reason for hiding this comment

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

Can't give a proper code review but the design and UX look great to me!

Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

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

Looks good to me!

{
const int LengthOfLeadingPart = 6;
const string IndicatorSymbol = ">>";
const string MsgForViewAll = "(<F4> to view all)";
Copy link
Member

Choose a reason for hiding this comment

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

Just curious if we do this elsewhere. I suspect that key binding is customizable by the user, but this won't update. Is that the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, the key could already be bound by a user and this message currently won't update in that case.
We don't do this elsewhere -- first time advertising a key-binding in the rendering. Will collect the feedback and see how to best deal with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #3668 to track this.

Copy link
Member

Choose a reason for hiding this comment

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

Nice test.

@daxian-dbw daxian-dbw merged commit ae08ca6 into PowerShell:master May 2, 2023
@daxian-dbw daxian-dbw deleted the tooltip branch May 2, 2023 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support rendering the tooltip in PSReadLine list view
3 participants