summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eval.c12
-rw-r--r--src/proto/window.pro1
-rw-r--r--src/testdir/test_window_id.vim8
-rw-r--r--src/version.c2
-rw-r--r--src/window.c15
5 files changed, 38 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 5025a52c1..e045a6753 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -807,6 +807,7 @@ static void f_values(typval_T *argvars, typval_T *rettv);
static void f_virtcol(typval_T *argvars, typval_T *rettv);
static void f_visualmode(typval_T *argvars, typval_T *rettv);
static void f_wildmenumode(typval_T *argvars, typval_T *rettv);
+static void f_win_findbuf(typval_T *argvars, typval_T *rettv);
static void f_win_getid(typval_T *argvars, typval_T *rettv);
static void f_win_gotoid(typval_T *argvars, typval_T *rettv);
static void f_win_id2tabwin(typval_T *argvars, typval_T *rettv);
@@ -8388,6 +8389,7 @@ static struct fst
{"virtcol", 1, 1, f_virtcol},
{"visualmode", 0, 1, f_visualmode},
{"wildmenumode", 0, 0, f_wildmenumode},
+ {"win_findbuf", 1, 1, f_win_findbuf},
{"win_getid", 0, 2, f_win_getid},
{"win_gotoid", 1, 1, f_win_gotoid},
{"win_id2tabwin", 1, 1, f_win_id2tabwin},
@@ -12669,6 +12671,16 @@ f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
}
/*
+ * "win_findbuf()" function
+ */
+ static void
+f_win_findbuf(typval_T *argvars, typval_T *rettv)
+{
+ if (rettv_list_alloc(rettv) != FAIL)
+ win_findbuf(argvars, rettv->vval.v_list);
+}
+
+/*
* "win_getid()" function
*/
static void
diff --git a/src/proto/window.pro b/src/proto/window.pro
index 3c511e3c5..05b6b9dae 100644
--- a/src/proto/window.pro
+++ b/src/proto/window.pro
@@ -87,4 +87,5 @@ int win_getid(typval_T *argvars);
int win_gotoid(typval_T *argvars);
void win_id2tabwin(typval_T *argvars, list_T *list);
int win_id2win(typval_T *argvars);
+void win_findbuf(typval_T *argvars, list_T *list);
/* vim: set ft=c : */
diff --git a/src/testdir/test_window_id.vim b/src/testdir/test_window_id.vim
index b9e9f45c4..fa3ebd757 100644
--- a/src/testdir/test_window_id.vim
+++ b/src/testdir/test_window_id.vim
@@ -5,6 +5,7 @@ func Test_win_getid()
let id1 = win_getid()
split two
let id2 = win_getid()
+ let bufnr2 = bufnr('%')
split three
let id3 = win_getid()
tabnew
@@ -12,6 +13,7 @@ func Test_win_getid()
let id4 = win_getid()
split five
let id5 = win_getid()
+ let bufnr5 = bufnr('%')
tabnext
wincmd w
@@ -67,5 +69,11 @@ func Test_win_getid()
call assert_equal([1, nr2], win_id2tabwin(id2))
call assert_equal([2, nr4], win_id2tabwin(id4))
+ call assert_equal([], win_findbuf(9999))
+ call assert_equal([id2], win_findbuf(bufnr2))
+ call win_gotoid(id5)
+ split
+ call assert_equal(sort([id5, win_getid()]), sort(win_findbuf(bufnr5)))
+
only!
endfunc
diff --git a/src/version.c b/src/version.c
index bed7a4604..ac23c50fe 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1558,
+/**/
1557,
/**/
1556,
diff --git a/src/window.c b/src/window.c
index b6111bd15..c6a6d2b84 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7297,4 +7297,19 @@ win_id2win(typval_T *argvars)
}
return 0;
}
+
+ void
+win_findbuf(typval_T *argvars, list_T *list)
+{
+ win_T *wp;
+ tabpage_T *tp;
+ int bufnr = get_tv_number(&argvars[0]);
+
+ for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
+ for (wp = tp == curtab ? firstwin : tp->tp_firstwin;
+ wp != NULL; wp = wp->w_next)
+ if (wp->w_buffer->b_fnum == bufnr)
+ list_append_number(list, wp->w_id);
+}
+
#endif