diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-12-10 21:06:22 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-12-10 21:06:22 +0100 |
commit | 8e6a31df81113bbf0e4bb5324a74dc5f6c62a490 (patch) | |
tree | 77b18f0770aef3fabadeb085420af1299b239066 | |
parent | 59eb016dff3fd4f764cfe326c80a9b840f0e1a02 (diff) | |
download | vim-git-8e6a31df81113bbf0e4bb5324a74dc5f6c62a490.tar.gz |
patch 8.0.1386: cannot select modified buffers with getbufinfo()v8.0.1386
Problem: Cannot select modified buffers with getbufinfo().
Solution: Add the "bufmodified" flag. (Yegappan Lakshmanan, closes #2431)
-rw-r--r-- | runtime/doc/eval.txt | 1 | ||||
-rw-r--r-- | src/evalfunc.c | 8 | ||||
-rw-r--r-- | src/testdir/test_bufwintabinfo.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 17 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 93e818a44..3afd67551 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4173,6 +4173,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()| diff --git a/src/evalfunc.c b/src/evalfunc.c index 726908472..9aacd3078 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4137,6 +4137,7 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv) int filtered = FALSE; int sel_buflisted = FALSE; int sel_bufloaded = FALSE; + int sel_bufmodified = FALSE; if (rettv_list_alloc(rettv) != OK) return; @@ -4159,6 +4160,10 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv) di = dict_find(sel_d, (char_u *)"bufloaded", -1); if (di != NULL && get_tv_number(&di->di_tv)) sel_bufloaded = TRUE; + + di = dict_find(sel_d, (char_u *)"bufmodified", -1); + if (di != NULL && get_tv_number(&di->di_tv)) + sel_bufmodified = TRUE; } } else if (argvars[0].v_type != VAR_UNKNOWN) @@ -4178,7 +4183,8 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv) if (argbuf != NULL && argbuf != buf) 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; d = get_buffer_info(buf); diff --git a/src/testdir/test_bufwintabinfo.vim b/src/testdir/test_bufwintabinfo.vim index a592cd7b1..31b465002 100644 --- a/src/testdir/test_bufwintabinfo.vim +++ b/src/testdir/test_bufwintabinfo.vim @@ -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 diff --git a/src/version.c b/src/version.c index 7c55df074..e96e672e7 100644 --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1386, +/**/ 1385, /**/ 1384, |