mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Fix click on foldcolumn with vsplit (#14127)
This commit is contained in:
		| @@ -717,23 +717,22 @@ static int mouse_adjust_click(win_T *wp, int row, int col) | ||||
| // Check clicked cell is foldcolumn | ||||
| int mouse_check_fold(void) | ||||
| { | ||||
|   int grid = mouse_grid; | ||||
|   int row = mouse_row; | ||||
|   int col = mouse_col; | ||||
|   int click_grid = mouse_grid; | ||||
|   int click_row = mouse_row; | ||||
|   int click_col = mouse_col; | ||||
|   int mouse_char = ' '; | ||||
|  | ||||
|   win_T *wp; | ||||
|  | ||||
|   wp = mouse_find_win(&grid, &row, &col); | ||||
|   wp = mouse_find_win(&click_grid, &click_row, &click_col); | ||||
|  | ||||
|   if (wp && mouse_row >= 0 && mouse_row < Rows | ||||
|       && mouse_col >= 0 && mouse_col <= Columns) { | ||||
|     int multigrid = ui_has(kUIMultigrid); | ||||
|     ScreenGrid *gp = multigrid ? &wp->w_grid : &default_grid; | ||||
|     int fdc = win_fdccol_count(wp); | ||||
|  | ||||
|     row = multigrid && mouse_grid == 0 ? row : mouse_row; | ||||
|     col = multigrid && mouse_grid == 0 ? col : mouse_col; | ||||
|     int row = multigrid && mouse_grid == 0 ? click_row : mouse_row; | ||||
|     int col = multigrid && mouse_grid == 0 ? click_col : mouse_col; | ||||
|  | ||||
|     // Remember the character under the mouse, might be one of foldclose or | ||||
|     // foldopen fillchars in the fold column. | ||||
| @@ -743,8 +742,8 @@ int mouse_check_fold(void) | ||||
|     } | ||||
|  | ||||
|     // Check for position outside of the fold column. | ||||
|     if (wp->w_p_rl ? col < wp->w_width_inner - fdc : | ||||
|         col >= fdc + (cmdwin_type == 0 ? 0 : 1)) { | ||||
|     if (wp->w_p_rl ? click_col < wp->w_width_inner - fdc : | ||||
|         click_col >= fdc + (cmdwin_type == 0 ? 0 : 1)) { | ||||
|       mouse_char = ' '; | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -464,6 +464,206 @@ describe("folded lines", function() | ||||
|       end | ||||
|     end) | ||||
|  | ||||
|     it("works with vsplit", function() | ||||
|       insert([[ | ||||
|         aa | ||||
|         bb | ||||
|         cc | ||||
|         dd | ||||
|         ee | ||||
|         ff]]) | ||||
|       feed_command('2') | ||||
|       command("set foldcolumn=1") | ||||
|       feed('zf3j') | ||||
|       feed_command('1') | ||||
|       feed('zf2j') | ||||
|       feed('zO') | ||||
|       feed_command("rightbelow vnew") | ||||
|       insert([[ | ||||
|         aa | ||||
|         bb | ||||
|         cc | ||||
|         dd | ||||
|         ee | ||||
|         ff]]) | ||||
|       feed_command('2') | ||||
|       command("set foldcolumn=1") | ||||
|       feed('zf3j') | ||||
|       feed_command('1') | ||||
|       feed('zf2j') | ||||
|       if multigrid then | ||||
|         meths.input_mouse('left', 'press', '', 4, 0, 0) | ||||
|         screen:expect([[ | ||||
|         ## grid 1 | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           {2:[No Name] [+]          }{3:[No Name] [+]         }| | ||||
|           [3:---------------------------------------------]| | ||||
|         ## grid 2 | ||||
|           {7:-}aa                   | | ||||
|           {7:-}bb                   | | ||||
|           {7:2}cc                   | | ||||
|           {7:2}dd                   | | ||||
|           {7:2}ee                   | | ||||
|           {7:│}ff                   | | ||||
|         ## grid 3 | ||||
|           :1                                           | | ||||
|         ## grid 4 | ||||
|           {7:-}^aa                   | | ||||
|           {7:+}{5:+---  4 lines: bb····}| | ||||
|           {7:│}ff                   | | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|         ]]) | ||||
|       else | ||||
|         meths.input_mouse('left', 'press', '', 0, 0, 23) | ||||
|         screen:expect([[ | ||||
|           {7:-}aa                   {2:│}{7:-}^aa                   | | ||||
|           {7:-}bb                   {2:│}{7:+}{5:+---  4 lines: bb····}| | ||||
|           {7:2}cc                   {2:│}{7:│}ff                   | | ||||
|           {7:2}dd                   {2:│}{1:~                     }| | ||||
|           {7:2}ee                   {2:│}{1:~                     }| | ||||
|           {7:│}ff                   {2:│}{1:~                     }| | ||||
|           {2:[No Name] [+]          }{3:[No Name] [+]         }| | ||||
|           :1                                           | | ||||
|         ]]) | ||||
|       end | ||||
|  | ||||
|       if multigrid then | ||||
|         meths.input_mouse('left', 'press', '', 4, 1, 0) | ||||
|         screen:expect([[ | ||||
|         ## grid 1 | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           {2:[No Name] [+]          }{3:[No Name] [+]         }| | ||||
|           [3:---------------------------------------------]| | ||||
|         ## grid 2 | ||||
|           {7:-}aa                   | | ||||
|           {7:-}bb                   | | ||||
|           {7:2}cc                   | | ||||
|           {7:2}dd                   | | ||||
|           {7:2}ee                   | | ||||
|           {7:│}ff                   | | ||||
|         ## grid 3 | ||||
|           :1                                           | | ||||
|         ## grid 4 | ||||
|           {7:-}^aa                   | | ||||
|           {7:-}bb                   | | ||||
|           {7:2}cc                   | | ||||
|           {7:2}dd                   | | ||||
|           {7:2}ee                   | | ||||
|           {7:│}ff                   | | ||||
|         ]]) | ||||
|       else | ||||
|         meths.input_mouse('left', 'press', '', 0, 1, 23) | ||||
|         screen:expect([[ | ||||
|           {7:-}aa                   {2:│}{7:-}^aa                   | | ||||
|           {7:-}bb                   {2:│}{7:-}bb                   | | ||||
|           {7:2}cc                   {2:│}{7:2}cc                   | | ||||
|           {7:2}dd                   {2:│}{7:2}dd                   | | ||||
|           {7:2}ee                   {2:│}{7:2}ee                   | | ||||
|           {7:│}ff                   {2:│}{7:│}ff                   | | ||||
|           {2:[No Name] [+]          }{3:[No Name] [+]         }| | ||||
|           :1                                           | | ||||
|         ]]) | ||||
|       end | ||||
|  | ||||
|       if multigrid then | ||||
|         meths.input_mouse('left', 'press', '', 2, 1, 0) | ||||
|         screen:expect([[ | ||||
|         ## grid 1 | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           {3:[No Name] [+]          }{2:[No Name] [+]         }| | ||||
|           [3:---------------------------------------------]| | ||||
|         ## grid 2 | ||||
|           {7:-}aa                   | | ||||
|           {7:+}{5:^+---  4 lines: bb····}| | ||||
|           {7:│}ff                   | | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|         ## grid 3 | ||||
|           :1                                           | | ||||
|         ## grid 4 | ||||
|           {7:-}aa                   | | ||||
|           {7:-}bb                   | | ||||
|           {7:2}cc                   | | ||||
|           {7:2}dd                   | | ||||
|           {7:2}ee                   | | ||||
|           {7:│}ff                   | | ||||
|         ]]) | ||||
|       else | ||||
|         meths.input_mouse('left', 'press', '', 0, 1, 0) | ||||
|         screen:expect([[ | ||||
|           {7:-}aa                   {2:│}{7:-}aa                   | | ||||
|           {7:+}{5:^+---  4 lines: bb····}{2:│}{7:-}bb                   | | ||||
|           {7:│}ff                   {2:│}{7:2}cc                   | | ||||
|           {1:~                     }{2:│}{7:2}dd                   | | ||||
|           {1:~                     }{2:│}{7:2}ee                   | | ||||
|           {1:~                     }{2:│}{7:│}ff                   | | ||||
|           {3:[No Name] [+]          }{2:[No Name] [+]         }| | ||||
|           :1                                           | | ||||
|         ]]) | ||||
|       end | ||||
|  | ||||
|       if multigrid then | ||||
|         meths.input_mouse('left', 'press', '', 2, 0, 0) | ||||
|         screen:expect([[ | ||||
|         ## grid 1 | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           [2:----------------------]{2:│}[4:----------------------]| | ||||
|           {3:[No Name] [+]          }{2:[No Name] [+]         }| | ||||
|           [3:---------------------------------------------]| | ||||
|         ## grid 2 | ||||
|           {7:+}{5:^+--  6 lines: aa·····}| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|           {1:~                     }| | ||||
|         ## grid 3 | ||||
|           :1                                           | | ||||
|         ## grid 4 | ||||
|           {7:-}aa                   | | ||||
|           {7:-}bb                   | | ||||
|           {7:2}cc                   | | ||||
|           {7:2}dd                   | | ||||
|           {7:2}ee                   | | ||||
|           {7:│}ff                   | | ||||
|         ]]) | ||||
|       else | ||||
|         meths.input_mouse('left', 'press', '', 0, 0, 0) | ||||
|         screen:expect([[ | ||||
|           {7:+}{5:^+--  6 lines: aa·····}{2:│}{7:-}aa                   | | ||||
|           {1:~                     }{2:│}{7:-}bb                   | | ||||
|           {1:~                     }{2:│}{7:2}cc                   | | ||||
|           {1:~                     }{2:│}{7:2}dd                   | | ||||
|           {1:~                     }{2:│}{7:2}ee                   | | ||||
|           {1:~                     }{2:│}{7:│}ff                   | | ||||
|           {3:[No Name] [+]          }{2:[No Name] [+]         }| | ||||
|           :1                                           | | ||||
|         ]]) | ||||
|       end | ||||
|     end) | ||||
|  | ||||
|     it("works with tab", function() | ||||
|       insert([[ | ||||
|         aa | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 tk-shirasaka
					tk-shirasaka