From 678f1e7272a8c3e9774a5a06babfc0953f700998 Mon Sep 17 00:00:00 2001 From: Jory Date: Wed, 25 Feb 2026 17:50:46 -0600 Subject: [PATCH 1/2] 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. --- pgcli/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pgcli/main.py b/pgcli/main.py index 913228b33..9ce15135d 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -48,6 +48,7 @@ ) from prompt_toolkit.history import FileHistory from prompt_toolkit.auto_suggest import AutoSuggestFromHistory +from prompt_toolkit.cursor_shapes import ModalCursorShapeConfig from pygments.lexers.sql import PostgresLexer 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): enable_suspend=True, editing_mode=EditingMode.VI if self.vi_mode else EditingMode.EMACS, search_ignore_case=True, + cursor=ModalCursorShapeConfig(), ) return prompt_app From a74df4729a8fed1249f7a2f757e448c238551550 Mon Sep 17 00:00:00 2001 From: Jory Date: Wed, 25 Feb 2026 20:20:20 -0600 Subject: [PATCH 2/2] Add cursor shape indicator to vi mode changelog --- changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.rst b/changelog.rst index fdfcde538..da6c611f1 100644 --- a/changelog.rst +++ b/changelog.rst @@ -4,6 +4,9 @@ Upcoming (TBD) Features: --------- * Add support for `\\T` prompt escape sequence to display transaction status (similar to psql's `%x`). +* Add cursor shape support for vi mode. When ``vi = True``, the terminal cursor now + reflects the current editing mode: beam in INSERT, block in NORMAL, underline in REPLACE. + Uses prompt_toolkit's ``ModalCursorShapeConfig``. 4.4.0 (2025-12-24) ==================