The lnum member of getbufinfo() for the current buffer looks strange for me.
E.g.:
Open a new buffer and input some lines.
Move the cursor to line 5, then execute the following:
:echo getbufinfo('%')[0].lnum
1
I expect 5 for this (as same as :ls).
The following patch fixes this:
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3979,7 +3979,8 @@ get_buffer_info(buf_T *buf)
dict_add_nr_str(dict, "bufnr", buf->b_fnum, NULL);
dict_add_nr_str(dict, "name", 0L,
buf->b_ffname != NULL ? buf->b_ffname : (char_u *)"");
- dict_add_nr_str(dict, "lnum", buflist_findlnum(buf), NULL);
+ dict_add_nr_str(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum
+ : buflist_findlnum(buf), NULL);
dict_add_nr_str(dict, "loaded", buf->b_ml.ml_mfp != NULL, NULL);
dict_add_nr_str(dict, "listed", buf->b_p_bl, NULL);
dict_add_nr_str(dict, "changed", bufIsChanged(buf), NULL);
This part is copied from the implementation of `:ls`.
Regards,
Ken Takata