0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 7.4.2226

Problem:    The field names used by getbufinfo(), gettabinfo() and
            getwininfo() are not consistent.
Solution:   Use bufnr, winnr and tabnr. (Yegappan Lakshmanan)
This commit is contained in:
Bram Moolenaar
2016-08-18 21:22:04 +02:00
parent bfd096d020
commit 3392883770
4 changed files with 14 additions and 12 deletions

View File

@@ -4004,6 +4004,7 @@ getbufinfo([{dict}])
Each returned List item is a dictionary with the following Each returned List item is a dictionary with the following
entries: entries:
bufnr buffer number.
changed TRUE if the buffer is modified. changed TRUE if the buffer is modified.
changedtick number of changes made to the buffer. changedtick number of changes made to the buffer.
hidden TRUE if the buffer is hidden. hidden TRUE if the buffer is hidden.
@@ -4011,7 +4012,6 @@ getbufinfo([{dict}])
lnum current line number in buffer. lnum current line number in buffer.
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.
nr buffer number.
options dictionary of buffer local options. options dictionary of buffer local options.
signs list of signs placed in the buffer. signs list of signs placed in the buffer.
Each list item is a dictionary with Each list item is a dictionary with

View File

@@ -3931,7 +3931,7 @@ get_buffer_info(buf_T *buf)
if (dict == NULL) if (dict == NULL)
return NULL; return NULL;
dict_add_nr_str(dict, "nr", buf->b_fnum, NULL); dict_add_nr_str(dict, "bufnr", buf->b_fnum, NULL);
dict_add_nr_str(dict, "name", 0L, dict_add_nr_str(dict, "name", 0L,
buf->b_ffname != NULL ? buf->b_ffname : (char_u *)""); 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", buflist_findlnum(buf), NULL);
@@ -5001,7 +5001,7 @@ get_tabpage_info(tabpage_T *tp, int tp_idx)
if (dict == NULL) if (dict == NULL)
return NULL; return NULL;
dict_add_nr_str(dict, "nr", tp_idx, NULL); dict_add_nr_str(dict, "tabnr", tp_idx, NULL);
l = list_alloc(); l = list_alloc();
if (l != NULL) if (l != NULL)
@@ -5125,12 +5125,12 @@ get_win_info(win_T *wp, short tpnr, short winnr)
if (dict == NULL) if (dict == NULL)
return NULL; return NULL;
dict_add_nr_str(dict, "tpnr", tpnr, NULL); dict_add_nr_str(dict, "tabnr", tpnr, NULL);
dict_add_nr_str(dict, "nr", winnr, NULL); dict_add_nr_str(dict, "winnr", winnr, NULL);
dict_add_nr_str(dict, "winid", wp->w_id, NULL); dict_add_nr_str(dict, "winid", wp->w_id, NULL);
dict_add_nr_str(dict, "height", wp->w_height, NULL); dict_add_nr_str(dict, "height", wp->w_height, NULL);
dict_add_nr_str(dict, "width", wp->w_width, NULL); dict_add_nr_str(dict, "width", wp->w_width, NULL);
dict_add_nr_str(dict, "bufnum", wp->w_buffer->b_fnum, NULL); dict_add_nr_str(dict, "bufnr", wp->w_buffer->b_fnum, NULL);
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
dict_add_nr_str(dict, "quickfix", bt_quickfix(wp->w_buffer), NULL); dict_add_nr_str(dict, "quickfix", bt_quickfix(wp->w_buffer), NULL);

View File

@@ -17,7 +17,7 @@ function Test_getbufwintabinfo()
set tabstop&vim set tabstop&vim
let b:editor = 'vim' let b:editor = 'vim'
let l = getbufinfo('%') let l = getbufinfo('%')
call assert_equal(bufnr('%'), l[0].nr) call assert_equal(bufnr('%'), l[0].bufnr)
call assert_equal(8, l[0].options.tabstop) call assert_equal(8, l[0].options.tabstop)
call assert_equal('vim', l[0].variables.editor) call assert_equal('vim', l[0].variables.editor)
call assert_notequal(-1, index(l[0].windows, bufwinid('%'))) call assert_notequal(-1, index(l[0].windows, bufwinid('%')))
@@ -46,25 +46,25 @@ function Test_getbufwintabinfo()
tabfirst tabfirst
let winlist = getwininfo() let winlist = getwininfo()
call assert_equal(5, len(winlist)) call assert_equal(5, len(winlist))
call assert_equal(winbufnr(2), winlist[1].bufnum) call assert_equal(winbufnr(2), winlist[1].bufnr)
call assert_equal(winheight(2), winlist[1].height) call assert_equal(winheight(2), winlist[1].height)
call assert_equal(1, winlist[2].nr) call assert_equal(1, winlist[2].winnr)
if has('signs') if has('signs')
call assert_equal('auto', winlist[0].options.signcolumn) call assert_equal('auto', winlist[0].options.signcolumn)
endif endif
call assert_equal(2, winlist[3].tpnr) call assert_equal(2, winlist[3].tabnr)
call assert_equal('green', winlist[2].variables.signal) call assert_equal('green', winlist[2].variables.signal)
call assert_equal(winwidth(1), winlist[0].width) call assert_equal(winwidth(1), winlist[0].width)
call assert_equal(w4_id, winlist[3].winid) call assert_equal(w4_id, winlist[3].winid)
let winfo = getwininfo(w5_id)[0] let winfo = getwininfo(w5_id)[0]
call assert_equal(2, winfo.tpnr) call assert_equal(2, winfo.tabnr)
call assert_equal([], getwininfo(3)) call assert_equal([], getwininfo(3))
call settabvar(1, 'space', 'build') call settabvar(1, 'space', 'build')
let tablist = gettabinfo() let tablist = gettabinfo()
call assert_equal(2, len(tablist)) call assert_equal(2, len(tablist))
call assert_equal(3, len(tablist[1].windows)) call assert_equal(3, len(tablist[1].windows))
call assert_equal(2, tablist[1].nr) call assert_equal(2, tablist[1].tabnr)
call assert_equal('build', tablist[0].variables.space) call assert_equal('build', tablist[0].variables.space)
call assert_equal(w2_id, tablist[0].windows[0]) call assert_equal(w2_id, tablist[0].windows[0])
call assert_equal([], gettabinfo(3)) call assert_equal([], gettabinfo(3))

View File

@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2226,
/**/ /**/
2225, 2225,
/**/ /**/