Skip to content

Commit

Permalink
Revert "Make TerminalUI::get_next_key() helpers static"
Browse files Browse the repository at this point in the history
On macOS, backspace reportedly no longer works after <c-z> 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 ad36585

Closes #5155
  • Loading branch information
krobelus authored and mawww committed May 18, 2024
1 parent 4e5631d commit 7a90473
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/terminal_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ Optional<Key> 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'))
Expand All @@ -717,7 +717,7 @@ Optional<Key> 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
Expand Down Expand Up @@ -756,7 +756,7 @@ Optional<Key> TerminalUI::get_next_key()
return mod;
};

auto parse_csi = [this]() -> Optional<Key> {
auto parse_csi = [this, &convert]() -> Optional<Key> {
auto next_char = [] { return get_char().value_or((unsigned char)0xff); };
int params[16][4] = {};
auto c = next_char();
Expand Down

0 comments on commit 7a90473

Please sign in to comment.