@@ -5382,6 +5382,8 @@ do_addsub(command, Prenum1, g_cmd)
53825382 int pos = 0 ;
53835383 int bit = 0 ;
53845384 int bits = sizeof (unsigned long ) * 8 ;
5385+ pos_T startpos ;
5386+ pos_T endpos ;
53855387
53865388 dohex = (vim_strchr (curbuf -> b_p_nf , 'x' ) != NULL ); /* "heX" */
53875389 dooct = (vim_strchr (curbuf -> b_p_nf , 'o' ) != NULL ); /* "Octal" */
@@ -5582,9 +5584,12 @@ do_addsub(command, Prenum1, g_cmd)
55825584#endif
55835585 }
55845586 curwin -> w_cursor .col = col ;
5587+ if (!did_change )
5588+ startpos = curwin -> w_cursor ;
55855589 did_change = TRUE;
55865590 (void )del_char (FALSE);
55875591 ins_char (firstdigit );
5592+ endpos = curwin -> w_cursor ;
55885593 curwin -> w_cursor .col = col ;
55895594 }
55905595 else
@@ -5677,6 +5682,8 @@ do_addsub(command, Prenum1, g_cmd)
56775682 * Delete the old number.
56785683 */
56795684 curwin -> w_cursor .col = col ;
5685+ if (!did_change )
5686+ startpos = curwin -> w_cursor ;
56805687 did_change = TRUE;
56815688 todel = length ;
56825689 c = gchar_cursor ();
@@ -5763,6 +5770,7 @@ do_addsub(command, Prenum1, g_cmd)
57635770 STRCAT (buf1 , buf2 );
57645771 ins_str (buf1 ); /* insert the new number */
57655772 vim_free (buf1 );
5773+ endpos = curwin -> w_cursor ;
57665774 if (lnum < lnume )
57675775 curwin -> w_cursor .col = t .col ;
57685776 else if (did_change && curwin -> w_cursor .col )
@@ -5788,6 +5796,14 @@ do_addsub(command, Prenum1, g_cmd)
57885796 if (visual )
57895797 /* cursor at the top of the selection */
57905798 curwin -> w_cursor = VIsual ;
5799+ if (did_change )
5800+ {
5801+ /* set the '[ and '] marks */
5802+ curbuf -> b_op_start = startpos ;
5803+ curbuf -> b_op_end = endpos ;
5804+ if (curbuf -> b_op_end .col > 0 )
5805+ -- curbuf -> b_op_end .col ;
5806+ }
57915807 return OK ;
57925808}
57935809
0 commit comments