Fix cancellation procedure.

This commit is contained in:
2026-09-08 07:06:38 +01:00
parent 0760209417
commit 51676362b9
3 changed files with 10 additions and 5 deletions
+4 -2
View File
@@ -168,10 +168,12 @@ void BEd::handle(std::string_view cmd, bool eof) {
std::tie(vase, lang, state) = c.function->pre_text_mode(*this, address, c.argument);
internal::ui::text_mode::TextMode tm(*this, vase, lang, state);
auto [a, b] = tm.run();
if (!b)
if (!b) {
text = a;
else
} else {
internal::vase::Shard::release(a);
throw ed_error("Operation cancelled.");
}
}
if (c.function->handle)
c.function->handle(*this, address, text, c.argument, nullptr);
View File
+6 -3
View File
@@ -159,6 +159,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
term_height = rows;
redraw();
bool running = true;
bool cancelled = false;
while (running) {
redraw();
@@ -176,8 +177,10 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
case io::KeyEvent::Modifier::ALT:
case io::KeyEvent::Modifier::CTRL_ALT:
case io::KeyEvent::Modifier::CTRL:
if (res.text[0] == 'c')
return {vase, true};
if (res.text[0] == 'c') {
cancelled = true;
running = false;
}
break;
case io::KeyEvent::Modifier::NONE:
if (res.text[0] == '\b' || res.text[0] == 0x7f) {
@@ -314,7 +317,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
uint16_t last_row = start + required_height;
bed.io.move_cursor(last_row, 1);
bed.io.write("\n");
return {vase, false};
return {vase, cancelled};
}
void TextMode::grow() {