From 498731615c2f879c0b67323aba385c17a4a39d24 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 21 Apr 2018 00:34:13 +0200 Subject: IO: let 'fsync' option control more cases Vim has the 'swapsync' option which we removed in 62d137ce0969. Instead let 'fsync' control swapfile-fsync. These cases ALWAYS force fsync (ignoring 'fsync' option): - Idle (CursorHold). - Exit caused by deadly signal. - SIGPWR signal. - Explicit :preserve command. --- src/nvim/getchar.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/nvim/getchar.c') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 98164b2653..3541ba7cc8 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1347,14 +1347,17 @@ void before_blocking(void) * All the changed memfiles are synced if c == 0 or when the number of typed * characters reaches 'updatecount' and 'updatecount' is non-zero. */ -void updatescript(int c) +static void updatescript(int c) { static int count = 0; - if (c && scriptout) + if (c && scriptout) { putc(c, scriptout); - if (c == 0 || (p_uc > 0 && ++count >= p_uc)) { - ml_sync_all(c == 0, TRUE); + } + bool idle = (c == 0); + if (idle || (p_uc > 0 && ++count >= p_uc)) { + ml_sync_all(idle, true, + (!!p_fs || idle)); // Always fsync at idle (CursorHold). count = 0; } } -- cgit