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

Auto-resize Predictor ListView when the height is too small #3563

Closed
1 task done
StevenBucher98 opened this issue Feb 2, 2023 · 6 comments · Fixed by #3583
Closed
1 task done

Auto-resize Predictor ListView when the height is too small #3563

StevenBucher98 opened this issue Feb 2, 2023 · 6 comments · Fixed by #3583
Labels

Comments

@StevenBucher98
Copy link
Collaborator

StevenBucher98 commented Feb 2, 2023

Prerequisites

  • Write a descriptive title.

Description of the new feature/enhancement

When my shell windows are too small to display all ten predictions in ListView, it should reduce the size to be able to display a smaller number of predictions.

This is particularly applicable in CloudShell where the default window when you open CloudShell is too small for ListView and so fails silently when I try using F2 and gives this error message when I try to set:

PS /home/steven> Set-PSReadLineOption -PredictionViewStyle ListView
WARNING: The prediction 'ListView' is temporarily disabled because the current window size of the console is too small. To use the 'ListView', please make sure the 'WindowWidth' is not less than '54' and the 'WindowHeight' is not less than '15'.
Screen.Recording.2023-02-02.at.10.00.06.AM.mov

Proposed technical implementation details (optional)

There are a few ways to improve this experience.

  • Incorporate similiar error message that Set-PSReadLineOption gives when the user tries F2
  • Make ListView number of results resizable based on the window.
  • Make ListView number of results resizable based on the window and incorporate scrollable functionality to enable users to see the other results given a smaller window.

cc @theJasonHelmick @daxian-dbw

@StevenBucher98 StevenBucher98 added the Issue-Enhancement It's a feature request. label Feb 2, 2023
@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Feb 2, 2023
@StevenBucher98 StevenBucher98 added this to the 2.3.0-Consider milestone Feb 2, 2023
@theJasonHelmick
Copy link
Collaborator

In the future, It would be great if ListView could resize, within reason, to the smaller window - perhaps only displaying 3 lines. Most important I think is an error message to display if the windows size is too small. In the graphic below, I pressed F2 after typing:

Get-

Screenshot 2023-02-02 at 9 07 29 AM

Nothing is displayed. But when I max the window - F2 works as expected.

Screenshot 2023-02-02 at 9 07 48 AM

@StevenBucher98
Copy link
Collaborator Author

Related to: #3557

@daxian-dbw
Copy link
Member

I improved the scrollable list view to be able to adjust the list height accordingly based on the terminal height, and print warning when the terminal size is too small to show the list view.

scrollable-adjustable

@ChristopherHaws
Copy link

@daxian-dbw Instead of showing a warning when it gets too small, maybe it could automatically switch to the PredictionInlineView when the windows is smaller than PredictionListView.MinWindowHeight and switch back when the terminal window height becomes greater than PredictionListView.MinWindowHeight?

@daxian-dbw
Copy link
Member

daxian-dbw commented Feb 6, 2023

PSReadLine uses inline view by default, so for Cloud Shell and VSCode users, they usually will press F2 attempting to change to list view. When the terminal size is too small to show the list view, we will still need to write out the warning message, because otherwise the user will find no change/feedback and thus not sure whether F2 stopped working.

Also, there are cases where the terminal height becomes too small while navigating within the list, when a particular list item has a long text that takes up a big chunk of space. In those cases, list view is still working in general, just not working for that particular list item.

With the new improvements, the list view would theoretically work as long as the terminal height is >= 5, which should cover most of the scenarios like the Cloud Shell and VSCode, if not all. At the meantime, changing between inline and list views is very simple -- pressing F2, so I prefer the user making the view change explicitly instead of depending on PSReadLine being that smart, so as to reduce code complexity.

@ghost ghost added the In-PR A PR is opened targeting the issue label Feb 17, 2023
@ghost ghost added Resolution-Fixed and removed In-PR A PR is opened targeting the issue Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Feb 27, 2023
@StevenBucher98 StevenBucher98 removed this from the 2.3.0-Consider milestone Mar 6, 2023
@ghost
Copy link

ghost commented Mar 8, 2023

🎉 This issue was addressed in 3583, which has now been successfully released in v2.3.0-beta0. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants