diff options
| -rw-r--r-- | runtime/doc/eval.txt | 11 | ||||
| -rwxr-xr-x | scripts/vim-patch.sh | 3 | ||||
| -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 | 
10 files changed, 112 insertions, 43 deletions
| diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4d5a592190..594b67b5c8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2352,6 +2352,7 @@ win_getid([{win} [, {tab}]])	Number	get |window-ID| for {win} in {tab}  win_gotoid({expr})		Number	go to |window-ID| {expr}  win_id2tabwin({expr})		List	get tab and window nr from |window-ID|  win_id2win({expr})		Number	get window nr from |window-ID| +win_screenpos({nr})		List	get screen position of window {nr}  winbufnr({nr})			Number	buffer number of window {nr}  wincol()			Number	window column of the cursor  winheight({nr})			Number	height of window {nr} @@ -4473,8 +4474,10 @@ getwininfo([{winid}])					*getwininfo()*  			variables	a reference to the dictionary with  					window-local variables  			width		window width +			wincol		leftmost screen column of the window  			winid		|window-ID|  			winnr		window number +			winrow		topmost screen column of the window  		To obtain all window-local variables use: >  			gettabwinvar({tabnr}, {winnr}, '&') @@ -8183,6 +8186,14 @@ win_id2win({expr})					*win_id2win()*  		Return the window number of window with ID {expr}.  		Return 0 if the window cannot be found in the current tabpage. +win_screenpos({nr})					*win_screenpos()* +		Return the screen position of window {nr} as a list with two +		numbers: [row, col].  The first window always has position +		[1, 1]. +		{nr} can be the window number or the |window-ID|. +		Return [0, 0] if the window cannot be found in the current +		tabpage. +  							*winbufnr()*  winbufnr({nr})	The result is a Number, which is the number of the buffer  		associated with window {nr}.  {nr} can be the window number or diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 9ea43383b6..bba76ffa97 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -86,7 +86,8 @@ get_vim_sources() {      cd "${VIM_SOURCE_DIR}"    else      cd "${VIM_SOURCE_DIR}" -    if [[ "$(git rev-parse --show-toplevel)" != "${VIM_SOURCE_DIR}" ]]; then +    if ! [ -d ".git" ] \ +        && ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then        msg_err "${VIM_SOURCE_DIR} does not appear to be a git repository."        echo "  Please remove it and try again."        exit 1 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 | 
