From 1322abef646533eb67d8c76d8a459ef48becb266 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 14 Mar 2023 04:48:11 +1100 Subject: [PATCH] Convert \r to \n in bracketed pastes It seems many terminals emits \r for newlines in bracketed pastes, manually convert this. --- src/terminal_ui.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 13a8af4b..d411dd67 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -971,7 +971,15 @@ Optional TerminalUI::get_next_key() if (m_paste_buffer) { - m_paste_buffer->push_back(*c); + auto paste_convert = [](char c) { + switch (c) + { + case '\r': return '\n'; + default: return c; + } + }; + + m_paste_buffer->push_back(paste_convert(*c)); return Key{Key::Invalid}; } return parse_key(*c);