comparison src/mouse.c @ 31133:cc0c4141fb73 v9.0.0901

patch 9.0.0901: setting w_leftcol and handling side effects is confusing Commit: https://github.com/vim/vim/commit/0c34d562647f029faca40f7733ccfb7b5377672b Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 18 14:07:20 2022 +0000 patch 9.0.0901: setting w_leftcol and handling side effects is confusing Problem: Setting w_leftcol and handling side effects is confusing. Solution: Use a function to set w_leftcol() and handle side effects.
author Bram Moolenaar <Bram@vim.org>
date Fri, 18 Nov 2022 15:15:04 +0100
parents 33ca088dbd3e
children 759b181807f7
comparison
equal deleted inserted replaced
31132:f56004c00be2 31133:cc0c4141fb73
2033 return FALSE; // no wrapping, no scrolling 2033 return FALSE; // no wrapping, no scrolling
2034 2034
2035 if (curwin->w_leftcol == (colnr_T)leftcol) 2035 if (curwin->w_leftcol == (colnr_T)leftcol)
2036 return FALSE; // already there 2036 return FALSE; // already there
2037 2037
2038 curwin->w_leftcol = (colnr_T)leftcol;
2039
2040 // When the line of the cursor is too short, move the cursor to the 2038 // When the line of the cursor is too short, move the cursor to the
2041 // longest visible line. 2039 // longest visible line.
2042 if ( 2040 if (
2043 #ifdef FEAT_GUI 2041 #ifdef FEAT_GUI
2044 (!gui.in_use || vim_strchr(p_go, GO_HORSCROLL) == NULL) && 2042 (!gui.in_use || vim_strchr(p_go, GO_HORSCROLL) == NULL) &&
2048 { 2046 {
2049 curwin->w_cursor.lnum = ui_find_longest_lnum(); 2047 curwin->w_cursor.lnum = ui_find_longest_lnum();
2050 curwin->w_cursor.col = 0; 2048 curwin->w_cursor.col = 0;
2051 } 2049 }
2052 2050
2053 return leftcol_changed(); 2051 return set_leftcol((colnr_T)leftcol);
2054 } 2052 }
2055 2053
2056 /* 2054 /*
2057 * Mouse scroll wheel: Default action is to scroll mouse_vert_step lines (or 2055 * Mouse scroll wheel: Default action is to scroll mouse_vert_step lines (or
2058 * mouse_hor_step, depending on the scroll direction), or one page when Shift 2056 * mouse_hor_step, depending on the scroll direction), or one page when Shift
2096 // This window is a terminal window, send the mouse event there. 2094 // This window is a terminal window, send the mouse event there.
2097 // Set "typed" to FALSE to avoid an endless loop. 2095 // Set "typed" to FALSE to avoid an endless loop.
2098 send_keys_to_term(curbuf->b_term, cap->cmdchar, mod_mask, FALSE); 2096 send_keys_to_term(curbuf->b_term, cap->cmdchar, mod_mask, FALSE);
2099 else 2097 else
2100 # endif 2098 # endif
2101 // For insert mode, don't scroll the window in which completion is being 2099 // For Insert mode, don't scroll the window in which completion is being
2102 // done. 2100 // done.
2103 if (mode == MODE_NORMAL || !pum_visible() || curwin != old_curwin) 2101 if (mode == MODE_NORMAL || !pum_visible() || curwin != old_curwin)
2104 { 2102 {
2105 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) 2103 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
2106 { 2104 {