summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Editor.zig18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Editor.zig b/src/Editor.zig
index 99ec932..469fc81 100644
--- a/src/Editor.zig
+++ b/src/Editor.zig
@@ -245,7 +245,7 @@ pub fn promptEx(
245 if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) { 245 if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) {
246 try buf.append(key_char); 246 try buf.append(key_char);
247 } 247 }
248 }, // else ?? 248 }, // TODO: else ??
249 } 249 }
250 250
251 if (callback) |cb| { 251 if (callback) |cb| {
@@ -265,18 +265,20 @@ pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool {
265 var response = try self.prompt(full_prompt); 265 var response = try self.prompt(full_prompt);
266 defer if (response) |str| self.allocator.free(str); 266 defer if (response) |str| self.allocator.free(str);
267 // TODO: This can be improved 267 // TODO: This can be improved
268 while (response == null 268 while (response != null
269 or response.?.len == 0 269 and (response.?.len == 0
270 or (response.?[0] != 'y' 270 or (response.?[0] != 'y'
271 and response.?[0] != 'Y' 271 and response.?[0] != 'Y'
272 and response.?[0] != 'n' 272 and response.?[0] != 'n'
273 and response.?[0] != 'N') 273 and response.?[0] != 'N'
274 )
275 )
274 ) { 276 ) {
275 if (response) |str| self.allocator.free(str); 277 if (response) |str| self.allocator.free(str);
276 response = try self.prompt(full_prompt); 278 response = try self.prompt(full_prompt);
277 } 279 }
278 280
279 return response.?[0] == 'y' or response.?[0] == 'Y'; 281 return response != null and (response.?[0] == 'y' or response.?[0] == 'Y');
280} 282}
281 283
282pub fn putBuffer(self: *Editor, buf_name: []const u8) !*Buffer { 284pub fn putBuffer(self: *Editor, buf_name: []const u8) !*Buffer {