Get-PSReadLineOption emits the ListView window-size warning, so prompt modules trigger it on every shell start

Open Beginner friendly
#5,205 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
cli

Research direction

Start by locating GetPSReadLineOption.EndProcessing and WarnWhenWindowSizeTooSmallForView, which the issue identifies as the warning path. Reproduce the behavior with the provided Set-PSReadLineOption and Get-PSReadLineOption commands at a 49x20 window size. Done means reading options no longer writes the warning, while opting into ListView still warns when appropriate.

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 - the console output is pasted verbatim under Actual behavior.

Environment data
PS Version: 7.6.5
PS HostName: ConsoleHost
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.8875 (WinBuild.160101.0800)
BufferWidth: 49
BufferHeight: 20
Steps to reproduce
[Console]::SetWindowSize(49, 20)    # anything below 50 columns or 5 rows
[Console]::SetBufferSize(49, 20)
Set-PSReadLineOption -PredictionViewStyle ListView -WarningAction SilentlyContinue
Get-PSReadLineOption | Out-Null
Get-PSReadLineOption | Out-Null

Where I actually ran into it: oh-my-posh's PowerShell init reads the options once when its module loads, to back up the prompt settings it is about to replace (omp.ps1):

$originalPSReadLineOptions = Get-PSReadLineOption

An editor terminal is often still below the threshold at the moment the profile runs - I hit this in Zed on Windows, where the pty is created before the terminal dock has been laid out. So the warning shows up on shell start: once for that read, and again for my own Set-PSReadLineOption -PredictionViewStyle ListView in the profile.

Expected behavior

Get-PSReadLineOption reads configuration, so it should return the options without writing to the warning stream. Set-PSReadLineOption -PredictionViewStyle ListView already warns at the point where the user opts in, which is where the advice is actionable.

Actual behavior

Every call warns, for as long as ListView is the active view style and the window is below 50x5:

WindowWidth = 49, WindowHeight = 20
PredictionViewStyle is now: ListView
-- calling Get-PSReadLineOption --
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 '50' and the 'WindowHeight' is not less than '5'.
-- calling it again --
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 '50' and the 'WindowHeight' is not less than '5'.

Two things that make it awkward to live with:

  • It also fires with PredictionSource = None, where nothing is predicted at all and the view style has no effect.
  • -WarningAction and $WarningPreference belong to the caller. Here the caller is the prompt module, so the person who chose ListView cannot turn it off without redirecting the warning stream around somebody else's init script.

GetPSReadLineOption.EndProcessing has called WarnWhenWindowSizeTooSmallForView since ListView was added in #1909, so I assume it is deliberate. If you want to keep telling people on read, warning once and re-arming when the window grows back would remove the noise on its own. If you would rather drop it from the read path, that is a one-line change. Happy to send a PR for whichever you prefer.

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.