Skip to content

Commit a12e801

Browse files
authored
Add cursor shape indicator for vi mode (#1558)
* feat: enable modal cursor shape in vi mode When vi = True, users expect the cursor to reflect modal state (block in NORMAL, beam in INSERT, underline in REPLACE). ModalCursorShapeConfig exists in prompt_toolkit for exactly this. Without it, cursor=None resolves to CursorShape._NEVER_CHANGE, so no DECSCUSR sequences are ever written regardless of mode. * Add cursor shape indicator to vi mode changelog
1 parent d0a6cc2 commit a12e801

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Upcoming (TBD)
44
Features:
55
---------
66
* Add support for `\\T` prompt escape sequence to display transaction status (similar to psql's `%x`).
7+
* Add cursor shape support for vi mode. When ``vi = True``, the terminal cursor now
8+
reflects the current editing mode: beam in INSERT, block in NORMAL, underline in REPLACE.
9+
Uses prompt_toolkit's ``ModalCursorShapeConfig``.
710

811
4.4.0 (2025-12-24)
912
==================

pgcli/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
)
4949
from prompt_toolkit.history import FileHistory
5050
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
51+
from prompt_toolkit.cursor_shapes import ModalCursorShapeConfig
5152
from pygments.lexers.sql import PostgresLexer
5253

5354
from pgspecial.main import PGSpecial, NO_QUERY, PAGER_OFF, PAGER_LONG_OUTPUT
@@ -1087,6 +1088,7 @@ def get_continuation(width, line_number, is_soft_wrap):
10871088
enable_suspend=True,
10881089
editing_mode=EditingMode.VI if self.vi_mode else EditingMode.EMACS,
10891090
search_ignore_case=True,
1091+
cursor=ModalCursorShapeConfig(),
10901092
)
10911093

10921094
return prompt_app

0 commit comments

Comments
 (0)