diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ced02..f9b8690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Procedure when bumping the version number: ### Fixed - Crash when connecting to nonexistent rooms - Crash when connecting to rooms that require authentication +- Pasting multi-line strings into the editor ## v0.2.1 - 2022-08-11 diff --git a/src/ui/util.rs b/src/ui/util.rs index ff6b7d8..52ae0dc 100644 --- a/src/ui/util.rs +++ b/src/ui/util.rs @@ -78,7 +78,13 @@ pub fn handle_editor_event( // Editing key!(Char ch) if char_filter(*ch) => editor.insert_char(terminal.frame(), *ch), - key!(Paste str) if str.chars().all(char_filter) => editor.insert_str(terminal.frame(), str), + key!(Paste str) if str.chars().all(char_filter) => { + // It seems that when pasting, '\n' are converted into '\r' for some + // reason. I don't really know why, or at what point this happens. + // Vim converts any '\r' pasted via the terminal into '\n', so I + // decided to mirror that behaviour. + editor.insert_str(terminal.frame(), &str.replace('\r', "\n")) + } key!(Ctrl + 'h') | key!(Backspace) => editor.backspace(terminal.frame()), key!(Ctrl + 'd') | key!(Delete) => editor.delete(), key!(Ctrl + 'l') => editor.clear(),