aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-11-26 07:53:07 +0800
committerGitHub <noreply@github.com>2024-11-26 07:53:07 +0800
commit66bb1e577c96d8eb63c04dcc737394b4ce2b0f5d (patch)
tree82fc231a3912ecdba0896a63ef1ef8b5ac05ee43
parentc644228e1dfe9f70aae53292b328be98dc95b8f7 (diff)
downloadrneovim-66bb1e577c96d8eb63c04dcc737394b4ce2b0f5d.tar.gz
rneovim-66bb1e577c96d8eb63c04dcc737394b4ce2b0f5d.tar.bz2
rneovim-66bb1e577c96d8eb63c04dcc737394b4ce2b0f5d.zip
vim-patch:9.1.0888: leftcol property not available in getwininfo() (#31349)
Problem: leftcol property not available in getwininfo() Solution: add leftcol property property (glepnir) closes: vim/vim#16119 https://github.com/vim/vim/commit/0a850673e3d4193d55f47bcbbc0b0da5f155307d Co-authored-by: glepnir <glephunter@gmail.com>
-rw-r--r--runtime/doc/builtin.txt2
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua2
-rw-r--r--src/nvim/eval.lua2
-rw-r--r--src/nvim/eval/window.c1
-rw-r--r--test/old/testdir/test_bufwintabinfo.vim12
5 files changed, 19 insertions, 0 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index ada3b7103c..585db21a0b 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4315,6 +4315,8 @@ getwininfo([{winid}]) *getwininfo()*
botline last complete displayed buffer line
bufnr number of buffer in the window
height window height (excluding winbar)
+ leftcol first column displayed; only used when
+ 'wrap' is off
loclist 1 if showing a location list
quickfix 1 if quickfix or location list window
terminal 1 if a terminal window
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 5eb15e1eee..f9b5d93a4b 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -3885,6 +3885,8 @@ function vim.fn.gettext(text) end
--- botline last complete displayed buffer line
--- bufnr number of buffer in the window
--- height window height (excluding winbar)
+--- leftcol first column displayed; only used when
+--- 'wrap' is off
--- loclist 1 if showing a location list
--- quickfix 1 if quickfix or location list window
--- terminal 1 if a terminal window
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index a418b34909..cd3ccf543e 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -4800,6 +4800,8 @@ M.funcs = {
botline last complete displayed buffer line
bufnr number of buffer in the window
height window height (excluding winbar)
+ leftcol first column displayed; only used when
+ 'wrap' is off
loclist 1 if showing a location list
quickfix 1 if quickfix or location list window
terminal 1 if a terminal window
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index 86495f1cb6..a9d3e89177 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -326,6 +326,7 @@ static dict_T *get_win_info(win_T *wp, int16_t tpnr, int16_t winnr)
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("leftcol"), wp->w_leftcol);
tv_dict_add_nr(dict, S_LEN("winbar"), wp->w_winbar_height);
tv_dict_add_nr(dict, S_LEN("width"), wp->w_width_inner);
tv_dict_add_nr(dict, S_LEN("bufnr"), wp->w_buffer->b_fnum);
diff --git a/test/old/testdir/test_bufwintabinfo.vim b/test/old/testdir/test_bufwintabinfo.vim
index 57492e07c9..0a4bd0b674 100644
--- a/test/old/testdir/test_bufwintabinfo.vim
+++ b/test/old/testdir/test_bufwintabinfo.vim
@@ -114,6 +114,18 @@ func Test_getbufwintabinfo()
wincmd t | only
endfunc
+function Test_get_wininfo_leftcol()
+ set nowrap
+ set winwidth=10
+ vsp
+ call setline(1, ['abcdefghijklmnopqrstuvwxyz'])
+ norm! 5zl
+ call assert_equal(5, getwininfo()[0].leftcol)
+ bwipe!
+ set wrap&
+ set winwidth&
+endfunc
+
function Test_get_buf_options()
let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts))