mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:8.0.1386: cannot select modified buffers with getbufinfo()
Problem: Cannot select modified buffers with getbufinfo().
Solution: Add the "bufmodified" flag. (Yegappan Lakshmanan, closes vim/vim#2431)
8e6a31df81
This commit is contained in:
@@ -4041,6 +4041,7 @@ getbufinfo([{dict}])
|
||||
be specified in {dict}:
|
||||
buflisted include only listed buffers.
|
||||
bufloaded include only loaded buffers.
|
||||
bufmodified include only modified buffers.
|
||||
|
||||
Otherwise, {expr} specifies a particular buffer to return
|
||||
information for. For the use of {expr}, see |bufname()|
|
||||
|
@@ -9692,6 +9692,7 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
bool filtered = false;
|
||||
bool sel_buflisted = false;
|
||||
bool sel_bufloaded = false;
|
||||
bool sel_bufmodified = false;
|
||||
|
||||
tv_list_alloc_ret(rettv, kListLenMayKnow);
|
||||
|
||||
@@ -9713,6 +9714,10 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
if (di != NULL && tv_get_number(&di->di_tv)) {
|
||||
sel_bufloaded = true;
|
||||
}
|
||||
di = tv_dict_find(sel_d, S_LEN("bufmodified"));
|
||||
if (di != NULL && tv_get_number(&di->di_tv)) {
|
||||
sel_bufmodified = true;
|
||||
}
|
||||
}
|
||||
} else if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||
// Information about one buffer. Argument specifies the buffer
|
||||
@@ -9732,7 +9737,8 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
continue;
|
||||
}
|
||||
if (filtered && ((sel_bufloaded && buf->b_ml.ml_mfp == NULL)
|
||||
|| (sel_buflisted && !buf->b_p_bl))) {
|
||||
|| (sel_buflisted && !buf->b_p_bl)
|
||||
|| (sel_bufmodified && !buf->b_changed))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,13 @@ function Test_getbufwintabinfo()
|
||||
call assert_equal('vim', l[0].variables.editor)
|
||||
call assert_notequal(-1, index(l[0].windows, bufwinid('%')))
|
||||
|
||||
" Test for getbufinfo() with 'bufmodified'
|
||||
call assert_equal(0, len(getbufinfo({'bufmodified' : 1})))
|
||||
call setbufline('Xtestfile1', 1, ["Line1"])
|
||||
let l = getbufinfo({'bufmodified' : 1})
|
||||
call assert_equal(1, len(l))
|
||||
call assert_equal(bufnr('Xtestfile1'), l[0].bufnr)
|
||||
|
||||
if has('signs')
|
||||
call append(0, ['Linux', 'Windows', 'Mac'])
|
||||
sign define Mark text=>> texthl=Search
|
||||
|
Reference in New Issue
Block a user