mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #21219 from neovim/backport-20894-to-release-0.8
[Backport release-0.8] vim-patch:9.0.0821: crash with win_move_statusline() in another tabpage
This commit is contained in:
@@ -113,6 +113,8 @@ PRAGMA_DIAG_POP
|
|||||||
static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
|
static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
|
||||||
static char *e_invalwindow = N_("E957: Invalid window number");
|
static char *e_invalwindow = N_("E957: Invalid window number");
|
||||||
static char *e_reduceempty = N_("E998: Reduce of an empty %s with no initial value");
|
static char *e_reduceempty = N_("E998: Reduce of an empty %s with no initial value");
|
||||||
|
static char e_cannot_resize_window_in_another_tab_page[]
|
||||||
|
= N_("E1308: Cannot resize a window in another tab page");
|
||||||
|
|
||||||
/// Dummy va_list for passing to vim_snprintf
|
/// Dummy va_list for passing to vim_snprintf
|
||||||
///
|
///
|
||||||
@@ -9704,6 +9706,10 @@ static void f_win_move_statusline(typval_T *argvars, typval_T *rettv, EvalFuncDa
|
|||||||
if (wp == NULL || wp->w_floating) {
|
if (wp == NULL || wp->w_floating) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!win_valid(wp)) {
|
||||||
|
emsg(_(e_cannot_resize_window_in_another_tab_page));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
offset = (int)tv_get_number(&argvars[1]);
|
offset = (int)tv_get_number(&argvars[1]);
|
||||||
win_drag_status_line(wp, offset);
|
win_drag_status_line(wp, offset);
|
||||||
|
@@ -1451,17 +1451,20 @@ func Test_win_move_statusline()
|
|||||||
call assert_true(id->win_move_statusline(-offset))
|
call assert_true(id->win_move_statusline(-offset))
|
||||||
call assert_equal(h, winheight(id))
|
call assert_equal(h, winheight(id))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" check that win_move_statusline doesn't error with offsets beyond moving
|
" check that win_move_statusline doesn't error with offsets beyond moving
|
||||||
" possibility
|
" possibility
|
||||||
call assert_true(win_move_statusline(id, 5000))
|
call assert_true(win_move_statusline(id, 5000))
|
||||||
call assert_true(winheight(id) > h)
|
call assert_true(winheight(id) > h)
|
||||||
call assert_true(win_move_statusline(id, -5000))
|
call assert_true(win_move_statusline(id, -5000))
|
||||||
call assert_true(winheight(id) < h)
|
call assert_true(winheight(id) < h)
|
||||||
|
|
||||||
" check that win_move_statusline returns false for an invalid window
|
" check that win_move_statusline returns false for an invalid window
|
||||||
wincmd =
|
wincmd =
|
||||||
let h = winheight(0)
|
let h = winheight(0)
|
||||||
call assert_false(win_move_statusline(-1, 1))
|
call assert_false(win_move_statusline(-1, 1))
|
||||||
call assert_equal(h, winheight(0))
|
call assert_equal(h, winheight(0))
|
||||||
|
|
||||||
" check that win_move_statusline returns false for a floating window
|
" check that win_move_statusline returns false for a floating window
|
||||||
let id = nvim_open_win(
|
let id = nvim_open_win(
|
||||||
\ 0, 0, #{relative: 'editor', row: 2, col: 2, width: 5, height: 3})
|
\ 0, 0, #{relative: 'editor', row: 2, col: 2, width: 5, height: 3})
|
||||||
@@ -1469,6 +1472,13 @@ func Test_win_move_statusline()
|
|||||||
call assert_false(win_move_statusline(id, 1))
|
call assert_false(win_move_statusline(id, 1))
|
||||||
call assert_equal(h, winheight(id))
|
call assert_equal(h, winheight(id))
|
||||||
call nvim_win_close(id, 1)
|
call nvim_win_close(id, 1)
|
||||||
|
|
||||||
|
" check that using another tabpage fails without crash
|
||||||
|
let id = win_getid()
|
||||||
|
tabnew
|
||||||
|
call assert_fails('call win_move_statusline(id, -1)', 'E1308:')
|
||||||
|
tabclose
|
||||||
|
|
||||||
%bwipe!
|
%bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user