Skip to content
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

Improve the list view to be scrollable and auto-adjust the list view height #3583

Merged
merged 7 commits into from Feb 27, 2023

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Feb 17, 2023

PR Summary

Fix #3563
Improve the list view to be scrollable and auto-adjust the list view height.

  • Now the list view is scrollable. It can display up to 50 items.
  • The max list view height is still 10, but the list view height can auto-adjust based on the terminal height: the max height changes to 5 when the terminal height is <=20, and then changes to 3 when the terminal height is <= 10.
  • A metadata line is added to show extra information for the list view.
  • When the terminal size is too small to show the list view, it prints a warning message to inform the user about it.
  • The key-bindings PageUp and PageDown can navigate within the list view by moving up/down a page.
  • The key-bindings Ctrl+PageUp and Ctrl+PageUp can navigate within the list view by jumping to the previous/next source.

The scrollable list view:

scrollable

The auto-adjustable list view height:

auto-adjust

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 marked this pull request as ready for review February 17, 2023 00:13
@daxian-dbw daxian-dbw self-assigned this Feb 17, 2023
@SteveL-MSFT SteveL-MSFT reopened this Feb 17, 2023
private void RenderWarningLine(StringBuilder buffer)
{
// Add italic text effect to the highlight color.
string highlightColor = _singleton._options._listPredictionColor + "\x1b[3m";
Copy link
Member

Choose a reason for hiding this comment

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

The use of italics should just be part of the configurable prediction highlight instead of always being added. Some users may prefer bold, for example. So this should be highlightStyle and not highlightColor

Copy link
Member Author

Choose a reason for hiding this comment

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

About the new colors and styles, there are a few of them:

  • un-highlighted texts in the metadata line
  • highlighted text in the metadata line
  • warning message

Currently,

  • the un-highlighted text uses the default inline view color/style;
  • the highlighted text uses the ListPredictionColor plus italics;
  • the warning message uses the ListPredictionColor plus italics;

I'm not sure about what to expose for configuration yet. It doesn't feel needed to expose them all in my opinion. The following are my thoughts:

  1. always apply italics to the text rendered in the metadata line, and use the ListPredictionColor as the user-configurable highlighting color/style.
  2. maybe expose configuration for un-highlighted text color/style, but I'm not super sure if it's really needed.
  3. warning message in this case will be uncommon for users to see because it will usually happen when the terminal height is very small (<5). So, exposing a configuration for it seems overkill to me.

I don't have a clear idea what/how to make configurable about the new color/styles at the moment, so I prefer to wait and collect some feedback about this, which hopefully will give us a clear idea. I will open an issue about this to track 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.

Issue opened: #3584

PSReadLine/PSReadLineResources.resx Outdated Show resolved Hide resolved
@daxian-dbw daxian-dbw merged commit 372212e into PowerShell:master Feb 27, 2023
@daxian-dbw daxian-dbw deleted the scroll branch February 27, 2023 18:48
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.

LGTM!

PSReadLine/Prediction.Views.cs Show resolved Hide resolved
PSReadLine/Prediction.Views.cs Show resolved Hide resolved
PSReadLine/Prediction.Views.cs Show resolved Hide resolved
PSReadLine/Prediction.Views.cs Show resolved Hide resolved
@daxian-dbw
Copy link
Member Author

@andschwa Thanks for the review! I submitted #3600 to address you feedback.

@ChristopherHaws
Copy link

Any idea when this will be released (even to a prerelease version)? I just ran powershell -noprofile -command "Update-Module PSReadLine -AllowPrerelease" and PSReadLine is still on version 2.2.6 and doesnt have these changes.

Thanks! :)

@ghost
Copy link

ghost commented Mar 8, 2023

🎉 v2.3.0-beta0 has been released which incorporates this pull request. 🎉

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.

Auto-resize Predictor ListView when the height is too small
4 participants