]> granicus.if.org Git - vim/commitdiff
patch 8.1.0187: getwininfo() and win_screenpos() return different numbers v8.1.0187
authorBram Moolenaar <Bram@vim.org>
Sun, 15 Jul 2018 15:01:11 +0000 (17:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 15 Jul 2018 15:01:11 +0000 (17:01 +0200)
Problem:    getwininfo() and win_screenpos() return different numbers.
Solution:   Add one to "wincol" and "winrow" from getwininfo().

runtime/doc/eval.txt
src/evalfunc.c
src/testdir/test_bufwintabinfo.vim
src/version.c

index 9394ece21fc12d1cc9a90450c4d129c41ee7b87d..5759815526c8322c05f691f1c18876ccebe5e915 100644 (file)
@@ -2196,7 +2196,7 @@ gettabvar({nr}, {varname} [, {def}])
                                any     variable {varname} in tab {nr} or {def}
 gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
                                any     {name} in {winnr} in tab page {tabnr}
-getwininfo([{winid}])          List    list of windows
+getwininfo([{winid}])          List    list of info about each window
 getwinpos([{timeout}])         List    X and Y coord in pixels of the Vim window
 getwinposx()                   Number  X coord in pixels of the Vim window
 getwinposy()                   Number  Y coord in pixels of the Vim window
@@ -4936,6 +4936,41 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}])              *gettabwinvar()*
                        :let list_is_on = gettabwinvar(1, 2, '&list')
                        :echo "myvar = " . gettabwinvar(3, 1, 'myvar')
 <
+getwininfo([{winid}])                                  *getwininfo()*
+               Returns information about windows as a List with Dictionaries.
+
+               If {winid} is given Information about the window with that ID
+               is returned.  If the window does not exist the result is an
+               empty list.
+
+               Without {winid} information about all the windows in all the
+               tab pages is returned.
+
+               Each List item is a Dictionary with the following entries:
+                       bufnr           number of buffer in the window
+                       height          window height (excluding winbar)
+                       winbar          1 if the window has a toolbar, 0
+                                       otherwise
+                       loclist         1 if showing a location list
+                                       {only with the +quickfix feature}
+                       quickfix        1 if quickfix or location list window
+                                       {only with the +quickfix feature}
+                       terminal        1 if a terminal window
+                                       {only with the +terminal feature}
+                       tabnr           tab page number
+                       variables       a reference to the dictionary with
+                                       window-local variables
+                       width           window width
+                       wincol          leftmost screen column of the window,
+                                       col from |win_screenpos()|
+                       winid           |window-ID|
+                       winnr           window number
+                       winrow          topmost screen column of the window,
+                                       row from |win_screenpos()|
+
+               To obtain all window-local variables use: >
+                       gettabwinvar({tabnr}, {winnr}, '&')
+
 getwinpos([{timeout}])                                 *getwinpos()*
                The result is a list with two numbers, the result of
                getwinposx() and getwinposy() combined: 
@@ -4969,39 +5004,6 @@ getwinposy()     The result is a Number, which is the Y coordinate in pixels of
                The result will be -1 if the information is not available.
                The value can be used with `:winpos`.
 
-getwininfo([{winid}])                                  *getwininfo()*
-               Returns information about windows as a List with Dictionaries.
-
-               If {winid} is given Information about the window with that ID
-               is returned.  If the window does not exist the result is an
-               empty list.
-
-               Without {winid} information about all the windows in all the
-               tab pages is returned.
-
-               Each List item is a Dictionary with the following entries:
-                       bufnr           number of buffer in the window
-                       height          window height (excluding winbar)
-                       winbar          1 if the window has a toolbar, 0
-                                       otherwise
-                       loclist         1 if showing a location list
-                                       {only with the +quickfix feature}
-                       quickfix        1 if quickfix or location list window
-                                       {only with the +quickfix feature}
-                       terminal        1 if a terminal window
-                                       {only with the +terminal feature}
-                       tabnr           tab page number
-                       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}, '&')
-
 getwinvar({winnr}, {varname} [, {def}])                                *getwinvar()*
                Like |gettabwinvar()| for the current tabpage.
                Examples: >
@@ -9049,7 +9051,7 @@ win_id2win({expr})                                        *win_id2win()*
 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].
+               [1, 1], unless there is a tabline, then it is [2, 1].
                {nr} can be the window number or the |window-ID|.
                Return [0, 0] if the window cannot be found in the current
                tabpage.
index 13c60b9930a95f2cb80b22502c438663977934b9..2e06c2063d3f9fcf45dcd379987e1e1dc9e4cf07 100644 (file)
@@ -5648,12 +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);
+    dict_add_number(dict, "winrow", wp->w_winrow + 1);
 #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, "wincol", wp->w_wincol + 1);
     dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum);
 
 #ifdef FEAT_TERMINAL
index d88b061ac726085030e62504df8075d88b5b5e6b..0e8c7d1dc162c2287dee50e23b591b7b52465bd5 100644 (file)
@@ -52,21 +52,22 @@ function Test_getbufwintabinfo()
     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(1, winlist[0].wincol)
+    " tabline adds one row in terminal, not in GUI
+    let tablineheight = winlist[0].winrow == 2 ? 1 : 0
+    call assert_equal(tablineheight + 1, winlist[0].winrow)
 
     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[1].wincol)
+    call assert_equal(tablineheight + winheight(1) + 2, 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(tablineheight + 1, winlist[2].winrow)
+    call assert_equal(1, winlist[2].wincol)
 
-    call assert_equal(winlist[2].width + 1, winlist[3].wincol)
-    call assert_equal(0, winlist[4].wincol)
+    call assert_equal(winlist[2].width + 2, winlist[3].wincol)
+    call assert_equal(1, winlist[4].wincol)
 
     call assert_equal(1, winlist[0].tabnr)
     call assert_equal(1, winlist[1].tabnr)
index 08e39b4d4d93b9dc7bad0412b1c9a4ffac035285..559d8bed535d7c0a7075b87772c4060d6f3120a5 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    187,
 /**/
     186,
 /**/