diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-12-30 19:29:21 +0400 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2024-01-06 08:59:54 +0100 |
commit | 53927d686a8107dd28a6d086b92a608f196e7ce3 (patch) | |
tree | b831134b68009ee8c4b863fc9e95b085c5b4d33b | |
parent | 1bed41fc76f11e0766eb09088c9b524fa471c674 (diff) | |
download | alacritty-53927d686a8107dd28a6d086b92a608f196e7ce3.tar.gz alacritty-53927d686a8107dd28a6d086b92a608f196e7ce3.zip |
Don't substitute `\n` in char bindings
This broke unintentionally due to routing paste-like input
via paste function.
Fixes #7476.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/event.rs | 24 |
2 files changed, 18 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 61260731..25d32e57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `alacritty migrate` failing with nonexistent imports - `Alt` bindings requiring composed key rather than pre-composed one on macOS - `Alt + Control` bindings not working on Windows +- `chars = "\u000A"` action in bindings inserting `\n` ## 0.13.0 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); } } |