Skip to content

Commit d3a1698

Browse files
committed
In VM mode, always request bracketed paste
1 parent f897500 commit d3a1698

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

Lib/_pyrepl/windows_console.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,10 @@ def __init__(
131131
super().__init__(f_in, f_out, term, encoding)
132132

133133
self.__vt_support = _supports_vt()
134-
self.__vt_bracketed_paste = False
135134

136135
if self.__vt_support:
137136
trace('console supports virtual terminal')
138137

139-
# Should make educated guess to determine the terminal type.
140-
# Currently enable bracketed-paste only if it's Windows Terminal.
141-
if 'WT_SESSION' in os.environ:
142-
trace('console supports bracketed-paste sequence')
143-
self.__vt_bracketed_paste = True
144-
145138
# Save original console modes so we can recover on cleanup.
146139
original_input_mode = DWORD()
147140
GetConsoleMode(InHandle, original_input_mode)
@@ -360,15 +353,13 @@ def prepare(self) -> None:
360353

361354
if self.__vt_support:
362355
SetConsoleMode(InHandle, self.__original_input_mode | ENABLE_VIRTUAL_TERMINAL_INPUT)
363-
if self.__vt_bracketed_paste:
364-
self._enable_bracketed_paste()
356+
self._enable_bracketed_paste()
365357

366358
def restore(self) -> None:
367359
if self.__vt_support:
368360
# Recover to original mode before running REPL
361+
self._disable_bracketed_paste()
369362
SetConsoleMode(InHandle, self.__original_input_mode)
370-
if self.__vt_bracketed_paste:
371-
self._disable_bracketed_paste()
372363

373364
def _move_relative(self, x: int, y: int) -> None:
374365
"""Moves relative to the current posxy"""
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Turn on virtual terminal mode in REPL Windows console to emit sequences that
2-
bracketed-paste modes require. If the terminal may not support paste modes,
3-
provides a flag to help callers turn off related features.
1+
Turn on virtual terminal mode and enable barcketed paste in REPL Windows
2+
console. (If the terminal does not support bracketed paste, enabling it
3+
does nothing.)

0 commit comments

Comments
 (0)