From 55a2c513aafb386c01259fca711b2e0f9b85e359 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Wed, 16 Sep 2020 22:57:34 +0200 Subject: buffer: don't rely on curbuf in BUFEMPTY --- src/nvim/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/fileio.c') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 29c29a2884..645423eafe 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5027,7 +5027,7 @@ void buf_reload(buf_T *buf, int orig_mode) // buffer contents. But if reading the file fails we should keep // the old contents. Can't use memory only, the file might be // too big. Use a hidden buffer to move the buffer contents to. - if (BUFEMPTY() || saved == FAIL) { + if (BUFEMPTY(curbuf) || saved == FAIL) { savebuf = NULL; } else { // Allocate a buffer without putting it in the buffer list. @@ -5060,7 +5060,7 @@ void buf_reload(buf_T *buf, int orig_mode) if (savebuf != NULL && bufref_valid(&bufref) && buf == curbuf) { // Put the text back from the save buffer. First // delete any lines that readfile() added. - while (!BUFEMPTY()) { + while (!BUFEMPTY(curbuf)) { if (ml_delete(buf->b_ml.ml_line_count, false) == FAIL) { break; } -- cgit From 763c852812c8c7e819881a76a237b6f19920f803 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Wed, 23 Sep 2020 22:45:51 +0200 Subject: undo: reduce reliance on curbuf --- src/nvim/fileio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/fileio.c') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 645423eafe..5d44a70a05 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -4687,7 +4687,7 @@ check_timestamps( } if (!stuff_empty() || global_busy || !typebuf_typed() - || autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0 + || autocmd_busy || curbuf->b_ro_locked > 0 || allbuf_lock > 0 ) { need_check_timestamps = true; // check later } else { @@ -5015,10 +5015,10 @@ void buf_reload(buf_T *buf, int orig_mode) old_topline = curwin->w_topline; if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur) { - /* Save all the text, so that the reload can be undone. - * Sync first so that this is a separate undo-able action. */ - u_sync(FALSE); - saved = u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE); + // Save all the text, so that the reload can be undone. + // Sync first so that this is a separate undo-able action. + u_sync(false); + saved = u_savecommon(curbuf, 0, curbuf->b_ml.ml_line_count + 1, 0, true); flags |= READ_KEEP_UNDO; } -- cgit From 7970631fa01e95a41ba4520e030e6208c8fb3648 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Tue, 24 Nov 2020 08:48:05 +0100 Subject: buffer: move BUFEMPTY to a function --- src/nvim/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/fileio.c') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 5d44a70a05..1203e231ac 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5027,7 +5027,7 @@ void buf_reload(buf_T *buf, int orig_mode) // buffer contents. But if reading the file fails we should keep // the old contents. Can't use memory only, the file might be // too big. Use a hidden buffer to move the buffer contents to. - if (BUFEMPTY(curbuf) || saved == FAIL) { + if (buf_is_empty(curbuf) || saved == FAIL) { savebuf = NULL; } else { // Allocate a buffer without putting it in the buffer list. @@ -5060,7 +5060,7 @@ void buf_reload(buf_T *buf, int orig_mode) if (savebuf != NULL && bufref_valid(&bufref) && buf == curbuf) { // Put the text back from the save buffer. First // delete any lines that readfile() added. - while (!BUFEMPTY(curbuf)) { + while (!buf_is_empty(curbuf)) { if (ml_delete(buf->b_ml.ml_line_count, false) == FAIL) { break; } -- cgit