#4845: conditional import of ptk_win32 → windows only (#4853)

* #4845: conditional import of ptk_win32 -> windows only

* #4845: added news entry

* #4845: moved news entry to separate file
This commit is contained in:
Hannes Römer 2022-06-28 04:21:34 +02:00 committed by GitHub
parent 5401a246c6
commit 349dee75a3
Failed to generate hash of commit
2 changed files with 26 additions and 1 deletions

23
news/main.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Fixed `whole_word_jumping` xontrib failing on Linux, conditional import of ``ptk_win32`` → Windows only
**Security:**
* <news item>

View file

@ -17,7 +17,6 @@ configuration of the Control+Backspace key binding.
""" """
import prompt_toolkit.input.ansi_escape_sequences as ansiseq import prompt_toolkit.input.ansi_escape_sequences as ansiseq
import prompt_toolkit.input.win32 as ptk_win32
from prompt_toolkit.filters import EmacsInsertMode, ViInsertMode from prompt_toolkit.filters import EmacsInsertMode, ViInsertMode
from prompt_toolkit.key_binding.bindings.named_commands import get_by_name from prompt_toolkit.key_binding.bindings.named_commands import get_by_name
from prompt_toolkit.keys import Keys from prompt_toolkit.keys import Keys
@ -80,6 +79,9 @@ def custom_keybindings(bindings, **kw):
if XSH.env.get("XONSH_WHOLE_WORD_CTRL_BKSP", True): if XSH.env.get("XONSH_WHOLE_WORD_CTRL_BKSP", True):
CONTROL_BKSP = "\x08" CONTROL_BKSP = "\x08"
if ON_WINDOWS: if ON_WINDOWS:
# issue #4845: Windows only (isort competes with black :-()
from prompt_toolkit.input import win32 as ptk_win32 # black:skip
# On windows BKSP is "\x08" and CTRL-BKSP is "\x7f" # On windows BKSP is "\x08" and CTRL-BKSP is "\x7f"
CONTROL_BKSP = "\x7f" CONTROL_BKSP = "\x7f"
ptk_win32.ConsoleInputReader.mappings[b"\x7f"] = CONTROL_BKSP ptk_win32.ConsoleInputReader.mappings[b"\x7f"] = CONTROL_BKSP