Skip to content

Commit 728983b

Browse files
authored
Improve ModalCursorShapeConfig for various input modes (#1900)
- Also display a beam cursor for Vi "insert multiple" mode (visual block insert). - Also display an underline cursor for Vi "replace single" mode. - Display a beam in Emacs mode (like Vi's insert).
1 parent 75615b1 commit 728983b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: src/prompt_toolkit/cursor_shapes.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,23 @@ class ModalCursorShapeConfig(CursorShapeConfig):
6969

7070
def get_cursor_shape(self, application: Application[Any]) -> CursorShape:
7171
if application.editing_mode == EditingMode.VI:
72-
if application.vi_state.input_mode == InputMode.INSERT:
72+
if application.vi_state.input_mode in {
73+
InputMode.NAVIGATION,
74+
}:
75+
return CursorShape.BLOCK
76+
if application.vi_state.input_mode in {
77+
InputMode.INSERT,
78+
InputMode.INSERT_MULTIPLE,
79+
}:
7380
return CursorShape.BEAM
74-
if application.vi_state.input_mode == InputMode.REPLACE:
81+
if application.vi_state.input_mode == {
82+
InputMode.REPLACE,
83+
InputMode.REPLACE_SINGLE,
84+
}:
7585
return CursorShape.UNDERLINE
86+
elif application.editing_mode == EditingMode.EMACS:
87+
# like vi's INSERT
88+
return CursorShape.BEAM
7689

7790
# Default
7891
return CursorShape.BLOCK

0 commit comments

Comments
 (0)