Patch 8.1.1963
Problem: Popup window filter may be called recursively when using a Normal
mode command. (Nick Jensen)
Solution: Prevent recursiveness. (closes #4887) Also restore KeyTyped.
Files: src/popupwin.c, src/testdir/test_popupwin.vim
*** ../vim-8.1.1962/src/popupwin.c 2019-09-01 17:38:05.332455200 +0200
--- src/popupwin.c 2019-09-01 23:22:46.447977386 +0200
***************
*** 2764,2771 ****
--- 2764,2777 ----
int
popup_do_filter(int c)
{
+ static int recursive = FALSE;
int res = FALSE;
win_T *wp;
+ int save_KeyTyped = KeyTyped;
+
+ if (recursive)
+ return FALSE;
+ recursive = TRUE;
popup_reset_handled();
***************
*** 2776,2788 ****
wp = mouse_find_win(&row, &col, FIND_POPUP);
if (wp != NULL && popup_close_if_on_X(wp, row, col))
! return TRUE;
}
while (!res && (wp = find_next_popup(FALSE)) != NULL)
if (wp->w_filter_cb.cb_name != NULL)
res = invoke_popup_filter(wp, c);
return res;
}
--- 2782,2796 ----
wp = mouse_find_win(&row, &col, FIND_POPUP);
if (wp != NULL && popup_close_if_on_X(wp, row, col))
! res = TRUE;
}
while (!res && (wp = find_next_popup(FALSE)) != NULL)
if (wp->w_filter_cb.cb_name != NULL)
res = invoke_popup_filter(wp, c);
+ recursive = FALSE;
+ KeyTyped = save_KeyTyped;
return res;
}
*** ../vim-8.1.1962/src/testdir/test_popupwin.vim 2019-09-01
17:38:05.332455200 +0200
--- src/testdir/test_popupwin.vim 2019-09-01 23:07:20.396364772 +0200
***************
*** 1919,1924 ****
--- 1919,1949 ----
call delete('XsomeFile')
endfunc
+ func Test_popupwin_with_buffer_and_filter()
+ new Xwithfilter
+ call setline(1, range(100))
+ let bufnr = bufnr()
+ hide
+
+ func BufferFilter(win, key)
+ if a:key == 'G'
+ " recursive use of "G" does not cause problems.
+ call win_execute(a:win, 'normal! G')
+ return 1
+ endif
+ return 0
+ endfunc
+
+ let winid = popup_create(bufnr, #{maxheight: 5, filter: 'BufferFilter'})
+ call assert_equal(1, popup_getpos(winid).firstline)
+ redraw
+ call feedkeys("G", 'xt')
+ call assert_equal(99, popup_getpos(winid).firstline)
+
+ call popup_close(winid)
+ exe 'bwipe! ' .. bufnr
+ endfunc
+
func Test_popupwin_width()
let winid = popup_create(repeat(['short', 'long long long line', 'medium
width'], 50), #{
\ maxwidth: 40,
*** ../vim-8.1.1962/src/version.c 2019-09-01 20:21:53.070152262 +0200
--- src/version.c 2019-09-01 23:26:31.570908613 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 1963,
/**/
--
hundred-and-one symptoms of being an internet addict:
167. You have more than 200 websites bookmarked.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201909012127.x81LRo0U029789%40masaka.moolenaar.net.