fix: destroy editor before creating a new one

Editor lifetimes should not overlap otherwise we run into duplicate command
issues.
This commit is contained in:
CJ van den Berg 2024-03-31 21:03:23 +02:00
parent 3d5119c335
commit a404f6e768

View file

@ -333,6 +333,7 @@ pub fn walk(self: *Self, ctx: *anyopaque, f: Widget.WalkFn, w: *Widget) bool {
}
fn create_editor(self: *Self) tp.result {
self.widgets.replace(0, Widget.empty(self.a, self.plane, .dynamic) catch |e| return tp.exit_error(e));
command.executeName("enter_mode_default", .{}) catch {};
var editor_widget = ed.create(self.a, Widget.to(self)) catch |e| return tp.exit_error(e);
errdefer editor_widget.deinit(self.a);