API to get prompt's *starting* Y coordinate, for external tab-completers that must scroll terminal and thus relocate prompt position

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
cli

調査の方向性

Start by tracing the existing InvokePrompt entry point and PSReadLine's prompt and cursor-position handling. Compare the proposed GetPromptStartPosition and MovePromptYPosition APIs, then define behavior for multiline prompts and terminal scrolling; done means an external completer can restore the prompt using its starting Y coordinate.

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

説明

Issue-Enhancement Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
Description of the new feature/enhancement

PSFzf exposes an alternative to MenuComplete using fzf's fuzzy matching menu. Just like MenuComplete, fzf's menu requires X lines of space beneath the prompt, so it may scroll the terminal upward when activated. When it returns, PSReadLine needs to be informed that the prompt has moved upward to a different Y position.

When the prompt is multiple lines long, this Y position is not the same as (Get-Host).UI.RawUI.CursorPosition. RawUI shows us the end of the prompt, but not the beginning. The beginning is the value which must be passed to InvokePrompt.

Related issues:
https://github.com/kelleyma49/PSFzf/issues/202#issuecomment-2503800370
https://github.com/kelleyma49/PSFzf/issues/227

Proposed technical implementation details (optional)

There are hacks to compute the prompt height, by overriding function prompt to capture the Y coordinate before the prompt is rendered. But the correct solution is for PSReadLine to expose either:

  • GetPromptStartPosition to get the Y coordinate of the prompt, so fzf can subtract the number of lines it scrolled the terminal and pass the result to InvokePrompt
  • MovePromptYPosition if you really don't want to expose the above. This would accept a positive or negative number and add it to the prompt's Y position.

Pseudo-code to show how this might work:

Set-PSReadLineKeyHandler -Key Tab -ScriptBlock {
  $cursor_y = (Get-Host).UI.RawUI.CursorPosition.Y # end of prompt, to account for multi-line prompts
  $prompt_y = [PSReadline]::GetPromptStartPosition().Y # start of prompt
  InvokeFzfMenu # This may scroll the terminal to make space for the menu, and will thus restore cursor position to a new (higher) Y coordinate when finished
  # How much did cursor position move?  Add this delta to prompt's start position
  $new_prompt_y = $prompt_y + (Get-Host).UI.RawUI.CursorPosition.Y - $cursor_y
  [PSReadline]::InvokePrompt($null, $new_prompt_y)
}
主要言語
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 を短くまとめたダイジェスト。