From: Michael D. Lowis Date: Wed, 30 Nov 2016 00:17:06 +0000 (-0500) Subject: cleaned up logic for quit with unsaved changes X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9675e1a55588988a8580870c661bb42704c4172b;p=projs%2Ftide.git cleaned up logic for quit with unsaved changes --- diff --git a/xedit.c b/xedit.c index b2acfe4..a89cd2f 100644 --- a/xedit.c +++ b/xedit.c @@ -413,16 +413,14 @@ static void change_focus(void) { } static void quit(void) { - static uint64_t num_clicks = 0; - static uint64_t prevtime = 0; + static uint64_t before = 0; uint64_t now = getmillis(); - num_clicks = (now - prevtime < 250 ? num_clicks+1 : 1); - prevtime = now; - if (!getbuf(EDIT)->modified || num_clicks >= 2) + if (!getbuf(EDIT)->modified || (now-before) <= 250) exit(0); else view_append(getview(TAGS), "File is modified. Double click Quit tag or press Ctrl+Q twice to discard changes."); + before = now; } static void save(void) { diff --git a/xpick b/xpick new file mode 100755 index 0000000..a0917fb Binary files /dev/null and b/xpick differ