Skip to content

Commit

Permalink
patch 8.1.0184: not easy to figure out the window layout
Browse files Browse the repository at this point in the history
Problem:    Not easy to figure out the window layout.
Solution:   Add "wincol" and "winrow" to what getwininfo() returns.
  • Loading branch information
brammool committed Jul 14, 2018
1 parent 1741367 commit b6959a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions runtime/doc/eval.txt
Expand Up @@ -4994,8 +4994,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}, '&')
Expand Down
2 changes: 2 additions & 0 deletions src/evalfunc.c
Expand Up @@ -5648,10 +5648,12 @@ get_win_info(win_T *wp, short tpnr, short winnr)
dict_add_number(dict, "winnr", winnr);
dict_add_number(dict, "winid", wp->w_id);
dict_add_number(dict, "height", wp->w_height);
dict_add_number(dict, "winrow", wp->w_winrow);
#ifdef FEAT_MENU
dict_add_number(dict, "winbar", wp->w_winbar_height);
#endif
dict_add_number(dict, "width", wp->w_width);
dict_add_number(dict, "wincol", wp->w_wincol);
dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum);

#ifdef FEAT_TERMINAL
Expand Down
21 changes: 19 additions & 2 deletions src/testdir/test_bufwintabinfo.vim
Expand Up @@ -46,17 +46,34 @@ 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)
call assert_equal(1, 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(winheight(1) + 2, winlist[1].winrow)

call assert_equal(1, winlist[2].winnr)
call assert_equal(1, 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)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -789,6 +789,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
184,
/**/
183,
/**/
Expand Down

0 comments on commit b6959a8

Please sign in to comment.