Show feedback to user when trying to quit with dirty buffers
This commit is contained in:
parent
552417091d
commit
d3e601e774
4 changed files with 58 additions and 13 deletions
|
@ -273,7 +273,13 @@ const cmds = struct {
|
|||
const Result = command.Result;
|
||||
|
||||
pub fn quit(self: *Self, _: Ctx) Result {
|
||||
try self.check_all_not_dirty();
|
||||
const logger = log.logger("buffer");
|
||||
defer logger.deinit();
|
||||
self.check_all_not_dirty() catch |err| {
|
||||
const dirties = self.buffer_manager.number_of_dirties();
|
||||
logger.print("There are {} unsaved buffer(s), use 'quit without saving' if not needed to save them", .{dirties});
|
||||
return err;
|
||||
};
|
||||
try tp.self_pid().send("quit");
|
||||
}
|
||||
pub const quit_meta: Meta = .{ .description = "Quit" };
|
||||
|
|
|
@ -163,9 +163,16 @@ const cmds_ = struct {
|
|||
pub const @"bco!_meta": Meta = .{ .description = "bco! (Close other buffers/tabs forcefully, ignoring changes)" };
|
||||
|
||||
pub fn bco(_: *void, _: Ctx) Result {
|
||||
const logger = log.logger("helix-mode");
|
||||
defer logger.deinit();
|
||||
const mv = tui.mainview() orelse return;
|
||||
const bm = tui.get_buffer_manager() orelse return;
|
||||
if (mv.get_active_buffer()) |buffer| _ = bm.close_others(buffer);
|
||||
if (mv.get_active_buffer()) |buffer| {
|
||||
const remaining = bm.close_others(buffer);
|
||||
if (remaining > 0) {
|
||||
logger.print("{} unsaved buffer(s) remaining", .{remaining});
|
||||
}
|
||||
}
|
||||
}
|
||||
pub const bco_meta: Meta = .{ .description = "bco (Close other buffers/tabs, except this one)" };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue