fix: restore cursors if unindent fails
This commit is contained in:
parent
dbc4707001
commit
5e35824a22
1 changed files with 4 additions and 0 deletions
|
@ -2638,6 +2638,10 @@ pub const Editor = struct {
|
||||||
|
|
||||||
pub fn unindent(self: *Self, _: Context) Result {
|
pub fn unindent(self: *Self, _: Context) Result {
|
||||||
const b = try self.buf_for_update();
|
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);
|
const root = try self.with_cursels_mut(b.root, unindent_cursel, b.allocator);
|
||||||
try self.update_buf(root);
|
try self.update_buf(root);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue