diff --git a/src/input_handler.cc b/src/input_handler.cc index 06f1eb1e..8b91d1a4 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1110,8 +1110,10 @@ public: sels.emplace_back(buffer.char_prev(pos)); } auto& main = context().selections().main(); - String main_char = buffer.string(buffer.char_prev(main.cursor()), - main.cursor()); + String main_char; + if (main.cursor() != BufferCoord{0, 0}) + main_char = buffer.string(buffer.char_prev(main.cursor()), + main.cursor()); if (not sels.empty()) SelectionList{buffer, std::move(sels)}.erase(); diff --git a/test/regression/0-crash-on-backspace-at-buffer-begin/cmd b/test/regression/0-crash-on-backspace-at-buffer-begin/cmd new file mode 100644 index 00000000..4329828f --- /dev/null +++ b/test/regression/0-crash-on-backspace-at-buffer-begin/cmd @@ -0,0 +1 @@ +i diff --git a/test/regression/0-crash-on-backspace-at-buffer-begin/in b/test/regression/0-crash-on-backspace-at-buffer-begin/in new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/0-crash-on-backspace-at-buffer-begin/in @@ -0,0 +1 @@ + diff --git a/test/regression/0-crash-on-backspace-at-buffer-begin/out b/test/regression/0-crash-on-backspace-at-buffer-begin/out new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/0-crash-on-backspace-at-buffer-begin/out @@ -0,0 +1 @@ +