diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-02-12 01:32:52 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-02-12 01:32:52 +0100 |
commit | 7da4d1561bd29615257a3f61073b5cf39f1f7463 (patch) | |
tree | d2e2ec42a187b25d7776d476c06419365845aecf /src | |
parent | c68d89521fc92834086abb6ad5ed12327b62ff60 (diff) | |
download | rneovim-7da4d1561bd29615257a3f61073b5cf39f1f7463.tar.gz rneovim-7da4d1561bd29615257a3f61073b5cf39f1f7463.tar.bz2 rneovim-7da4d1561bd29615257a3f61073b5cf39f1f7463.zip |
lint
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 45 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 21 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 28 | ||||
-rw-r--r-- | src/nvim/normal.c | 2 |
4 files changed, 52 insertions, 44 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 0127b576c9..3958fb05e9 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1407,16 +1407,20 @@ void set_curbuf(buf_T *buf, int action) } if (bufref_valid(&prevbufref) && !aborting()) { win_T *previouswin = curwin; - if (prevbuf == curbuf) - u_sync(FALSE); - close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, - unload ? action : (action == DOBUF_GOTO - && !buf_hide(prevbuf) - && !bufIsChanged( - prevbuf)) ? DOBUF_UNLOAD : 0, FALSE); - if (curwin != previouswin && win_valid(previouswin)) - /* autocommands changed curwin, Grr! */ + if (prevbuf == curbuf) { + u_sync(false); + } + close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, + prevbuf, + unload + ? action + : (action == DOBUF_GOTO && !buf_hide(prevbuf) + && !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, + false); + if (curwin != previouswin && win_valid(previouswin)) { + // autocommands changed curwin, Grr! curwin = previouswin; + } } } /* An autocommand may have deleted "buf", already entered it (e.g., when @@ -4413,7 +4417,7 @@ do_arg_all ( } wp->w_arg_idx = i; - if (i == opened_len && !keep_tabs) { /* close this window */ + if (i == opened_len && !keep_tabs) { // close this window if (buf_hide(buf) || forceit || buf->b_nwindows > 1 || !bufIsChanged(buf)) { /* If the buffer was changed, and we would like to hide it, @@ -4511,14 +4515,15 @@ do_arg_all ( new_curwin = curwin; new_curtab = curtab; } - (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, - ECMD_ONE, - ((buf_hide(curwin->w_buffer) - || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) - + ECMD_OLDBUF, curwin); - if (use_firstwin) - ++autocmd_no_leave; - use_firstwin = FALSE; + (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, ECMD_ONE, + ((buf_hide(curwin->w_buffer) + || bufIsChanged(curwin->w_buffer)) + ? ECMD_HIDE : 0) + ECMD_OLDBUF, + curwin); + if (use_firstwin) { + autocmd_no_leave++; + } + use_firstwin = false; } os_breakcheck(); @@ -4706,13 +4711,13 @@ void ex_buffer_all(exarg_T *eap) */ for (wp = lastwin; open_wins > count; ) { r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer) - || autowrite(wp->w_buffer, FALSE) == OK); + || autowrite(wp->w_buffer, false) == OK); if (!win_valid(wp)) { /* BufWrite Autocommands made the window invalid, start over */ wp = lastwin; } else if (r) { win_close(wp, !buf_hide(wp->w_buffer)); - --open_wins; + open_wins--; wp = lastwin; } else { wp = wp->w_prev; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 629125fa44..2873f76ce0 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2013,8 +2013,9 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, } else other = (fnum != curbuf->b_fnum); - if (other) - ++no_wait_return; /* don't wait for autowrite message */ + if (other) { + no_wait_return++; // don't wait for autowrite message + } if (other && !forceit && curbuf->b_nwindows == 1 && !buf_hide(curbuf) && curbufIsChanged() && autowrite(curbuf, forceit) == FAIL) { if (p_confirm && p_write) @@ -2032,17 +2033,19 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, if (setpm) setpcmark(); if (!other) { - if (lnum != 0) + if (lnum != 0) { curwin->w_cursor.lnum = lnum; + } check_cursor_lnum(); beginline(BL_SOL | BL_FIX); - retval = 0; /* it's in the same file */ + retval = 0; // it's in the same file } else if (do_ecmd(fnum, ffname, sfname, NULL, lnum, - (buf_hide(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0), - curwin) == OK) - retval = -1; /* opened another file */ - else - retval = 1; /* error encountered */ + (buf_hide(curbuf) ? ECMD_HIDE : 0) + + (forceit ? ECMD_FORCEIT : 0), curwin) == OK) { + retval = -1; // opened another file + } else { + retval = 1; // error encountered + } theend: xfree(free_me); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 10a8a1e4dc..e1d28b4a9c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5987,7 +5987,7 @@ static void ex_quit(exarg_T *eap) } // If there are more files or windows we won't exit. - if (check_more(FALSE, eap->forceit) == OK && only_one_window()) { + if (check_more(false, eap->forceit) == OK && only_one_window()) { exiting = true; } if ((!buf_hide(wp->w_buffer) @@ -6007,7 +6007,7 @@ static void ex_quit(exarg_T *eap) if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) { getout(0); } - /* close window; may free buffer */ + // close window; may free buffer win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); } } @@ -6123,11 +6123,12 @@ ex_win_close ( } - /* free buffer when not hiding it or when it's a scratch buffer */ - if (tp == NULL) + // free buffer when not hiding it or when it's a scratch buffer + if (tp == NULL) { win_close(win, !need_hide && !buf_hide(buf)); - else + } else { win_close_othertab(win, !need_hide && !buf_hide(buf), tp); + } } /* @@ -6928,15 +6929,14 @@ do_exedit ( empty buffer */ setpcmark(); if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), - NULL, eap, - eap->do_ecmd_lnum, - (buf_hide(curbuf) ? ECMD_HIDE : 0) - + (eap->forceit ? ECMD_FORCEIT : 0) - // After a split we can use an existing buffer. - + (old_curwin != NULL ? ECMD_OLDBUF : 0) - + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) - , old_curwin == NULL ? curwin : NULL) == FAIL) { - /* Editing the file failed. If the window was split, close it. */ + NULL, eap, eap->do_ecmd_lnum, + (buf_hide(curbuf) ? ECMD_HIDE : 0) + + (eap->forceit ? ECMD_FORCEIT : 0) + // After a split we can use an existing buffer. + + (old_curwin != NULL ? ECMD_OLDBUF : 0) + + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0) + , old_curwin == NULL ? curwin : NULL) == FAIL) { + // Editing the file failed. If the window was split, close it. if (old_curwin != NULL) { need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); if (!need_hide || buf_hide(curbuf)) { diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e698236d1b..fbbc8248e8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5235,7 +5235,7 @@ static void nv_gotofile(cmdarg_T *cap) } setpcmark(); (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, - buf_hide(curbuf) ? ECMD_HIDE : 0, curwin); + buf_hide(curbuf) ? ECMD_HIDE : 0, curwin); if (cap->nchar == 'F' && lnum >= 0) { curwin->w_cursor.lnum = lnum; check_cursor_lnum(); |