Add cancel buffer (to store cancelled operations.)

This commit is contained in:
2026-09-08 11:50:17 +01:00
parent 51676362b9
commit d6d3f31326
6 changed files with 31 additions and 19 deletions
+4 -4
View File
@@ -72,21 +72,21 @@ void GenericBuffer::list_history(BEd &ctx) {
}
}
HistoryBuffer *GenericBuffer::get_history(uint64_t version) {
ReadonlyBuffer *GenericBuffer::get_history(uint64_t version) {
uint64_t current = base_version + undo_stack.size();
if (version < base_version)
throw ed_error("History version has been pruned.");
if (version < current) {
auto &item = undo_stack[version - base_version];
return new HistoryBuffer(name, item.text, item.parse_state);
return new ReadonlyBuffer(name, item.text, item.parse_state);
}
if (version == current)
return new HistoryBuffer(name, root, parse);
return new ReadonlyBuffer(name, root, parse);
uint64_t redo_offset = version - current - 1;
if (redo_offset >= redo_stack.size())
throw ed_error("No such history version.");
auto &item = redo_stack[redo_stack.size() - 1 - redo_offset];
return new HistoryBuffer(name, item.text, item.parse_state);
return new ReadonlyBuffer(name, item.text, item.parse_state);
}
void GenericBuffer::snapshot(std::string action_) {
+1
View File
@@ -188,6 +188,7 @@ void Parser::locator(AddressPromise &addr) {
token(io::Token::AddressSymbol);
advance();
end_token();
token(io::Token::Number);
addr.base = AddressPromise::Current{};
uint16_t j = 0;
uint64_t num = 0;
+2 -2
View File
@@ -272,7 +272,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
cursor.col = byte_column(previous.line, wanted);
} break;
case io::KeyEvent::SpecialKey::DOWN: {
if (cursor.row + 1 >= vase->lines)
if (cursor.row >= vase->lines)
break;
vase::Iterator current(vase, cursor.row, Direction::Forward);
if (!current.next())
@@ -294,7 +294,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
if (!it.next())
throw ed_error("Invalid cursor position.");
next.col = next_cluster(it.line, cursor.col);
} else if (cursor.row + 1 < vase->lines) {
} else if (cursor.row < vase->lines) {
++next.row;
next.col = 0;
} else {