patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Problem: 'autowrite' takes effect when buffer is not to be written.
Solution: Don't write buffers that are not supposed to be written. (Even Q
Jones, closes #3391) Add tests for 'autowrite'.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index cb04635..89effa1 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2041,7 +2041,7 @@
}
/*
- * flush all buffers, except the ones that are readonly
+ * Flush all buffers, except the ones that are readonly or are never written.
*/
void
autowrite_all(void)
@@ -2051,7 +2051,7 @@
if (!(p_aw || p_awa) || !p_write)
return;
FOR_ALL_BUFFERS(buf)
- if (bufIsChanged(buf) && !buf->b_p_ro)
+ if (bufIsChanged(buf) && !buf->b_p_ro && !bt_dontwrite(buf))
{
bufref_T bufref;