From 2339d78cbd562319473a34a36390378df64ade00 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Tue, 11 Sep 2018 18:16:02 +0200 Subject: Quit, autosave and interactive save Quitting calcurse with auto_save on may lead to an interactive conflict resolution for the save operation. When the result is a cancellation of the save, the quit command is also cancelled. Signed-off-by: Lukas Fleischer --- src/calcurse.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/calcurse.c b/src/calcurse.c index 16d979f..0f6b69a 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -509,7 +509,11 @@ static inline void key_generic_scroll_down(void) static inline void key_generic_quit(void) { if (conf.auto_save) - io_save_cal(interactive); + if (io_save_cal(interactive) == IO_SAVE_CANCEL) { + /* Cancel quit as well. */ + wins_update(FLAG_STA); + return; + } if (conf.auto_gc) note_gc(); @@ -544,7 +548,12 @@ static inline void key_generic_cmd(void) if (!strcmp(cmd_name, "write") || !strcmp(cmd_name, "w") || !strcmp(cmd_name, "wq")) { - io_save_cal(interactive); + if (io_save_cal(interactive) == IO_SAVE_CANCEL && + strcmp(cmd_name, "wq") == 0) { + /* Cancel quit as well. */ + wins_update(FLAG_STA); + return; + } valid = 1; } if (!strcmp(cmd_name, "quit") || !strcmp(cmd_name, "q") || -- cgit v1.2.3-70-g09d2