diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 11 | ||||
-rw-r--r-- | src/nvim/eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_bufwintabinfo.vim | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_options.vim | 14 | ||||
-rw-r--r-- | src/nvim/testdir/test_tabpage.vim | 66 | ||||
-rw-r--r-- | src/nvim/testdir/test_window_cmd.vim | 13 |
8 files changed, 99 insertions, 42 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 86f57ee5a2..4bb7a45232 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10262,8 +10262,10 @@ static dict_T *get_win_info(win_T *wp, int16_t tpnr, int16_t winnr) tv_dict_add_nr(dict, S_LEN("winnr"), winnr); tv_dict_add_nr(dict, S_LEN("winid"), wp->handle); tv_dict_add_nr(dict, S_LEN("height"), wp->w_height); + tv_dict_add_nr(dict, S_LEN("winrow"), wp->w_winrow); tv_dict_add_nr(dict, S_LEN("width"), wp->w_width); tv_dict_add_nr(dict, S_LEN("bufnr"), wp->w_buffer->b_fnum); + tv_dict_add_nr(dict, S_LEN("wincol"), wp->w_wincol); tv_dict_add_nr(dict, S_LEN("quickfix"), bt_quickfix(wp->w_buffer)); tv_dict_add_nr(dict, S_LEN("loclist"), @@ -10310,6 +10312,15 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } +// "win_screenpos()" function +static void f_win_screenpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + tv_list_alloc_ret(rettv, 2); + const win_T *const wp = find_win_by_nr(&argvars[0], NULL); + tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1); + tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1); +} + /* * "getwinposx()" function */ diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 23959f348a..328f46443f 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -338,6 +338,7 @@ return { win_gotoid={args=1}, win_id2tabwin={args=1}, win_id2win={args=1}, + win_screenpos={args=1}, winbufnr={args=1}, wincol={}, winheight={args=1}, diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 4dcecae9d8..c9eccfa6b0 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1595,15 +1595,16 @@ void ex_file(exarg_T *eap) } if (*eap->arg != NUL || eap->addr_count == 1) { - if (rename_buffer(eap->arg) == FAIL) + if (rename_buffer(eap->arg) == FAIL) { return; + } + redraw_tabline = true; } - if (!shortmess(SHM_FILEINFO)) { - // print full file name if :cd used + // print file name if no argument or 'F' is not in 'shortmess' + if (*eap->arg == NUL || !shortmess(SHM_FILEINFO)) { fileinfo(false, false, eap->forceit); } - redraw_tabline = true; } /* diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim index a592cd7b11..a6b4524cc0 100644 --- a/src/nvim/testdir/test_bufwintabinfo.vim +++ b/src/nvim/testdir/test_bufwintabinfo.vim @@ -39,17 +39,35 @@ function Test_getbufwintabinfo() let w2_id = win_getid() tabnew | let w3_id = win_getid() new | let w4_id = win_getid() - new | let w5_id = win_getid() + vert new | let w5_id = win_getid() call setwinvar(0, 'signal', 'green') tabfirst let winlist = getwininfo() call assert_equal(5, len(winlist)) + call assert_equal(winwidth(1), winlist[0].width) + call assert_equal(0, winlist[0].wincol) + let tablineheight = winlist[0].winrow == 1 ? 1 : 0 + call assert_equal(tablineheight, winlist[0].winrow) " tabline adds one + call assert_equal(winbufnr(2), winlist[1].bufnr) call assert_equal(winheight(2), winlist[1].height) + call assert_equal(0, winlist[1].wincol) + call assert_equal(tablineheight + winheight(1) + 1, winlist[1].winrow) + call assert_equal(1, winlist[2].winnr) + call assert_equal(tablineheight, winlist[2].winrow) + call assert_equal(0, winlist[2].wincol) + + call assert_equal(winlist[2].width + 1, winlist[3].wincol) + call assert_equal(0, winlist[4].wincol) + + call assert_equal(1, winlist[0].tabnr) + call assert_equal(1, winlist[1].tabnr) + call assert_equal(2, winlist[2].tabnr) call assert_equal(2, winlist[3].tabnr) + call assert_equal(2, winlist[4].tabnr) + call assert_equal('green', winlist[2].variables.signal) - call assert_equal(winwidth(1), winlist[0].width) call assert_equal(w4_id, winlist[3].winid) let winfo = getwininfo(w5_id)[0] call assert_equal(2, winfo.tabnr) diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index caa530e4aa..3ff1e98caf 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2201,10 +2201,11 @@ func! Test_normal44_textobjects2() endfunc func! Test_normal45_drop() - if !has("dnd") + if !has('dnd') return endif - " basic test for :drop command + + " basic test for drag-n-drop " unfortunately, without a gui, we can't really test much here, " so simply test that ~p fails (which uses the drop register) new diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index f0aec42ae1..e90a14c380 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -339,3 +339,17 @@ func Test_copy_winopt() call assert_equal(4,&numberwidth) bw! endfunc + +func Test_shortmess_F() + new + call assert_match('\[No Name\]', execute('file')) + set shortmess+=F + call assert_match('\[No Name\]', execute('file')) + call assert_match('^\s*$', execute('file foo')) + call assert_match('foo', execute('file')) + set shortmess-=F + call assert_match('bar', execute('file bar')) + call assert_match('bar', execute('file')) + set shortmess& + bwipe +endfunc diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index a2eec2cc11..add9b3d7cf 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -42,40 +42,38 @@ function Test_tabpage() call assert_true(t:val_num == 100 && t:val_str == 'SetTabVar test' && t:val_list == ['red', 'blue', 'green']) tabclose - if has('nvim') || has('gui') || has('clientserver') - " Test for ":tab drop exist-file" to keep current window. - sp test1 - tab drop test1 - call assert_true(tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1) - close - " - " - " Test for ":tab drop new-file" to keep current window of tabpage 1. - split - tab drop newfile - call assert_true(tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1) - tabclose - q - " - " - " Test for ":tab drop multi-opend-file" to keep current tabpage and window. - new test1 - tabnew - new test1 - tab drop test1 - call assert_true(tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1) - tabclose - q - " - " - " Test for ":tab drop vertical-split-window" to jump test1 buffer - tabedit test1 - vnew - tabfirst - tab drop test1 - call assert_equal([2, 2, 2, 2], [tabpagenr('$'), tabpagenr(), tabpagewinnr(2, '$'), tabpagewinnr(2)]) - 1tabonly - endif + " Test for ":tab drop exist-file" to keep current window. + sp test1 + tab drop test1 + call assert_true(tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1) + close + " + " + " Test for ":tab drop new-file" to keep current window of tabpage 1. + split + tab drop newfile + call assert_true(tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1) + tabclose + q + " + " + " Test for ":tab drop multi-opend-file" to keep current tabpage and window. + new test1 + tabnew + new test1 + tab drop test1 + call assert_true(tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1) + tabclose + q + " + " + " Test for ":tab drop vertical-split-window" to jump test1 buffer + tabedit test1 + vnew + tabfirst + tab drop test1 + call assert_equal([2, 2, 2, 2], [tabpagenr('$'), tabpagenr(), tabpagewinnr(2, '$'), tabpagewinnr(2)]) + 1tabonly " " for i in range(9) | tabnew | endfor diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index ad60c8d3c7..b3ab6957dc 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -374,6 +374,19 @@ func Test_equalalways_on_close() set equalalways& endfunc +func Test_win_screenpos() + call assert_equal(1, winnr('$')) + split + vsplit + 10wincmd _ + 30wincmd | + call assert_equal([1, 1], win_screenpos(1)) + call assert_equal([1, 32], win_screenpos(2)) + call assert_equal([12, 1], win_screenpos(3)) + call assert_equal([0, 0], win_screenpos(4)) + only +endfunc + func Test_window_jump_tag() help /iccf |