diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 8 | ||||
-rw-r--r-- | src/nvim/diff.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/fileio.c | 4 | ||||
-rw-r--r-- | src/nvim/macros.h | 4 | ||||
-rw-r--r-- | src/nvim/main.c | 4 | ||||
-rw-r--r-- | src/nvim/move.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 2 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | src/nvim/undo.c | 2 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
13 files changed, 18 insertions, 20 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 09bb230ff5..5e300a5df5 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -139,7 +139,7 @@ read_buffer( if (read_stdin) { // Set or reset 'modified' before executing autocommands, so that // it can be changed there. - if (!readonlymode && !BUFEMPTY()) { + if (!readonlymode && !BUFEMPTY(curbuf)) { changed(); } else if (retval != FAIL) { unchanged(curbuf, false, true); @@ -1921,7 +1921,7 @@ bool curbuf_reusable(void) return (curbuf != NULL && curbuf->b_ffname == NULL && curbuf->b_nwindows <= 1 - && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()) + && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY(curbuf)) && !bt_quickfix(curbuf) && !curbufIsChanged()); } @@ -2061,7 +2061,7 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit) // If 'switchbuf' contains "split", "vsplit" or "newtab" and the // current buffer isn't empty: open new tab or window if (wp == NULL && (swb_flags & (SWB_VSPLIT | SWB_SPLIT | SWB_NEWTAB)) - && !BUFEMPTY()) { + && !BUFEMPTY(curbuf)) { if (swb_flags & SWB_NEWTAB) { tabpage_new(); } else if (win_split(0, (swb_flags & SWB_VSPLIT) ? WSP_VERT : 0) @@ -4951,7 +4951,7 @@ do_arg_all( win_enter(lastwin, false); // ":tab drop file" should re-use an empty window to avoid "--remote-tab" // leaving an empty tab page when executed locally. - if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 + if (keep_tabs && BUFEMPTY(curbuf) && curbuf->b_nwindows == 1 && curbuf->b_ffname == NULL && !curbuf->b_changed) { use_firstwin = true; tab_drop_empty_window = true; diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 5f8b81822b..53cb14bcc7 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2669,7 +2669,7 @@ void ex_diffgetput(exarg_T *eap) } } - buf_empty = BUFEMPTY(); + buf_empty = BUFEMPTY(curbuf); added = 0; for (i = 0; i < count; ++i) { diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1579f3ff98..5887817ec3 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -8047,7 +8047,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) // can't backup past first character in buffer // can't backup past starting point unless 'backspace' > 1 // can backup to a previous line if 'backspace' == 0 - if (BUFEMPTY() + if (BUFEMPTY(curbuf) || (!revins_on && ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0) || (!can_bs(BS_START) 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; } diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 48a16ed42a..dce1e73dfd 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -35,8 +35,8 @@ #define LINEEMPTY(p) (*ml_get(p) == NUL) /// BUFEMPTY() - return TRUE if the current buffer is empty -#define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == \ - NUL) +#define BUFEMPTY(buf) ((buf)->b_ml.ml_line_count == 1 \ + && *ml_get_buf((buf), (linenr_T)1, false) == '\0') // toupper() and tolower() that use the current locale. // Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the diff --git a/src/nvim/main.c b/src/nvim/main.c index 2cb562b558..9bccca85ee 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1444,11 +1444,9 @@ static void read_stdin(void) no_wait_return = true; int save_msg_didany = msg_didany; set_buflisted(true); - // Create memfile and read from stdin. (void)open_buffer(true, NULL, 0); - - if (BUFEMPTY() && curbuf->b_next != NULL) { + if (BUFEMPTY(curbuf) && curbuf->b_next != NULL) { // stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561 do_cmdline_cmd("silent! bnext"); // Delete the empty stdin buffer. diff --git a/src/nvim/move.c b/src/nvim/move.c index 1210a3365a..dee46d6291 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -172,7 +172,7 @@ void update_topline(win_T *wp) old_topfill = wp->w_topfill; // If the buffer is empty, always set topline to 1. - if (BUFEMPTY()) { // special case - file is empty + if (BUFEMPTY(curbuf)) { // special case - file is empty if (wp->w_topline != 1) { redraw_later(wp, NOT_VALID); } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 855f63ba7b..545ab8a94a 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3069,7 +3069,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } // In an empty buffer the empty line is going to be replaced, include // it in the saved lines. - if ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL) { + if ((BUFEMPTY(curbuf) ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL) { goto end; } if (dir == FORWARD) { diff --git a/src/nvim/option.c b/src/nvim/option.c index 388bedc043..113297412c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -880,7 +880,7 @@ void set_init_3(void) xfree(p); } - if (BUFEMPTY()) { + if (BUFEMPTY(curbuf)) { int idx_ffs = findoption_len(S_LEN("ffs")); // Apply the first entry of 'fileformats' to the initial buffer. diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index f620517aff..ef9346b6c8 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -735,7 +735,7 @@ static int pum_set_selected(int n, int repeat) && (curbuf->b_p_bt[2] == 'f') && (curbuf->b_p_bh[0] == 'w')) { // Already a "wipeout" buffer, make it empty. - while (!BUFEMPTY()) { + while (!BUFEMPTY(curbuf)) { ml_delete((linenr_T)1, false); } } else { diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 771c2106db..f09223eab5 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -6672,7 +6672,7 @@ void ex_spelldump(exarg_T *eap) set_option_value("spl", dummy, (char *)spl, OPT_LOCAL); xfree(spl); - if (!BUFEMPTY()) { + if (!BUFEMPTY(curbuf)) { return; } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index ffd613cec2..2010aa42d8 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -2414,7 +2414,7 @@ static void u_undoredo(int undo, bool do_buf_event) curhead->uh_entry = newlist; curhead->uh_flags = new_flags; - if ((old_flags & UH_EMPTYBUF) && BUFEMPTY()) { + if ((old_flags & UH_EMPTYBUF) && BUFEMPTY(curbuf)) { curbuf->b_ml.ml_flags |= ML_EMPTY; } if (old_flags & UH_CHANGED) { diff --git a/src/nvim/version.c b/src/nvim/version.c index f3a30630f8..507352e146 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2190,7 +2190,7 @@ void list_version(void) /// Show the intro message when not editing a file. void maybe_intro_message(void) { - if (BUFEMPTY() + if (BUFEMPTY(curbuf) && (curbuf->b_fname == NULL) && (firstwin->w_next == NULL) && (vim_strchr(p_shm, SHM_INTRO) == NULL)) { |