mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Strip NULs from bracketed paste text as a Windows workaround
See #1661 for lots of context. Long story short, in Windows Terminal it looks like any character that would requite the press of a modifier key causes a NUL to appear in the pasted text for that character. This feels like it could be a bug in Windows Terminal and we will investigate and report at some point. Meanwhile though this provides a workaround that has the paste experience work the same as I'm seeing on macOS (and I would imagine in most terminals on GNU/Linux too).
This commit is contained in:
@@ -118,7 +118,10 @@ class XTermParser(Parser[events.Event]):
|
||||
# ESC from the closing bracket, since at that point we didn't know what
|
||||
# the full escape code was.
|
||||
pasted_text = "".join(paste_buffer[:-1])
|
||||
on_token(events.Paste(self.sender, text=pasted_text))
|
||||
# Note the removal of NUL characters: https://github.com/Textualize/textual/issues/1661
|
||||
on_token(
|
||||
events.Paste(self.sender, text=pasted_text.replace("\x000", ""))
|
||||
)
|
||||
paste_buffer.clear()
|
||||
|
||||
character = ESC if use_prior_escape else (yield read1())
|
||||
|
||||
Reference in New Issue
Block a user