diff src/ops.c @ 7570:4250ecde6009 v7.4.1085

commit https://github.com/vim/vim/commit/a52dfaed104183c1fa2a3b6e4430b23d86bcbece Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 10 20:21:57 2016 +0100 patch 7.4.1085 Problem: The CTRL-A and CTRL-X commands do not update the '[ and '] marks. Solution: (Yukihiro Nakadaira)
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Jan 2016 20:30:04 +0100
parents f624d7671e0c
children b872724c37db
line wrap: on
line diff
--- a/src/ops.c
+++ b/src/ops.c
@@ -5382,6 +5382,8 @@ do_addsub(command, Prenum1, g_cmd)
     int		pos = 0;
     int		bit = 0;
     int		bits = sizeof(unsigned long) * 8;
+    pos_T	startpos;
+    pos_T	endpos;
 
     dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL);	/* "heX" */
     dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL);	/* "Octal" */
@@ -5582,9 +5584,12 @@ do_addsub(command, Prenum1, g_cmd)
 #endif
 	    }
 	    curwin->w_cursor.col = col;
+	    if (!did_change)
+		startpos = curwin->w_cursor;
 	    did_change = TRUE;
 	    (void)del_char(FALSE);
 	    ins_char(firstdigit);
+	    endpos = curwin->w_cursor;
 	    curwin->w_cursor.col = col;
 	}
 	else
@@ -5677,6 +5682,8 @@ do_addsub(command, Prenum1, g_cmd)
 	     * Delete the old number.
 	     */
 	    curwin->w_cursor.col = col;
+	    if (!did_change)
+		startpos = curwin->w_cursor;
 	    did_change = TRUE;
 	    todel = length;
 	    c = gchar_cursor();
@@ -5763,6 +5770,7 @@ do_addsub(command, Prenum1, g_cmd)
 	    STRCAT(buf1, buf2);
 	    ins_str(buf1);		/* insert the new number */
 	    vim_free(buf1);
+	    endpos = curwin->w_cursor;
 	    if (lnum < lnume)
 		curwin->w_cursor.col = t.col;
 	    else if (did_change && curwin->w_cursor.col)
@@ -5788,6 +5796,14 @@ do_addsub(command, Prenum1, g_cmd)
     if (visual)
 	/* cursor at the top of the selection */
 	curwin->w_cursor = VIsual;
+    if (did_change)
+    {
+	/* set the '[ and '] marks */
+	curbuf->b_op_start = startpos;
+	curbuf->b_op_end = endpos;
+	if (curbuf->b_op_end.col > 0)
+	    --curbuf->b_op_end.col;
+    }
     return OK;
 }