diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-05-08 15:00:04 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-08 15:00:04 +0100 |
commit | 27724251bc73f97b55240731f4316ee1b4eac1c5 (patch) | |
tree | 304b1488afa10d9b17f050699d1c3ddc839509bc | |
parent | d899e51120798d3fb5420abb1f19dddf3f014d05 (diff) | |
download | vim-git-27724251bc73f97b55240731f4316ee1b4eac1c5.tar.gz |
patch 8.2.4913: popup_hide() does not always have effectv8.2.4913
Problem: Popup_hide() does not always have effect.
Solution: Add the POPF_HIDDEN_FORCE flag. (closes #10376)
-rw-r--r-- | src/popupwin.c | 11 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popup_prop_not_visible_01a.dump | 10 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popup_prop_not_visible_01b.dump | 10 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 8 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 19 |
6 files changed, 47 insertions, 13 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 27e9fe12e..2306dacc1 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -978,7 +978,7 @@ apply_options(win_T *wp, dict_T *dict, int create) nr = dict_get_bool(dict, (char_u *)"hidden", FALSE); if (nr > 0) - wp->w_popup_flags |= POPF_HIDDEN; + wp->w_popup_flags |= POPF_HIDDEN | POPF_HIDDEN_FORCE; // when "firstline" and "cursorline" are both set and the cursor would be // above or below the displayed lines, move the cursor to "firstline". @@ -2644,7 +2644,10 @@ f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED) id = (int)tv_get_number(argvars); wp = find_popup_win(id); if (wp != NULL) + { popup_hide(wp); + wp->w_popup_flags |= POPF_HIDDEN_FORCE; + } } void @@ -2674,6 +2677,7 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED) wp = find_popup_win(id); if (wp != NULL) { + wp->w_popup_flags &= ~POPF_HIDDEN_FORCE; popup_show(wp); #ifdef FEAT_QUICKFIX if (wp->w_popup_flags & POPF_INFO) @@ -3606,8 +3610,9 @@ check_popup_unhidden(win_T *wp) textprop_T prop; linenr_T lnum; - if (find_visible_prop(wp->w_popup_prop_win, - wp->w_popup_prop_type, wp->w_popup_prop_id, + if ((wp->w_popup_flags & POPF_HIDDEN_FORCE) == 0 + && find_visible_prop(wp->w_popup_prop_win, + wp->w_popup_prop_type, wp->w_popup_prop_id, &prop, &lnum) == OK) { wp->w_popup_flags &= ~POPF_HIDDEN; diff --git a/src/testdir/dumps/Test_popup_prop_not_visible_01a.dump b/src/testdir/dumps/Test_popup_prop_not_visible_01a.dump new file mode 100644 index 000000000..0b97cb832 --- /dev/null +++ b/src/testdir/dumps/Test_popup_prop_not_visible_01a.dump @@ -0,0 +1,10 @@ +| +2&#ffffff0|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@60 +| +0&&@42||+1&&> +0&&@30 +|~+0#4040ff13&| @41||+1#0000000&|s+0&&|o|m|e| |t|e|x|t| @21 +|~+0#4040ff13&| @41||+1#0000000&| +0&&@30 +|~+0#4040ff13&| @41||+1#0000000&|o+0&&|t|h|e|r| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|o|t|h|e|r|"| +0#0000000#ffffff0@1 +|~+0#4040ff13&| @41||+1#0000000&|~+0#4040ff13&| @29 +|~| @41||+1#0000000&|~+0#4040ff13&| @29 +|~| @41||+1#0000000&|~+0#4040ff13&| @29 +|[+1#0000000&|N|o| |N|a|m|e|]| @15|0|,|0|-|1| @9|A|l@1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @2|1|,|0|-|1| @6|A|l@1 +|:+0&&|c|a|l@1| |p|o|p|u|p|_|h|i|d|e|(|g|:|s|o|m|e|_|i|d|)| @47 diff --git a/src/testdir/dumps/Test_popup_prop_not_visible_01b.dump b/src/testdir/dumps/Test_popup_prop_not_visible_01b.dump new file mode 100644 index 000000000..e8a5c2e35 --- /dev/null +++ b/src/testdir/dumps/Test_popup_prop_not_visible_01b.dump @@ -0,0 +1,10 @@ +| +2&#ffffff0|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@60 +| +0&&@42||+1&&> +0&&@30 +|~+0#4040ff13&| @41||+1#0000000&|s+0&&|o|m|e| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|s|o|m|e|"| +0#0000000#ffffff0@3 +|~+0#4040ff13&| @41||+1#0000000&| +0&&@30 +|~+0#4040ff13&| @41||+1#0000000&|o+0&&|t|h|e|r| |t|e|x|t|a+0#ffffff16#e000002|t@1|a|c|h|e|d| |t|o| |"|o|t|h|e|r|"| +0#0000000#ffffff0@1 +|~+0#4040ff13&| @41||+1#0000000&|~+0#4040ff13&| @29 +|~| @41||+1#0000000&|~+0#4040ff13&| @29 +|~| @41||+1#0000000&|~+0#4040ff13&| @29 +|[+1#0000000&|N|o| |N|a|m|e|]| @15|0|,|0|-|1| @9|A|l@1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @2|1|,|0|-|1| @6|A|l@1 +|:+0&&|c|a|l@1| |p|o|p|u|p|_|s|h|o|w|(|g|:|s|o|m|e|_|i|d|)| @47 diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 3e5373ca8..f58b159e3 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -4055,7 +4055,7 @@ func Test_popup_prop_not_visible() setline(1, ['', 'some text', '', 'other text']) prop_type_add('someprop', {}) prop_add(2, 9, {type: 'someprop', length: 5}) - popup_create('attached to "some"', { + g:some_id = popup_create('attached to "some"', { textprop: 'someprop', highlight: 'ErrorMsg', line: -1, @@ -4076,6 +4076,12 @@ func Test_popup_prop_not_visible() let buf = RunVimInTerminal('-S XtestPropNotVisble', #{rows: 10}) call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_01', {}) + " check that hiding and unhiding the popup works + call term_sendkeys(buf, ":call popup_hide(g:some_id)\<CR>") + call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_01a', {}) + call term_sendkeys(buf, ":call popup_show(g:some_id)\<CR>") + call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_01b', {}) + call term_sendkeys(buf, ":vert resize -14\<CR>") call VerifyScreenDump(buf, 'Test_popup_prop_not_visible_02', {}) diff --git a/src/version.c b/src/version.c index ead455bbd..792bd24b9 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4913, +/**/ 4912, /**/ 4911, @@ -631,15 +631,16 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); // Values for w_popup_flags. #define POPF_IS_POPUP 0x01 // this is a popup window #define POPF_HIDDEN 0x02 // popup is not displayed -#define POPF_CURSORLINE 0x04 // popup is highlighting at the cursorline -#define POPF_ON_CMDLINE 0x08 // popup overlaps command line -#define POPF_DRAG 0x10 // popup can be moved by dragging border -#define POPF_DRAGALL 0x20 // popup can be moved by dragging everywhere -#define POPF_RESIZE 0x40 // popup can be resized by dragging -#define POPF_MAPPING 0x80 // mapping keys -#define POPF_INFO 0x100 // used for info of popup menu -#define POPF_INFO_MENU 0x200 // align info popup with popup menu -#define POPF_POSINVERT 0x400 // vertical position can be inverted +#define POPF_HIDDEN_FORCE 0x04 // popup is explicitly set to not be displayed +#define POPF_CURSORLINE 0x08 // popup is highlighting at the cursorline +#define POPF_ON_CMDLINE 0x10 // popup overlaps command line +#define POPF_DRAG 0x20 // popup can be moved by dragging border +#define POPF_DRAGALL 0x40 // popup can be moved by dragging everywhere +#define POPF_RESIZE 0x80 // popup can be resized by dragging +#define POPF_MAPPING 0x100 // mapping keys +#define POPF_INFO 0x200 // used for info of popup menu +#define POPF_INFO_MENU 0x400 // align info popup with popup menu +#define POPF_POSINVERT 0x800 // vertical position can be inverted // flags used in w_popup_handled #define POPUP_HANDLED_1 0x01 // used by mouse_find_win() |