在通过 CancellationToken 取消列表提示后,Cursor 留下了隐藏项
作者: glen-84创建于 2026年7月19日更新于 2026年7月19日
标签area: promptarea: progressarea: console
Information
- OS: Linux
- Version: 0.57.2 (also present on
mainas of this writing) - Terminal: any ANSI terminal (observed on Ghostty)
Describe the bug
When an interactive list-based prompt (
SelectionPrompt,MultiSelectionPrompt) is cancelled through theCancellationTokenpassed toShowAsync— e.g. by wiringConsole.CancelKeyPressto aCancellationTokenSourceso Ctrl+C aborts the prompt — the terminal Cursor is left hidden. The rest of the terminal state is restored correctly (input/rendering), but the Cursor never becomes visible again, so it looks like typed input has no caret until the Cursor is manually restored (printf '\033[?25h'/tput cnorm).
Root cause
In ListPrompt<T>.Show(...), the Cursor is hidden inside the using (new RenderHookScope(...)) block, but Cursor.Show() is only called after the block, past the while loop:
内容来源: spectreconsole/spectre.console