Now it accepts len in screen cells.

Cheers, Alexey.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r 1d3b648de738 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt	Wed Jul 02 20:00:48 2014 +0200
+++ b/runtime/doc/eval.txt	Thu Jul 03 12:13:21 2014 +0400
@@ -4401,7 +4401,8 @@
 		  |col()| would return).  The character at this position will
 		  be highlighted.
 		- A list with three numbers, e.g., [23, 11, 3]. As above, but
-		  the third number gives the length of the highlight in bytes.
+		  the third number gives the length of the highlight in screen
+		  cells.
 		
 		The maximum number of positions is 8.
 
diff -r 1d3b648de738 src/screen.c
--- a/src/screen.c	Wed Jul 02 20:00:48 2014 +0200
+++ b/src/screen.c	Thu Jul 03 12:13:21 2014 +0400
@@ -7636,8 +7636,40 @@
     {
 	colnr_T	start = posmatch->pos[bot].col == 0
 					     ? 0 : posmatch->pos[bot].col - 1;
-	colnr_T	end = posmatch->pos[bot].col == 0
-				    ? MAXCOL : start + posmatch->pos[bot].len;
+	colnr_T	end = MAXCOL;
+
+	if (start < 0)
+	    return FALSE;
+
+	if (posmatch->pos[bot].col > 0)
+	{
+	    int	len = 0;
+
+#ifdef FEAT_MBYTE
+	    if (has_mbyte)
+	    {
+		char_u	*ml = ml_get_buf(shl->buf, lnum, FALSE);
+		int	ml_len = STRLEN(ml);
+
+		if (start > ml_len)
+		    return FALSE;
+
+		for (i = 0; i < posmatch->pos[bot].len; i++)
+		{
+		    if (len + start > ml_len)
+		    {
+			len = ml_len - start;
+			break;
+		    }
+		    len += (*mb_ptr2len)(ml + start + len);
+		}
+	    }
+	    else
+#endif
+		len = posmatch->pos[bot].len;
+
+	    end = start + len;
+	}
 
 	shl->rm.startpos[0].lnum = 0;
 	shl->rm.startpos[0].col = start;

Raspunde prin e-mail lui