feat: use current file name as default for save as

This commit is contained in:
CJ van den Berg 2024-08-30 21:03:45 +02:00
parent e79f10d59f
commit 2d67d4a2c6
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -21,9 +21,7 @@ pub const create = Type.create;
pub fn load_entries(self: *Type) !void { pub fn load_entries(self: *Type) !void {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| { if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
if (editor.file_path) |old_path| try self.file_path.appendSlice(editor.file_path orelse "");
if (std.mem.lastIndexOf(u8, old_path, "/")) |pos|
try self.file_path.appendSlice(old_path[0 .. pos + 1]);
if (editor.get_primary().selection) |sel| ret: { if (editor.get_primary().selection) |sel| ret: {
const text = editor.get_selection(sel, self.a) catch break :ret; const text = editor.get_selection(sel, self.a) catch break :ret;
defer self.a.free(text); defer self.a.free(text);