diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 372b11e..c53ad9d 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -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); }