vim-patch:8.2.0019: cannot number of lines of another buffer

Problem:    Cannot number of lines of another buffer.
Solution:   Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
            closes vim/vim#5370)
a9e9679de3
This commit is contained in:
Jan Edmund Lazo 2019-12-20 00:02:36 -05:00
parent 026ba804d1
commit c147806e23
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
3 changed files with 13 additions and 0 deletions

View File

@ -4138,6 +4138,8 @@ getbufinfo([{dict}])
hidden TRUE if the buffer is hidden. hidden TRUE if the buffer is hidden.
listed TRUE if the buffer is listed. listed TRUE if the buffer is listed.
lnum current line number in buffer. lnum current line number in buffer.
linecount number of lines in the buffer (only
valid when loaded)
loaded TRUE if the buffer is loaded. loaded TRUE if the buffer is loaded.
name full path to the file in the buffer. name full path to the file in the buffer.
signs list of signs placed in the buffer. signs list of signs placed in the buffer.

View File

@ -9922,6 +9922,7 @@ static dict_T *get_buffer_info(buf_T *buf)
buf->b_ffname != NULL ? (const char *)buf->b_ffname : ""); buf->b_ffname != NULL ? (const char *)buf->b_ffname : "");
tv_dict_add_nr(dict, S_LEN("lnum"), tv_dict_add_nr(dict, S_LEN("lnum"),
buf == curbuf ? curwin->w_cursor.lnum : buflist_findlnum(buf)); buf == curbuf ? curwin->w_cursor.lnum : buflist_findlnum(buf));
tv_dict_add_nr(dict, S_LEN("linecount"), buf->b_ml.ml_line_count);
tv_dict_add_nr(dict, S_LEN("loaded"), buf->b_ml.ml_mfp != NULL); tv_dict_add_nr(dict, S_LEN("loaded"), buf->b_ml.ml_mfp != NULL);
tv_dict_add_nr(dict, S_LEN("listed"), buf->b_p_bl); tv_dict_add_nr(dict, S_LEN("listed"), buf->b_p_bl);
tv_dict_add_nr(dict, S_LEN("changed"), bufIsChanged(buf)); tv_dict_add_nr(dict, S_LEN("changed"), bufIsChanged(buf));

View File

@ -139,3 +139,13 @@ function Test_get_win_options()
set foldlevel=0 set foldlevel=0
endif endif
endfunc endfunc
func Test_getbufinfo_lines()
new Xfoo
call setline(1, ['a', 'bc', 'd'])
let bn = bufnr('%')
hide
call assert_equal(3, getbufinfo(bn)[0]["linecount"])
edit Xfoo
bw!
endfunc