mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
buffer: don't rely on curbuf in BUFEMPTY
This commit is contained in:
parent
df33f30e88
commit
55a2c513aa
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user