aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-23 07:31:39 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-23 07:46:51 -0400
commit2a1887c2df27c5f91f0f2f6ad6c70da60239cfce (patch)
treed3fcdf232e623f322a64f0fd3b79518bfe4d7429
parentc58054c231f11cfd911795b572029e9360835bbb (diff)
downloadrneovim-2a1887c2df27c5f91f0f2f6ad6c70da60239cfce.tar.gz
rneovim-2a1887c2df27c5f91f0f2f6ad6c70da60239cfce.tar.bz2
rneovim-2a1887c2df27c5f91f0f2f6ad6c70da60239cfce.zip
vim-patch:8.1.0187: getwininfo() and win_screenpos() return different numbers
Problem: getwininfo() and win_screenpos() return different numbers. Solution: Add one to "wincol" and "winrow" from getwininfo(). https://github.com/vim/vim/commit/7132ddc1014a4e1230f0080e418221e5843e1277
-rw-r--r--runtime/doc/eval.txt40
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/testdir/test_bufwintabinfo.vim19
3 files changed, 32 insertions, 31 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 8c3399fd0d..de2650baa4 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4741,25 +4741,6 @@ gettagstack([{nr}]) *gettagstack()*
See |tagstack| for more information about the tag stack.
-getwinpos([{timeout}]) *getwinpos()*
- The result is a list with two numbers, the result of
- getwinposx() and getwinposy() combined:
- [x-pos, y-pos]
- {timeout} can be used to specify how long to wait in msec for
- a response from the terminal. When omitted 100 msec is used.
-
- *getwinposx()*
-getwinposx() The result is a Number, which is the X coordinate in pixels of
- the left hand side of the GUI Vim window. The result will be
- -1 if the information is not available.
- The value can be used with `:winpos`.
-
- *getwinposy()*
-getwinposy() The result is a Number, which is the Y coordinate in pixels of
- the top of the GUI Vim window. 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.
@@ -4789,6 +4770,25 @@ getwininfo([{winid}]) *getwininfo()*
winnr window number
winrow topmost screen column of the window
+getwinpos([{timeout}]) *getwinpos()*
+ The result is a list with two numbers, the result of
+ getwinposx() and getwinposy() combined:
+ [x-pos, y-pos]
+ {timeout} can be used to specify how long to wait in msec for
+ a response from the terminal. When omitted 100 msec is used.
+
+ *getwinposx()*
+getwinposx() The result is a Number, which is the X coordinate in pixels of
+ the left hand side of the GUI Vim window. The result will be
+ -1 if the information is not available.
+ The value can be used with `:winpos`.
+
+ *getwinposy()*
+getwinposy() The result is a Number, which is the Y coordinate in pixels of
+ the top of the GUI Vim window. The result will be -1 if the
+ information is not available.
+ The value can be used with `:winpos`.
+
getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Like |gettabwinvar()| for the current tabpage.
Examples: >
@@ -8888,7 +8888,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.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 94f559c0dc..3d56522f79 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10839,12 +10839,12 @@ 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("winrow"), wp->w_winrow + 1);
tv_dict_add_nr(dict, S_LEN("topline"), wp->w_topline);
tv_dict_add_nr(dict, S_LEN("botline"), wp->w_botline - 1);
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("wincol"), wp->w_wincol + 1);
tv_dict_add_nr(dict, S_LEN("terminal"), bt_terminal(wp->w_buffer));
tv_dict_add_nr(dict, S_LEN("quickfix"), bt_quickfix(wp->w_buffer));
diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim
index d88b061ac7..0e8c7d1dc1 100644
--- a/src/nvim/testdir/test_bufwintabinfo.vim
+++ b/src/nvim/testdir/test_bufwintabinfo.vim
@@ -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)