Skip to content

Commit

Permalink
Strip NULs from bracketed paste text as a Windows workaround
Browse files Browse the repository at this point in the history
See Textualize#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).
  • Loading branch information
davep committed Jan 25, 2023
1 parent 7bdc8f9 commit 32bb793
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/textual/_xterm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def reissue_sequence_as_keys(reissue_sequence: str) -> None:
# 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())
Expand Down

0 comments on commit 32bb793

Please sign in to comment.