fix: restart with no open file should return to home screen
This commit is contained in:
parent
dd2601b627
commit
a98d4e02a7
1 changed files with 12 additions and 5 deletions
|
@ -1293,9 +1293,12 @@ pub fn write_restore_info(self: *Self) void {
|
|||
var meta = std.ArrayListUnmanaged(u8).empty;
|
||||
const writer = meta.writer(a);
|
||||
|
||||
const editor = self.get_active_editor() orelse return;
|
||||
cbor.writeValue(writer, editor.file_path) catch return;
|
||||
editor.update_meta();
|
||||
if (self.get_active_editor()) |editor| {
|
||||
cbor.writeValue(writer, editor.file_path) catch return;
|
||||
editor.update_meta();
|
||||
} else {
|
||||
cbor.writeValue(writer, null) catch return;
|
||||
}
|
||||
|
||||
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
||||
buffer_manager.write_state(writer) catch return;
|
||||
|
@ -1317,11 +1320,15 @@ fn read_restore_info(self: *Self) !void {
|
|||
var iter: []const u8 = buf[0..size];
|
||||
|
||||
tp.trace(tp.channel.debug, .{ "mainview", "extract" });
|
||||
var editor_file_path: []const u8 = undefined;
|
||||
var editor_file_path: ?[]const u8 = undefined;
|
||||
if (!try cbor.matchValue(&iter, cbor.extract(&editor_file_path))) return error.Stop;
|
||||
try self.buffer_manager.extract_state(&iter);
|
||||
|
||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = editor_file_path } });
|
||||
if (editor_file_path) |file_path| {
|
||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } });
|
||||
} else {
|
||||
try tp.self_pid().send(.{ "cmd", "close_file" });
|
||||
}
|
||||
}
|
||||
|
||||
fn get_next_mru_buffer(self: *Self) ?[]const u8 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue