From 7a90473267f7f2fd8df5ae933c7b287c31ce3c97 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 17 May 2024 10:39:32 +0200 Subject: [PATCH] Revert "Make TerminalUI::get_next_key() helpers static" On macOS, backspace reportedly no longer works after and fg. The value of m_original_termios.c_cc[VERASE] seems to be wrong in a static lambda that captures a singleton "this". Not sure what's the problem. I thought that it is guaranteed that "static auto convert = [this]() { ... }" is initialized lazily, hence it should capture the correct address. Maybe the address changes somehow or it's UB / a compiler bug. This reverts commit ad36585b7ad236bea7d1c02b0679ae371c3c2a9e Closes #5155 --- src/terminal_ui.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 3ad95e4071..52a25e261e 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -702,7 +702,7 @@ Optional TerminalUI::get_next_key() static constexpr auto control = [](char c) { return c & 037; }; - static auto convert = [this](Codepoint c) -> Codepoint { + auto convert = [this](Codepoint c) -> Codepoint { if (c == control('m') or c == control('j')) return Key::Return; if (c == control('i')) @@ -717,7 +717,7 @@ Optional TerminalUI::get_next_key() return Key::Escape; return c; }; - static auto parse_key = [](unsigned char c) -> Key { + auto parse_key = [&convert](unsigned char c) -> Key { if (Codepoint cp = convert(c); cp > 255) return Key{cp}; // Special case: you can type NUL with Ctrl-2 or Ctrl-Shift-2 or @@ -756,7 +756,7 @@ Optional TerminalUI::get_next_key() return mod; }; - auto parse_csi = [this]() -> Optional { + auto parse_csi = [this, &convert]() -> Optional { auto next_char = [] { return get_char().value_or((unsigned char)0xff); }; int params[16][4] = {}; auto c = next_char();