]> granicus.if.org Git - vim/commitdiff
patch 7.4.779 v7.4.779
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Jul 2015 13:02:38 +0000 (15:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Jul 2015 13:02:38 +0000 (15:02 +0200)
Problem:    Using CTRL-A in a line without a number moves the cursor. May
            cause a crash when at the start of the line. (Urtica Dioica)
Solution:   Do not move the cursor if no number was changed.

src/ops.c
src/version.c

index 8752477e39374e5c3c4b95f8b09b6cb506b767f8..e8820517124c817a5a9a8ef0e3bf8dc272c6cc1b 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -5404,6 +5404,7 @@ do_addsub(command, Prenum1, g_cmd)
     int                lnum = curwin->w_cursor.lnum;
     int                lnume = curwin->w_cursor.lnum;
     int                startcol;
+    int                did_change = FALSE;
 
     dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */
     dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
@@ -5547,6 +5548,7 @@ do_addsub(command, Prenum1, g_cmd)
 #endif
            }
            curwin->w_cursor.col = col;
+           did_change = TRUE;
            (void)del_char(FALSE);
            ins_char(firstdigit);
        }
@@ -5619,6 +5621,7 @@ do_addsub(command, Prenum1, g_cmd)
             * Delete the old number.
             */
            curwin->w_cursor.col = col;
+           did_change = TRUE;
            todel = length;
            c = gchar_cursor();
 
@@ -5713,7 +5716,8 @@ do_addsub(command, Prenum1, g_cmd)
        RLADDSUBFIX(ptr);
 #endif
     }
-    --curwin->w_cursor.col;
+    if (did_change && curwin->w_cursor.col > 0)
+       --curwin->w_cursor.col;
     return OK;
 }
 
index 016b25c1d66e20a299bdcf0d141a0f4962859899..f90e5093044af46bd4a8f2414829c236e8391453 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    779,
 /**/
     778,
 /**/