summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-04 15:39:28 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-04 15:39:28 +0200
commit5ca1ac373ae62b37152cb6f85916b402eda520a5 (patch)
tree002e91e14351d0a5f19bd6d7645a831377be5867
parentbc2cfe4672d370330b8698d4d025697a9a6ec569 (diff)
downloadvim-git-5ca1ac373ae62b37152cb6f85916b402eda520a5.tar.gz
patch 8.1.1626: no test for closing a popup window with a modified bufferv8.1.1626
Problem: No test for closing a popup window with a modified buffer. Solution: Add a test. Add "popups" to getbufinfo().
-rw-r--r--runtime/doc/eval.txt8
-rw-r--r--src/evalfunc.c23
-rw-r--r--src/testdir/test_popupwin.vim27
-rw-r--r--src/version.c2
4 files changed, 56 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 7c457e34e..cd2149e9d 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3140,7 +3140,11 @@ bufadd({name}) *bufadd()*
number. Otherwise return the buffer number of the newly
created buffer. When {name} is an empty string then a new
buffer is always created.
- The buffer will not have' 'buflisted' set.
+ The buffer will not have' 'buflisted' set and not be loaded
+ yet. To add some text to the buffer use this: >
+ let bufnr = bufadd('someName')
+ call bufload(bufnr)
+ call setbufline(bufnr, 1, ['some', 'text'])
bufexists({expr}) *bufexists()*
The result is a Number, which is |TRUE| if a buffer called
@@ -4744,6 +4748,8 @@ getbufinfo([{dict}])
buffer-local variables.
windows list of |window-ID|s that display this
buffer
+ popups list of popup |window-ID|s that
+ display this buffer
Examples: >
for buf in getbufinfo()
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 7c9860f8a..925040d2b 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4509,10 +4509,10 @@ get_buffer_info(buf_T *buf)
dict_add_number(dict, "hidden",
buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0);
- /* Get a reference to buffer variables */
+ // Get a reference to buffer variables
dict_add_dict(dict, "variables", buf->b_vars);
- /* List of windows displaying this buffer */
+ // List of windows displaying this buffer
windows = list_alloc();
if (windows != NULL)
{
@@ -4522,6 +4522,23 @@ get_buffer_info(buf_T *buf)
dict_add_list(dict, "windows", windows);
}
+#ifdef FEAT_TEXT_PROP
+ // List of popup windows displaying this buffer
+ windows = list_alloc();
+ if (windows != NULL)
+ {
+ for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
+ if (wp->w_buffer == buf)
+ list_append_number(windows, (varnumber_T)wp->w_id);
+ FOR_ALL_TABPAGES(tp)
+ for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
+ if (wp->w_buffer == buf)
+ list_append_number(windows, (varnumber_T)wp->w_id);
+
+ dict_add_list(dict, "popups", windows);
+ }
+#endif
+
#ifdef FEAT_SIGNS
if (buf->b_signlist != NULL)
{
@@ -5685,7 +5702,7 @@ get_tabpage_info(tabpage_T *tp, int tp_idx)
if (l != NULL)
{
for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
- wp; wp = wp->w_next)
+ wp != NULL; wp = wp->w_next)
list_append_number(l, (varnumber_T)wp->w_id);
dict_add_list(dict, "windows", l);
}
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index f7579f540..4e798c603 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -1710,3 +1710,30 @@ func Test_popupwin_width()
endfor
call popup_clear()
endfunc
+
+func Test_popupwin_buf_close()
+ let buf = bufadd('Xtestbuf')
+ call bufload(buf)
+ call setbufline(buf, 1, ['just', 'some', 'lines'])
+ let winid = popup_create(buf, {})
+ redraw
+ call assert_equal(3, popup_getpos(winid).height)
+ let bufinfo = getbufinfo(buf)[0]
+ call assert_equal(1, bufinfo.changed)
+ call assert_equal(0, bufinfo.hidden)
+ call assert_equal(0, bufinfo.listed)
+ call assert_equal(1, bufinfo.loaded)
+ call assert_equal([], bufinfo.windows)
+ call assert_equal([winid], bufinfo.popups)
+
+ call popup_close(winid)
+ call assert_equal({}, popup_getpos(winid))
+ let bufinfo = getbufinfo(buf)[0]
+ call assert_equal(1, bufinfo.changed)
+ call assert_equal(1, bufinfo.hidden)
+ call assert_equal(0, bufinfo.listed)
+ call assert_equal(1, bufinfo.loaded)
+ call assert_equal([], bufinfo.windows)
+ call assert_equal([], bufinfo.popups)
+ exe 'bwipe! ' .. buf
+endfunc
diff --git a/src/version.c b/src/version.c
index 157e9ece2..e78733a17 100644
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1626,
+/**/
1625,
/**/
1624,