@@ -5371,9 +5371,9 @@ op_addsub(oap, Prenum1, g_cmd)
53715371 }
53725372 else
53735373 {
5374- int one_change ;
5375- int length ;
5376- pos_T startpos ;
5374+ int one_change ;
5375+ int length ;
5376+ pos_T startpos ;
53775377
53785378 if (u_save ((linenr_T )(oap -> start .lnum - 1 ),
53795379 (linenr_T )(oap -> end .lnum + 1 )) == FAIL )
@@ -5388,32 +5388,29 @@ op_addsub(oap, Prenum1, g_cmd)
53885388 pos .col = bd .textcol ;
53895389 length = bd .textlen ;
53905390 }
5391- else
5391+ else if (oap -> motion_type == MLINE )
5392+ {
5393+ curwin -> w_cursor .col = 0 ;
5394+ pos .col = 0 ;
5395+ length = (colnr_T )STRLEN (ml_get (pos .lnum ));
5396+ }
5397+ else /* oap->motion_type == MCHAR */
53925398 {
5393- if (oap -> motion_type == MLINE )
5399+ if (!oap -> inclusive )
5400+ dec (& (oap -> end ));
5401+ length = (colnr_T )STRLEN (ml_get (pos .lnum ));
5402+ pos .col = 0 ;
5403+ if (pos .lnum == oap -> start .lnum )
53945404 {
5395- curwin -> w_cursor .col = 0 ;
5396- pos .col = 0 ;
5397- length = (colnr_T )STRLEN (ml_get (pos .lnum ));
5405+ pos .col += oap -> start .col ;
5406+ length -= oap -> start .col ;
53985407 }
5399- else if (oap -> motion_type == MCHAR )
5408+ if (pos . lnum == oap -> end . lnum )
54005409 {
5401- if (!oap -> inclusive )
5402- dec (& (oap -> end ));
5403- length = (colnr_T )STRLEN (ml_get (pos .lnum ));
5404- pos .col = 0 ;
5405- if (pos .lnum == oap -> start .lnum )
5406- {
5407- pos .col += oap -> start .col ;
5408- length -= oap -> start .col ;
5409- }
5410- if (pos .lnum == oap -> end .lnum )
5411- {
5412- length = (int )STRLEN (ml_get (oap -> end .lnum ));
5413- if (oap -> end .col >= length )
5414- oap -> end .col = length - 1 ;
5415- length = oap -> end .col - pos .col + 1 ;
5416- }
5410+ length = (int )STRLEN (ml_get (oap -> end .lnum ));
5411+ if (oap -> end .col >= length )
5412+ oap -> end .col = length - 1 ;
5413+ length = oap -> end .col - pos .col + 1 ;
54175414 }
54185415 }
54195416 one_change = do_addsub (oap -> op_type , & pos , length , amount );
@@ -5493,7 +5490,7 @@ do_addsub(op_type, pos, length, Prenum1)
54935490 int was_positive = TRUE;
54945491 int visual = VIsual_active ;
54955492 int did_change = FALSE;
5496- pos_T t = curwin -> w_cursor ;
5493+ pos_T save_cursor = curwin -> w_cursor ;
54975494 int maxlen = 0 ;
54985495 pos_T startpos ;
54995496 pos_T endpos ;
@@ -5819,9 +5816,6 @@ do_addsub(op_type, pos, length, Prenum1)
58195816 -- curwin -> w_cursor .col ;
58205817 }
58215818
5822- theend :
5823- if (visual )
5824- curwin -> w_cursor = t ;
58255819 if (did_change )
58265820 {
58275821 /* set the '[ and '] marks */
@@ -5831,6 +5825,10 @@ do_addsub(op_type, pos, length, Prenum1)
58315825 -- curbuf -> b_op_end .col ;
58325826 }
58335827
5828+ theend :
5829+ if (visual )
5830+ curwin -> w_cursor = save_cursor ;
5831+
58345832 return did_change ;
58355833}
58365834
0 commit comments