Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1645126

Browse files
ltrujelloCarreau
authored andcommitted
Fixes #13472 by restoring user's terminal cursor
1 parent ca8b6d5 commit 1645126

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

IPython/core/interactiveshell.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,6 +3679,10 @@ def atexit_operations(self):
36793679
pass
36803680
del self.tempdirs
36813681

3682+
# Restore user's cursor
3683+
if hasattr(self, "editing_mode") and self.editing_mode == 'vi':
3684+
sys.stdout.write("\x1b[0 q")
3685+
sys.stdout.flush()
36823686

36833687
def cleanup(self):
36843688
self.restore_sys_module_state()

IPython/terminal/shortcuts.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,7 @@ def set_input_mode(self, mode):
336336
shape = {InputMode.NAVIGATION: 2, InputMode.REPLACE: 4}.get(mode, 6)
337337
cursor = "\x1b[{} q".format(shape)
338338

339-
if hasattr(sys.stdout, "_cli"):
340-
write = sys.stdout._cli.output.write_raw
341-
else:
342-
write = sys.stdout.write
343-
344-
write(cursor)
339+
sys.stdout.write(cursor)
345340
sys.stdout.flush()
346341

347342
self._input_mode = mode

0 commit comments

Comments
 (0)