diff src/popupwin.c @ 17946:ec4248c4b92c v8.1.1969

patch 8.1.1969: popup window filter is used in all modes Commit: https://github.com/vim/vim/commit/581ba39aefe837298a9943b04a1dab13a7ec6772 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 3 22:08:33 2019 +0200 patch 8.1.1969: popup window filter is used in all modes Problem: Popup window filter is used in all modes. Solution: Add the "filtermode" property.
author Bram Moolenaar <Bram@vim.org>
date Tue, 03 Sep 2019 22:15:03 +0200
parents 0bf8cb0258be
children 2fdbcecab216
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -845,6 +845,15 @@ apply_general_options(win_T *wp, dict_T 
 	    wp->w_popup_flags &= ~POPF_MAPPING;
     }
 
+    str = dict_get_string(dict, (char_u *)"filtermode", FALSE);
+    if (str != NULL)
+    {
+	if (STRCMP(str, "a") == 0)
+	    wp->w_filter_mode = MODE_ALL;
+	else
+	    wp->w_filter_mode = mode_str2flags(str);
+    }
+
     di = dict_find(dict, (char_u *)"callback", -1);
     if (di != NULL)
     {
@@ -1851,6 +1860,7 @@ popup_create(typval_T *argvars, typval_T
 	wp->w_border_char[i] = 0;
     wp->w_want_scrollbar = 1;
     wp->w_popup_fixed = 0;
+    wp->w_filter_mode = MODE_ALL;
 
     if (d != NULL)
 	// Deal with options.
@@ -2768,6 +2778,7 @@ popup_do_filter(int c)
     int		res = FALSE;
     win_T	*wp;
     int		save_KeyTyped = KeyTyped;
+    int		state;
 
     if (recursive)
 	return FALSE;
@@ -2785,8 +2796,10 @@ popup_do_filter(int c)
 	    res = TRUE;
     }
 
+    state = get_real_state();
     while (!res && (wp = find_next_popup(FALSE)) != NULL)
-	if (wp->w_filter_cb.cb_name != NULL)
+	if (wp->w_filter_cb.cb_name != NULL
+		&& (wp->w_filter_mode & state) != 0)
 	    res = invoke_popup_filter(wp, c);
 
     recursive = FALSE;