To: vim_dev@googlegroups.com Subject: Patch 8.1.1884 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1884 Problem: Cannot use mouse scroll wheel in popup in Insert mode. Mouse clicks in popup close the popup menu. Solution: Check if the mouse is in a popup window. Do not let mouse events close the popup menu. (closes #4544) Files: src/edit.c, src/popupmnu.c, src/insexpand.c *** ../vim-8.1.1883/src/edit.c 2019-06-12 20:21:57.737817533 +0200 --- src/edit.c 2019-08-18 17:15:45.826882712 +0200 *************** *** 5267,5273 **** col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col, FAIL_POPUP); if (wp == NULL) return; curwin = wp; --- 5267,5273 ---- col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col, FIND_POPUP); if (wp == NULL) return; curwin = wp; *************** *** 5288,5293 **** --- 5288,5297 ---- (long)(curwin->w_botline - curwin->w_topline)); else scroll_redraw(dir, 3L); + # ifdef FEAT_TEXT_PROP + if (WIN_IS_POPUP(curwin)) + popup_set_firstline(curwin); + # endif } #ifdef FEAT_GUI else *** ../vim-8.1.1883/src/popupmnu.c 2019-08-18 15:24:23.197608923 +0200 --- src/popupmnu.c 2019-08-18 19:20:55.466507293 +0200 *************** *** 638,643 **** --- 638,644 ---- { int resized = FALSE; int context = pum_height / 2; + int prev_selected = pum_selected; #ifdef FEAT_TEXT_PROP int has_info = FALSE; #endif *************** *** 826,832 **** curbuf->b_changed = 0; curbuf->b_p_ma = FALSE; ! curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; if (use_popup && win_valid(curwin_save)) redraw_win_later(curwin_save, SOME_VALID); --- 827,842 ---- curbuf->b_changed = 0; curbuf->b_p_ma = FALSE; ! if (pum_selected != prev_selected) ! { ! # ifdef FEAT_TEXT_PROP ! curwin->w_firstline = 1; ! # endif ! curwin->w_topline = 1; ! } ! else if (curwin->w_topline > curbuf->b_ml.ml_line_count) ! curwin->w_topline = curbuf->b_ml.ml_line_count; ! curwin->w_cursor.lnum = curwin->w_topline; curwin->w_cursor.col = 0; if (use_popup && win_valid(curwin_save)) redraw_win_later(curwin_save, SOME_VALID); *** ../vim-8.1.1883/src/insexpand.c 2019-08-15 21:30:26.622085162 +0200 --- src/insexpand.c 2019-08-18 18:42:07.215280901 +0200 *************** *** 1943,1948 **** --- 1943,1978 ---- || c == K_MOUSELEFT || c == K_MOUSERIGHT) return retval; + #ifdef FEAT_TEXT_PROP + // Ignore mouse events in a popup window + if (is_mouse_key(c)) + { + // Ignore drag and release events, the position does not need to be in + // the popup and it may have just closed. + if (c == K_LEFTRELEASE + || c == K_LEFTRELEASE_NM + || c == K_MIDDLERELEASE + || c == K_RIGHTRELEASE + || c == K_X1RELEASE + || c == K_X2RELEASE + || c == K_LEFTDRAG + || c == K_MIDDLEDRAG + || c == K_RIGHTDRAG + || c == K_X1DRAG + || c == K_X2DRAG) + return retval; + if (popup_visible) + { + int row = mouse_row; + int col = mouse_col; + win_T *wp = mouse_find_win(&row, &col, FIND_POPUP); + + if (wp != NULL && WIN_IS_POPUP(wp)) + return retval; + } + } + #endif + // Set "compl_get_longest" when finding the first matches. if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || (ctrl_x_mode == CTRL_X_NORMAL && !compl_started)) *** ../vim-8.1.1883/src/version.c 2019-08-18 17:58:08.389767777 +0200 --- src/version.c 2019-08-18 19:22:24.082100145 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1884, /**/ -- From "know your smileys": :-) Funny |-) Funny Oriental (-: Funny Australian /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///