diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-09-23 22:45:51 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-07-06 19:08:32 +0200 |
commit | 763c852812c8c7e819881a76a237b6f19920f803 (patch) | |
tree | a2892e9cf4e89e5f58ed4870bf40af3f816f33f7 /src/nvim/change.c | |
parent | 55a2c513aafb386c01259fca711b2e0f9b85e359 (diff) | |
download | rneovim-763c852812c8c7e819881a76a237b6f19920f803.tar.gz rneovim-763c852812c8c7e819881a76a237b6f19920f803.tar.bz2 rneovim-763c852812c8c7e819881a76a237b6f19920f803.zip |
undo: reduce reliance on curbuf
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 c0183d4317..ca98d8f40b 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. |