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

オープン 初心者向け
#5,205 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
cli

調査の方向性

まず、issue が警告パスとして特定している GetPSReadLineOption.EndProcessing と WarnWhenWindowSizeTooSmallForView を見つけます。ウィンドウサイズを 49x20 にして、提供されている Set-PSReadLineOption コマンドと Get-PSReadLineOption コマンドで動作を再現します。完了条件は、オプションの読み取りで警告が出力されなくなる一方、ListView を選択した場合は適切なときに引き続き警告が表示されることです。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C#
スター
4.4k
フォーク
341
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PowerShell/PSReadLine のほかの issue

PowerShell/PSReadLine の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。