fix: restore cursors if unindent fails

This commit is contained in:
CJ van den Berg 2024-12-06 23:21:45 +01:00
parent dbc4707001
commit 5e35824a22
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -2638,6 +2638,10 @@ pub const Editor = struct {
pub fn unindent(self: *Self, _: Context) Result {
const b = try self.buf_for_update();
errdefer blk: {
self.cursels.clearAndFree();
self.cursels = self.cursels_saved.clone() catch break :blk;
}
const root = try self.with_cursels_mut(b.root, unindent_cursel, b.allocator);
try self.update_buf(root);
}