]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0019: cannot number of lines of another buffer v8.2.0019
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Dec 2019 21:40:15 +0000 (22:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Dec 2019 21:40:15 +0000 (22:40 +0100)
Problem:    Cannot number of lines of another buffer.
Solution:   Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
            closes #5370)

runtime/doc/eval.txt
src/evalbuffer.c
src/testdir/test_bufwintabinfo.vim
src/version.c

index eeb19e9407d64f7fbd955ad9abd51728bae9f64f..070582d358f6c5bc5d51c22e4586f2a26aed6872 100644 (file)
@@ -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.
index a475165f4132796bdf099383e3ef439720d70870..09db525e28154995d0f48e60583ae3865f948d62 100644 (file)
@@ -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));
index bebaca62815754ff7c0011e25f791dfc46c1b911..d61670b6701a0af0cd9a1129dcc7506f34defb49 100644 (file)
@@ -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
index 65924cd09772de19cfd3d894f6ed93679081df16..67d491874f9b24dae9ec479c15a23918f9d398df 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    19,
 /**/
     18,
 /**/