From e6aae2d63a1e5ca9eb67977a4bc34b7ecea3d8a7 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Fri, 31 Dec 2021 21:21:50 +0200 Subject: Fix a bug --- src/Editor.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Editor.zig b/src/Editor.zig index 487c5ff..4d45b77 100644 --- a/src/Editor.zig +++ b/src/Editor.zig @@ -237,7 +237,13 @@ pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool { var response = try self.prompt(full_prompt); defer if (response) |str| self.allocator.free(str); // TODO: This can be improved - while (response == null or (response.?[0] != 'y' and response.?[0] != 'Y' and response.?[0] != 'n' and response.?[0] != 'N')) { + while (response == null + or response.?.len == 0 + or (response.?[0] != 'y' + and response.?[0] != 'Y' + and response.?[0] != 'n' + and response.?[0] != 'N') + ) { if (response) |str| self.allocator.free(str); response = try self.prompt(full_prompt); } -- cgit v1.2.3