From 7e0083aabffdb2937b65f8e9daf01a8fb90da524 Mon Sep 17 00:00:00 2001 From: edyfox Date: Tue, 13 Feb 2007 05:56:31 +0000 Subject: [PATCH] Patch 7.0.195 Problem: When a buffer is modified and 'autowriteall' is set, ":quit" results in an endless loop when there is a conversion error while writing. (Nikolai Weibull) Solution: Make autowrite() return FAIL if the buffer is still changed after writing it. Files: src/ex_cmds2.c git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/vim7@212 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/ex_cmds2.c | 18 ++++++++++++++---- src/version.c | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 6396ee11..e5e1f65c 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1242,14 +1242,22 @@ autowrite(buf, forceit) buf_T *buf; int forceit; { + int r; + if (!(p_aw || p_awa) || !p_write #ifdef FEAT_QUICKFIX - /* never autowrite a "nofile" or "nowrite" buffer */ - || bt_dontwrite(buf) + /* never autowrite a "nofile" or "nowrite" buffer */ + || bt_dontwrite(buf) #endif - || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) + || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) return FAIL; - return buf_write_all(buf, forceit); + r = buf_write_all(buf, forceit); + + /* Writing may succeed but the buffer still changed, e.g., when there is a + * conversion error. We do want to return FAIL then. */ + if (buf_valid(buf) && bufIsChanged(buf)) + r = FAIL; + return r; } /* @@ -1472,6 +1480,8 @@ check_changed_any(hidden) if (buf == NULL) /* No buffers changed */ return FALSE; + /* Try auto-writing the buffer. If this fails but the buffer no + * longer exists it's not changed, that's OK. */ if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf)) break; /* didn't save - still changes */ } diff --git a/src/version.c b/src/version.c index 0c45c476..d60f52d0 100644 --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 195, +/**/ 194, /**/ 193, -- 2.11.4.GIT