From c611b70567364a902e325f4397ef21b1cd3b443f Mon Sep 17 00:00:00 2001 From: trilader Date: Wed, 6 Jan 2021 20:46:00 +0100 Subject: [PATCH] Fix crash when pressing backspace in a lineedit at pos 0 with chars left --- tui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tui.cpp b/tui.cpp index 2e20244..18217f6 100644 --- a/tui.cpp +++ b/tui.cpp @@ -339,7 +339,7 @@ std::string get_string(const std::string &caption, const std::string &text, cons // FIXME: Correctly handle deletion of clusters with more than one codepoint e.g. ° or ä {TERMPAINT_EV_KEY, "Delete", 0, [&](){ if(input_pos < input.size()) { input.erase(input_pos, 1); } }, "Delete input forward"}, - {TERMPAINT_EV_KEY, "Backspace", 0, [&](){ if(!input.empty()) { input.erase(input_pos - 1, 1); input_pos--; }}, "Delete input backward"}, + {TERMPAINT_EV_KEY, "Backspace", 0, [&](){ if(input_pos > 0) { input.erase(input_pos - 1, 1); input_pos--; }}, "Delete input backward"}, {TERMPAINT_EV_KEY, "Escape", 0, [&](){ input.clear(); done = true; }, "Abort input"}, {TERMPAINT_EV_KEY, "Enter", 0, [&](){ done = true; }, "Confirm input"},