diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-09 10:15:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 10:15:18 +0200 |
commit | 1c416892879de6b78038f2cc2f1487eff46abb60 (patch) | |
tree | 3895521bc907b7a0617940c21272ac7ee9f052da /src/nvim/change.c | |
parent | 27118c6eb3351b0df96e2514e8f3806108e50cf7 (diff) | |
parent | 9c93e6461c8c6ec2e8d3e73f506389ac7086d531 (diff) | |
download | rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.gz rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.bz2 rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.zip |
Merge pull request #12971 from vigoux/decurbuf
Decrease reliance on curbuf in BUFEMPTY and `undo.c`
Diffstat (limited to 'src/nvim/change.c')
-rw-r--r-- | src/nvim/change.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index 9880ffa447..ca1ca756bb 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -40,18 +40,18 @@ /// "col" is the column for the message; non-zero when in insert mode and /// 'showmode' is on. /// Careful: may trigger autocommands that reload the buffer. -void change_warning(int col) +void change_warning(buf_T *buf, int col) { static char *w_readonly = N_("W10: Warning: Changing a readonly file"); - if (curbuf->b_did_warn == false + if (buf->b_did_warn == false && curbufIsChanged() == 0 && !autocmd_busy - && curbuf->b_p_ro) { - curbuf_lock++; - apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, false, curbuf); - curbuf_lock--; - if (!curbuf->b_p_ro) { + && buf->b_p_ro) { + buf->b_ro_locked++; + apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, false, buf); + buf->b_ro_locked--; + if (!buf->b_p_ro) { return; } // Do what msg() does, but with a column offset if the warning should @@ -70,7 +70,7 @@ void change_warning(int col) ui_flush(); os_delay(1002L, true); // give the user time to think about it } - curbuf->b_did_warn = true; + buf->b_did_warn = true; redraw_cmdline = false; // don't redraw and erase the message if (msg_row < Rows - 1) { showmode(); @@ -91,7 +91,7 @@ void changed(void) // Give a warning about changing a read-only file. This may also // check-out the file, thus change "curbuf"! - change_warning(0); + change_warning(curbuf, 0); // Create a swap file if that is wanted. // Don't do this for "nofile" and "nowrite" buffer types. |