comparison src/mouse.c @ 34194:a522c6c0127b v9.1.0047

patch 9.1.0047: issues with temp curwin/buf while cmdwin is open Commit: https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f Author: Sean Dewar <seandewar@users.noreply.github.com> Date: Wed Aug 16 14:17:36 2023 +0100 patch 9.1.0047: issues with temp curwin/buf while cmdwin is open Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Alternatively, we could ban win_execute in the cmdwin and audit all places that temporarily change/restore curwin/buf, but I didn't notice any problems arising from allowing this (standard cmdwin restrictions still apply, so things that may actually break the cmdwin are still forbidden). closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 23 Jan 2024 23:00:04 +0100
parents 63341afcd329
children 7f84a834055a
comparison
equal deleted inserted replaced
34193:00b0bd66410b 34194:a522c6c0127b
1694 end_visual_mode_keep_button(); 1694 end_visual_mode_keep_button();
1695 redraw_curbuf_later(UPD_INVERTED); // delete the inversion 1695 redraw_curbuf_later(UPD_INVERTED); // delete the inversion
1696 } 1696 }
1697 #if defined(FEAT_CLIPBOARD) 1697 #if defined(FEAT_CLIPBOARD)
1698 // Continue a modeless selection in another window. 1698 // Continue a modeless selection in another window.
1699 if (cmdwin_type != 0 && row < curwin->w_winrow) 1699 if (cmdwin_type != 0 && row < cmdwin_win->w_winrow)
1700 return IN_OTHER_WIN; 1700 return IN_OTHER_WIN;
1701 #endif 1701 #endif
1702 #ifdef FEAT_PROP_POPUP 1702 #ifdef FEAT_PROP_POPUP
1703 // Continue a modeless selection in a popup window or dragging it. 1703 // Continue a modeless selection in a popup window or dragging it.
1704 if (in_popup_win) 1704 if (in_popup_win)
1822 #ifdef FEAT_FOLDING 1822 #ifdef FEAT_FOLDING
1823 && ( 1823 && (
1824 # ifdef FEAT_RIGHTLEFT 1824 # ifdef FEAT_RIGHTLEFT
1825 wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc : 1825 wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
1826 # endif 1826 # endif
1827 col >= wp->w_p_fdc + (cmdwin_type == 0 && wp == curwin ? 0 : 1) 1827 col >= wp->w_p_fdc + (wp != cmdwin_win ? 0 : 1)
1828 ) 1828 )
1829 #endif 1829 #endif
1830 && (flags & MOUSE_MAY_STOP_VIS)))) 1830 && (flags & MOUSE_MAY_STOP_VIS))))
1831 { 1831 {
1832 end_visual_mode_keep_button(); 1832 end_visual_mode_keep_button();
1833 redraw_curbuf_later(UPD_INVERTED); // delete the inversion 1833 redraw_curbuf_later(UPD_INVERTED); // delete the inversion
1834 } 1834 }
1835 if (cmdwin_type != 0 && wp != curwin) 1835 if (cmdwin_type != 0 && wp != cmdwin_win)
1836 { 1836 {
1837 // A click outside the command-line window: Use modeless 1837 // A click outside the command-line window: Use modeless
1838 // selection if possible. Allow dragging the status lines. 1838 // selection if possible. Allow dragging the status lines.
1839 on_sep_line = 0; 1839 on_sep_line = 0;
1840 #ifdef FEAT_CLIPBOARD 1840 #ifdef FEAT_CLIPBOARD
1842 return IN_STATUS_LINE; 1842 return IN_STATUS_LINE;
1843 return IN_OTHER_WIN; 1843 return IN_OTHER_WIN;
1844 #else 1844 #else
1845 row = 0; 1845 row = 0;
1846 col += wp->w_wincol; 1846 col += wp->w_wincol;
1847 wp = curwin; 1847 wp = cmdwin_win;
1848 #endif 1848 #endif
1849 } 1849 }
1850 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) 1850 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
1851 if (popup_is_popup(curwin) && curbuf->b_term != NULL) 1851 if (popup_is_popup(curwin) && curbuf->b_term != NULL)
1852 // terminal in popup window: don't jump to another window 1852 // terminal in popup window: don't jump to another window
1935 redraw_curbuf_later(UPD_INVERTED); // delete the inversion 1935 redraw_curbuf_later(UPD_INVERTED); // delete the inversion
1936 } 1936 }
1937 1937
1938 #if defined(FEAT_CLIPBOARD) 1938 #if defined(FEAT_CLIPBOARD)
1939 // Continue a modeless selection in another window. 1939 // Continue a modeless selection in another window.
1940 if (cmdwin_type != 0 && row < curwin->w_winrow) 1940 if (cmdwin_type != 0 && row < cmdwin_win->w_winrow)
1941 return IN_OTHER_WIN; 1941 return IN_OTHER_WIN;
1942 #endif 1942 #endif
1943 #ifdef FEAT_PROP_POPUP 1943 #ifdef FEAT_PROP_POPUP
1944 if (in_popup_win) 1944 if (in_popup_win)
1945 { 1945 {
2073 // Check for position outside of the fold column. 2073 // Check for position outside of the fold column.
2074 if ( 2074 if (
2075 # ifdef FEAT_RIGHTLEFT 2075 # ifdef FEAT_RIGHTLEFT
2076 curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc : 2076 curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
2077 # endif 2077 # endif
2078 col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1) 2078 col >= curwin->w_p_fdc + (cmdwin_win != curwin ? 0 : 1)
2079 ) 2079 )
2080 mouse_char = ' '; 2080 mouse_char = ' ';
2081 #endif 2081 #endif
2082 2082
2083 // compute the position in the buffer line from the posn on the screen 2083 // compute the position in the buffer line from the posn on the screen