summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2007-02-13 05:19:30 +0000
committerBram Moolenaar <Bram@vim.org>2007-02-13 05:19:30 +0000
commit373154b00c90a7fe81409f471075a62ef3dfbc25 (patch)
tree68ac660c8aa7535496fbc752de2d83ecf18949da /src/ex_cmds2.c
parentad40f02cd9a306924352c1647186ce745489fcfb (diff)
updated for version 7.0-195v7.0.195
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 6396ee115e..e5e1f65c6d 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 */
}