diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-12-17 22:40:15 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-12-17 22:40:15 +0100 |
commit | a9e9679de3ef082ee29868ab404283dfc53258f2 (patch) | |
tree | dbbddc9c73cbc409668aecc7fea3e123fb4fa46f | |
parent | 91b65e49440e77222a65b6f868507453239f409b (diff) | |
download | vim-git-a9e9679de3ef082ee29868ab404283dfc53258f2.tar.gz |
patch 8.2.0019: cannot number of lines of another bufferv8.2.0019
Problem: Cannot number of lines of another buffer.
Solution: Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
closes #5370)
-rw-r--r-- | runtime/doc/eval.txt | 2 | ||||
-rw-r--r-- | src/evalbuffer.c | 1 | ||||
-rw-r--r-- | src/testdir/test_bufwintabinfo.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 15 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index eeb19e940..070582d35 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4796,6 +4796,8 @@ getbufinfo([{dict}]) {only with the |+viminfo| feature} listed TRUE if the buffer is listed. lnum current line number in buffer. + linecount number of lines in the buffer (only + valid when loaded) loaded TRUE if the buffer is loaded. name full path to the file in the buffer. signs list of signs placed in the buffer. diff --git a/src/evalbuffer.c b/src/evalbuffer.c index a475165f4..09db525e2 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -545,6 +545,7 @@ get_buffer_info(buf_T *buf) dict_add_string(dict, "name", buf->b_ffname); dict_add_number(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum : buflist_findlnum(buf)); + dict_add_number(dict, "linecount", buf->b_ml.ml_line_count); dict_add_number(dict, "loaded", buf->b_ml.ml_mfp != NULL); dict_add_number(dict, "listed", buf->b_p_bl); dict_add_number(dict, "changed", bufIsChanged(buf)); diff --git a/src/testdir/test_bufwintabinfo.vim b/src/testdir/test_bufwintabinfo.vim index bebaca628..d61670b67 100644 --- a/src/testdir/test_bufwintabinfo.vim +++ b/src/testdir/test_bufwintabinfo.vim @@ -154,3 +154,13 @@ function Test_getbufinfo_lastused() call assert_equal(getbufinfo('Xtestfile2')[0].lastused, 7654321) call test_settime(0) 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 diff --git a/src/version.c b/src/version.c index 65924cd09..67d491874 100644 --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 19, +/**/ 18, /**/ 17, |