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

0a850673e3

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2024-11-26 07:53:07 +08:00
committed by GitHub
parent c644228e1d
commit 66bb1e577c
5 changed files with 19 additions and 0 deletions

View File

@@ -4315,6 +4315,8 @@ getwininfo([{winid}]) *getwininfo()*
botline last complete displayed buffer line botline last complete displayed buffer line
bufnr number of buffer in the window bufnr number of buffer in the window
height window height (excluding winbar) height window height (excluding winbar)
leftcol first column displayed; only used when
'wrap' is off
loclist 1 if showing a location list loclist 1 if showing a location list
quickfix 1 if quickfix or location list window quickfix 1 if quickfix or location list window
terminal 1 if a terminal window terminal 1 if a terminal window

View File

@@ -3885,6 +3885,8 @@ function vim.fn.gettext(text) end
--- botline last complete displayed buffer line --- botline last complete displayed buffer line
--- bufnr number of buffer in the window --- bufnr number of buffer in the window
--- height window height (excluding winbar) --- height window height (excluding winbar)
--- leftcol first column displayed; only used when
--- 'wrap' is off
--- loclist 1 if showing a location list --- loclist 1 if showing a location list
--- quickfix 1 if quickfix or location list window --- quickfix 1 if quickfix or location list window
--- terminal 1 if a terminal window --- terminal 1 if a terminal window

View File

@@ -4800,6 +4800,8 @@ M.funcs = {
botline last complete displayed buffer line botline last complete displayed buffer line
bufnr number of buffer in the window bufnr number of buffer in the window
height window height (excluding winbar) height window height (excluding winbar)
leftcol first column displayed; only used when
'wrap' is off
loclist 1 if showing a location list loclist 1 if showing a location list
quickfix 1 if quickfix or location list window quickfix 1 if quickfix or location list window
terminal 1 if a terminal window terminal 1 if a terminal window

View File

@@ -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("winrow"), wp->w_winrow + 1);
tv_dict_add_nr(dict, S_LEN("topline"), wp->w_topline); 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("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("winbar"), wp->w_winbar_height);
tv_dict_add_nr(dict, S_LEN("width"), wp->w_width_inner); 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); tv_dict_add_nr(dict, S_LEN("bufnr"), wp->w_buffer->b_fnum);

View File

@@ -114,6 +114,18 @@ func Test_getbufwintabinfo()
wincmd t | only wincmd t | only
endfunc 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() function Test_get_buf_options()
let opts = bufnr()->getbufvar('&') let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts)) call assert_equal(v:t_dict, type(opts))