From 0bde08a141b8de9b9d9354b532a84333e02724dc Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 2 Jan 2022 09:29:45 +0200 Subject: Added Allocator to Editor.prompt & Editor.promptEx --- src/Buffer.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Buffer.zig') diff --git a/src/Buffer.zig b/src/Buffer.zig index 7f3043b..5bf319c 100644 --- a/src/Buffer.zig +++ b/src/Buffer.zig @@ -274,8 +274,8 @@ pub fn forwardChar(self: *Buffer) void { // TODO: Make use of the callback feature to go to the final line while typing in. pub fn goToLine(self: *Buffer, editor: *Editor) !void { - if (try editor.prompt("Goto line")) |line_str| { - defer editor.allocator.free(line_str); + if (try editor.prompt(self.allocator, "Goto line")) |line_str| { + defer self.allocator.free(line_str); const line = std.fmt.parseUnsigned(usize, line_str, 0) catch |err| { try editor.setStatusMessage("Couldn't parse '{s}' as an integer: {}", .{ line_str, err }); @@ -434,8 +434,7 @@ pub fn recenterTopBottom(self: *Buffer, screenrows: usize) void { pub fn save(self: *Buffer, editor: *Editor) !void { if (self.file_path == null) { - // TODO: Editor.prompt should take an Allocator - const fname = (try editor.prompt("Save as")) orelse { return; }; + const fname = (try editor.prompt(self.allocator, "Save as")) orelse { return; }; defer self.allocator.free(fname); const file_path = try es.files.resolvePath(self.allocator, fname); -- cgit v1.2.3