diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-12-30 19:29:21 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-30 19:29:21 +0400 |
commit | 107c8720c3439703cfb8058e7581396af17a8529 (patch) | |
tree | 8544d49a7691c93ebe1c0a1f0662e43cf75c85c5 /alacritty | |
parent | b067fcca337377a751880744b71a6576501dcdd1 (diff) |
Don't substitute `\n` in char bindings
This broke unintentionally due to routing paste-like input
via paste function.
Fixes #7476.
Diffstat (limited to 'alacritty')
-rw-r--r-- | alacritty/src/event.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 3b3d8297..ff08557b 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -839,13 +839,23 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon } else { self.on_terminal_input_start(); - // In non-bracketed (ie: normal) mode, terminal applications cannot distinguish - // pasted data from keystrokes. - // In theory, we should construct the keystrokes needed to produce the data we are - // pasting... since that's neither practical nor sensible (and probably an impossible - // task to solve in a general way), we'll just replace line breaks (windows and unix - // style) with a single carriage return (\r, which is what the Enter key produces). - self.write_to_pty(text.replace("\r\n", "\r").replace('\n', "\r").into_bytes()); + let payload = if bracketed { + // In non-bracketed (ie: normal) mode, terminal applications cannot distinguish + // pasted data from keystrokes. + // + // In theory, we should construct the keystrokes needed to produce the data we are + // pasting... since that's neither practical nor sensible (and probably an + // impossible task to solve in a general way), we'll just replace line breaks + // (windows and unix style) with a single carriage return (\r, which is what the + // Enter key produces). + text.replace("\r\n", "\r").replace('\n', "\r").into_bytes() + } else { + // When we explicitly disable bracketed paste don't manipulate with the input, + // so we pass user input as is. + text.to_owned().into_bytes() + }; + + self.write_to_pty(payload); } } |