vim-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 vim/vim#3391)  Add tests for 'autowrite'.
8c9e7b00f6
This commit is contained in:
Jan Edmund Lazo
2018-09-03 21:06:59 -04:00
parent 4d6ba4d06a
commit b6e83ba284
2 changed files with 40 additions and 2 deletions

View File

@@ -1209,7 +1209,7 @@ int autowrite(buf_T *buf, int forceit)
return r;
}
/// 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)
{
if (!(p_aw || p_awa) || !p_write) {
@@ -1217,7 +1217,7 @@ void autowrite_all(void)
}
FOR_ALL_BUFFERS(buf) {
if (bufIsChanged(buf) && !buf->b_p_ro) {
if (bufIsChanged(buf) && !buf->b_p_ro && !bt_dontwrite(buf)) {
bufref_T bufref;
set_bufref(&bufref, buf);
(void)buf_write_all(buf, false);