diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index cb1de28..76ca303 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -1257,6 +1257,11 @@ pub fn reset_to_last_saved(self: *Self) void { } } +pub fn refresh_from_file(self: *Self) LoadFromFileError!void { + try self.load_from_file_and_update(self.file_path); + self.update_last_used_time(); +} + pub fn store_to_string(self: *const Self, allocator: Allocator, eol_mode: EolMode) ![]u8 { var s = try ArrayList(u8).initCapacity(allocator, self.root.weights_sum().len); try self.root.store(s.writer(), eol_mode); diff --git a/src/tui/editor.zig b/src/tui/editor.zig index f87d199..96d3f13 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -4610,6 +4610,11 @@ pub const Editor = struct { } pub const open_scratch_buffer_meta: Meta = .{ .arguments = &.{ .string, .string } }; + pub fn reload_file(self: *Self, _: Context) Result { + if (self.buffer) |buffer| try buffer.refresh_from_file(); + } + pub const reload_file_meta: Meta = .{ .description = "Reload file" }; + pub const SaveOption = enum { default, format, no_format }; pub fn save_file(self: *Self, ctx: Context) Result {