changeset 18658:0969f82fbbff v8.1.2321

patch 8.1.2321: cannot select all text with the mouse Commit: https://github.com/vim/vim/commit/0a5aa7b28a39507260acb15c1ef698a33c855cc1 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 18 23:31:48 2019 +0100 patch 8.1.2321: cannot select all text with the mouse Problem: Cannot select all text with the mouse. (John Marriott) Solution: Move limiting the mouse column to f_getmousepos(). (closes https://github.com/vim/vim/issues/5242)
author Bram Moolenaar <Bram@vim.org>
date Mon, 18 Nov 2019 23:45:03 +0100
parents 0e6db1821963
children c68c1e19acfa
files src/mouse.c src/version.c
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -2822,7 +2822,6 @@ mouse_comp_pos(
     int		retval = FALSE;
     int		off;
     int		count;
-    char_u	*p;
 
 #ifdef FEAT_RIGHTLEFT
     if (win->w_p_rl)
@@ -2882,11 +2881,6 @@ mouse_comp_pos(
 	col += row * (win->w_width - off);
 	// add skip column (for long wrapping line)
 	col += win->w_skipcol;
-	// limit to text length plus one
-	p = ml_get_buf(win->w_buffer, lnum, FALSE);
-	count = (int)STRLEN(p);
-	if (col > count)
-	    col = count;
     }
 
     if (!win->w_p_wrap)
@@ -3053,7 +3047,17 @@ f_getmousepos(typval_T *argvars UNUSED, 
 	    col -= left_off;
 	    if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
 	    {
+		char_u	*p;
+		int	count;
+
 		mouse_comp_pos(wp, &row, &col, &line, NULL);
+
+		// limit to text length plus one
+		p = ml_get_buf(wp->w_buffer, line, FALSE);
+		count = (int)STRLEN(p);
+		if (col > count)
+		    col = count;
+
 		column = col + 1;
 	    }
 	}
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2321,
+/**/
     2320,
 /**/
     2319,