aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-15 16:49:00 +0800
committerGitHub <noreply@github.com>2022-07-15 16:49:00 +0800
commit564d99c89a3d9a236df758d320cc38abc50215ec (patch)
tree9798e6718ce448953e32caf604641b063f58b5fc /src
parent9777907467b29e890556db287b6a9995c0024896 (diff)
parenta649af4dbaba5ef13dcbf610fe584dbc67cf2435 (diff)
downloadrneovim-564d99c89a3d9a236df758d320cc38abc50215ec.tar.gz
rneovim-564d99c89a3d9a236df758d320cc38abc50215ec.tar.bz2
rneovim-564d99c89a3d9a236df758d320cc38abc50215ec.zip
Merge pull request #19373 from zeertzjq/vim-8.2.0426
vim-patch:8.0.1118,8.2.0426
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c11
-rw-r--r--src/nvim/ex_cmds.c3
-rw-r--r--src/nvim/ex_cmds2.c6
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/move.c6
-rw-r--r--src/nvim/normal.c3
-rw-r--r--src/nvim/tag.c3
-rw-r--r--src/nvim/testdir/test_buffer.vim1
-rw-r--r--src/nvim/testdir/test_normal.vim2
-rw-r--r--src/nvim/testdir/test_options.vim11
-rw-r--r--src/nvim/testdir/test_window_cmd.vim29
11 files changed, 59 insertions, 21 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 69aaee4f9b..09f5ebe217 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -94,11 +94,19 @@ static char *e_buflocked = N_("E937: Attempt to delete a buffer that is in use")
// Number of times free_buffer() was called.
static int buf_free_count = 0;
+static int top_file_num = 1; ///< highest file number
+
typedef enum {
kBffClearWinInfo = 1,
kBffInitChangedtick = 2,
} BufFreeFlags;
+/// @return the highest possible buffer number
+int get_highest_fnum(void)
+{
+ return top_file_num - 1;
+}
+
/// Read data from buffer for retrying.
///
/// @param read_stdin read file from stdin, otherwise fifo
@@ -443,6 +451,7 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i
return false;
}
+ // check no autocommands closed the window
if (win != NULL // Avoid bogus clang warning.
&& win_valid_any_tab(win)) {
// Set b_last_cursor when closing the last window for the buffer.
@@ -1643,8 +1652,6 @@ void no_write_message_nobang(const buf_T *const buf)
// functions for dealing with the buffer list
//
-static int top_file_num = 1; ///< highest file number
-
/// Initialize b:changedtick and changedtick_val attribute
///
/// @param[out] buf Buffer to initialize for.
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 4c711d3ebc..9a5cf9f50f 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4862,8 +4862,7 @@ void ex_help(exarg_T *eap)
* Re-use an existing help window or open a new one.
* Always open a new one for ":tab help".
*/
- if (!bt_help(curwin->w_buffer)
- || cmdmod.cmod_tab != 0) {
+ if (!bt_help(curwin->w_buffer) || cmdmod.cmod_tab != 0) {
if (cmdmod.cmod_tab != 0) {
wp = NULL;
} else {
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 897928abec..e57dc5d13f 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1018,8 +1018,7 @@ void check_arg_idx(win_T *win)
// We are editing the current entry in the argument list.
// Set "arg_had_last" if it's also the last one
win->w_arg_idx_invalid = false;
- if (win->w_arg_idx == WARGCOUNT(win) - 1
- && win->w_alist == &global_alist) {
+ if (win->w_arg_idx == WARGCOUNT(win) - 1 && win->w_alist == &global_alist) {
arg_had_last = true;
}
}
@@ -1150,8 +1149,7 @@ void do_argfile(exarg_T *eap, int argn)
}
curwin->w_arg_idx = argn;
- if (argn == ARGCOUNT - 1
- && curwin->w_alist == &global_alist) {
+ if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist) {
arg_had_last = true;
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9e8262fdfc..4e6846bf21 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4616,8 +4616,9 @@ char *invalid_range(exarg_T *eap)
}
break;
case ADDR_BUFFERS:
- if (eap->line1 < firstbuf->b_fnum
- || eap->line2 > lastbuf->b_fnum) {
+ // Only a boundary check, not whether the buffers actually
+ // exist.
+ if (eap->line1 < 1 || eap->line2 > get_highest_fnum()) {
return _(e_invrange);
}
break;
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 99ca5060cd..bd68ad6f97 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -786,8 +786,7 @@ void curs_columns(win_T *wp, int may_scroll)
} else {
wp->w_wrow = wp->w_height_inner - 1 - wp->w_empty_rows;
}
- } else if (wp->w_p_wrap
- && wp->w_width_inner != 0) {
+ } else if (wp->w_p_wrap && wp->w_width_inner != 0) {
width = textwidth + win_col_off2(wp);
// long line wrapping, adjust wp->w_wrow
@@ -1083,8 +1082,7 @@ bool scrolldown(long line_count, int byfold)
* and move the cursor onto the displayed part of the window.
*/
int wrow = curwin->w_wrow;
- if (curwin->w_p_wrap
- && curwin->w_width_inner != 0) {
+ if (curwin->w_p_wrap && curwin->w_width_inner != 0) {
validate_virtcol();
validate_cheight();
wrow += curwin->w_cline_height - 1 -
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 0eb8a8f59b..b675abfb7d 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -6012,8 +6012,7 @@ static void nv_g_home_m_cmd(cmdarg_T *cap)
cap->oap->motion_type = kMTCharWise;
cap->oap->inclusive = false;
- if (curwin->w_p_wrap
- && curwin->w_width_inner != 0) {
+ if (curwin->w_p_wrap && curwin->w_width_inner != 0) {
int width1 = curwin->w_width_inner - curwin_col_off();
int width2 = width1 + curwin_col_off2();
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 5b62d11bc9..28b3b6c1ef 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1863,6 +1863,7 @@ parse_line:
// For "normal" tags: Do a quick check if the tag matches.
// This speeds up tag searching a lot!
if (orgpat.headlen) {
+ memset(&tagp, 0, sizeof(tagp));
tagp.tagname = lbuf;
tagp.tagname_end = (char_u *)vim_strchr((char *)lbuf, TAB);
if (tagp.tagname_end == NULL) {
@@ -2784,7 +2785,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
// A :ta from a help file will keep the b_help flag set. For ":ptag"
// we need to use the flag from the window where we came from.
if (l_g_do_tagpreview != 0) {
- keep_help_flag = curwin_save->w_buffer->b_help;
+ keep_help_flag = bt_help(curwin_save->w_buffer);
} else {
keep_help_flag = curbuf->b_help;
}
diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim
index 4cc559adb8..67be3e6747 100644
--- a/src/nvim/testdir/test_buffer.vim
+++ b/src/nvim/testdir/test_buffer.vim
@@ -146,6 +146,7 @@ endfunc
func Test_bdelete_cmd()
%bwipe!
call assert_fails('bdelete 5', 'E516:')
+ call assert_fails('1,1bdelete 1 2', 'E488:')
" Deleting a unlisted and unloaded buffer
edit Xfile1
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index d1d914d0b6..2d5b66df26 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -2656,7 +2656,7 @@ func Test_normal49_counts()
endfunc
func Test_normal50_commandline()
- if !has("timers") || !has("cmdline_hist") || !has("vertsplit")
+ if !has("timers") || !has("cmdline_hist")
return
endif
func! DoTimerWork(id)
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 7b6cfa6bb4..9f89d47758 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -290,9 +290,10 @@ func Test_set_errors()
call assert_fails('set regexpengine=3', 'E474:')
call assert_fails('set history=10001', 'E474:')
call assert_fails('set numberwidth=21', 'E474:')
- call assert_fails('set colorcolumn=-a')
- call assert_fails('set colorcolumn=a')
- call assert_fails('set colorcolumn=1,')
+ call assert_fails('set colorcolumn=-a', 'E474:')
+ call assert_fails('set colorcolumn=a', 'E474:')
+ call assert_fails('set colorcolumn=1,', 'E474:')
+ call assert_fails('set colorcolumn=1;', 'E474:')
call assert_fails('set cmdheight=-1', 'E487:')
call assert_fails('set cmdwinheight=-1', 'E487:')
if has('conceal')
@@ -343,9 +344,13 @@ func Test_set_errors()
call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
call assert_fails('set guicursor=i-ci', 'E545:')
call assert_fails('set guicursor=x', 'E545:')
+ call assert_fails('set guicursor=x:', 'E546:')
call assert_fails('set guicursor=r-cr:horx', 'E548:')
call assert_fails('set guicursor=r-cr:hor0', 'E549:')
endif
+ if has('mouseshape')
+ call assert_fails('se mouseshape=i-r:x', 'E547:')
+ endif
call assert_fails('set backupext=~ patchmode=~', 'E589:')
call assert_fails('set winminheight=10 winheight=9', 'E591:')
call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index cbc8ad05d2..41b0cd874c 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -172,6 +172,35 @@ func Test_window_split_edit_bufnr()
%bw!
endfunc
+func Test_window_split_no_room()
+ " N horizontal windows need >= 2*N + 1 lines:
+ " - 1 line + 1 status line in each window
+ " - 1 Ex command line
+ "
+ " 2*N + 1 <= &lines
+ " N <= (lines - 1)/2
+ "
+ " Beyond that number of windows, E36: Not enough room is expected.
+ let hor_win_count = (&lines - 1)/2
+ let hor_split_count = hor_win_count - 1
+ for s in range(1, hor_split_count) | split | endfor
+ call assert_fails('split', 'E36:')
+
+ " N vertical windows need >= 2*(N - 1) + 1 columns:
+ " - 1 column + 1 separator for each window (except last window)
+ " - 1 column for the last window which does not have separator
+ "
+ " 2*(N - 1) + 1 <= &columns
+ " 2*N - 1 <= &columns
+ " N <= (&columns + 1)/2
+ let ver_win_count = (&columns + 1)/2
+ let ver_split_count = ver_win_count - 1
+ for s in range(1, ver_split_count) | vsplit | endfor
+ call assert_fails('vsplit', 'E36:')
+
+ %bw!
+endfunc
+
func Test_window_exchange()
e Xa