# HG changeset patch # User Bram Moolenaar # Date 1634230807 -7200 # Node ID 560132056b97e92edf5ad9fb8aaa453457ce3743 # Parent 8b36e7633cee03a1eff93645d37948e149ff8f16 patch 8.2.3509: undo file is not synced Commit: https://github.com/vim/vim/commit/340dd0fbe462a15a9678cfba02085b4adcc45f02 Author: Bram Moolenaar Date: Thu Oct 14 17:52:23 2021 +0100 patch 8.2.3509: undo file is not synced Problem: Undo file is not synced. (Sami Farin) Solution: Sync the undo file if 'fsync' is set. (Christian Brabandt, closes #8879, closes #8920) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3610,8 +3610,8 @@ A jump table for the options with a shor systems without an fsync() implementation, this variable is always off. Also see 'swapsync' for controlling fsync() on swap files. - 'fsync' also applies to |writefile()|, unless a flag is used to - overrule it. + 'fsync' also applies to |writefile()| (unless a flag is used to + overrule it) and when writing undo files (see |undo-persistence|). This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. diff --git a/src/undo.c b/src/undo.c --- a/src/undo.c +++ b/src/undo.c @@ -1786,6 +1786,11 @@ u_write_undo( write_ok = FALSE; #endif +#if defined(UNIX) && defined(HAVE_FSYNC) + if (p_fs && fflush(fp) == 0 && vim_fsync(fd) != 0) + write_ok = FALSE; +#endif + write_error: fclose(fp); if (!write_ok) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3509, +/**/ 3508, /**/ 3507,