patch 8.1.1770: cannot get the window ID of the popup preview window
Problem: Cannot get the window ID of the popup preview window.
Solution: Add popup_getpreview().
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 79c5409..bd05691 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2554,6 +2554,7 @@
popup_filter_yesno({id}, {key}) Number filter for a dialog popup window
popup_getoptions({id}) Dict get options of popup window {id}
popup_getpos({id}) Dict get position of popup window {id}
+popup_getpreview() Number get window ID of preview popup window
popup_hide({id}) none hide popup menu {id}
popup_menu({what}, {options}) Number create a popup window used as a menu
popup_move({id}, {options}) none set position of popup window {id}
diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt
index 52d0892..d696e28 100644
--- a/runtime/doc/popup.txt
+++ b/runtime/doc/popup.txt
@@ -1,4 +1,4 @@
-*popup.txt* For Vim version 8.1. Last change: 2019 Jul 18
+*popup.txt* For Vim version 8.1. Last change: 2019 Jul 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -335,6 +335,10 @@
If popup window {id} is not found an empty Dict is returned.
+popup_getpreview() *popup_getpreview()*
+ Get the |window-ID| for the popup preview window.
+ Return zero if there is none.
+
popup_hide({id}) *popup_hide()*
If {id} is a displayed popup, hide it now. If the popup has a
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 3875b43..8253df8 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -715,6 +715,7 @@
{"popup_filter_yesno", 2, 2, f_popup_filter_yesno},
{"popup_getoptions", 1, 1, f_popup_getoptions},
{"popup_getpos", 1, 1, f_popup_getpos},
+ {"popup_getpreview", 0, 0, f_popup_getpreview},
{"popup_hide", 1, 1, f_popup_hide},
{"popup_locate", 2, 2, f_popup_locate},
{"popup_menu", 2, 2, f_popup_menu},
diff --git a/src/popupwin.c b/src/popupwin.c
index 4c694c2..8ad6642 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -3019,7 +3019,15 @@
for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_p_pvw)
return wp;
- return wp;
+ return NULL;
+}
+
+ void
+f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ win_T *wp = popup_find_preview_window();
+
+ rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
}
int
diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro
index 605575b..04825cc 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -42,6 +42,7 @@
void update_popups(void (*win_update)(win_T *wp));
int set_ref_in_popups(int copyID);
win_T *popup_find_preview_window(void);
+void f_popup_getpreview(typval_T *argvars, typval_T *rettv);
int popup_is_popup(win_T *wp);
int popup_create_preview_window(void);
void popup_close_preview(void);
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_3.dump b/src/testdir/dumps/Test_popupwin_previewpopup_3.dump
new file mode 100644
index 0000000..27a6caf
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_3.dump
@@ -0,0 +1,14 @@
+|o+0&#ffffff0|n|e| @71
+|t|w|o| @71
+|t|h|r|e@1| @69
+|f|o|u|r| @9|╔+0#0000001#ffd7ff255|═@40|X| +0#0000000#ffffff0@17
+|f|i|v|e| @9|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|s|i|x| @10|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|s|e|v|e|n| @8|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|f|i|n|d| |t|h|e|w|o|r|d| |s|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|n|i|n|e| @9|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@17
+|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|:+0#0000000&| @55|1|0|,|9| @9|A|l@1|
diff --git a/src/version.c b/src/version.c
index 2db2ee1..b0fe67f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1770,
+/**/
1769,
/**/
1768,