@@ -849,8 +849,8 @@ op_delete(oparg_T *oap)
849849 }
850850 else
851851 beginline (0 ); // cursor in column 0
852- truncate_line (FALSE); // delete the rest of the line
853- // leave cursor past last char in line
852+ truncate_line (FALSE); // delete the rest of the line,
853+ // leaving cursor past last char in line
854854 if (oap -> line_count > 1 )
855855 u_clearline (); // "U" command not possible after "2cc"
856856 }
@@ -1494,16 +1494,13 @@ swapchar(int op_type, pos_T *pos)
14941494 void
14951495op_insert (oparg_T * oap , long count1 )
14961496{
1497- long ins_len , pre_textlen = 0 ;
1498- char_u * firstline , * ins_text ;
1497+ long pre_textlen = 0 ;
14991498 colnr_T ind_pre_col = 0 , ind_post_col ;
15001499 int ind_pre_vcol = 0 , ind_post_vcol = 0 ;
15011500 struct block_def bd ;
15021501 int i ;
15031502 pos_T t1 ;
15041503 pos_T start_insert ;
1505- // offset when cursor was moved in insert mode
1506- int offset = 0 ;
15071504
15081505 // edit() changes this - record it for OP_APPEND
15091506 bd .is_MAX = (curwin -> w_curswant == MAXCOL );
@@ -1540,14 +1537,9 @@ op_insert(oparg_T *oap, long count1)
15401537 // Get indent information
15411538 ind_pre_col = (colnr_T )getwhitecols_curline ();
15421539 ind_pre_vcol = get_indent ();
1543- firstline = ml_get (oap -> start .lnum ) + bd .textcol ;
15441540 pre_textlen = ml_get_len (oap -> start .lnum ) - bd .textcol ;
1545-
15461541 if (oap -> op_type == OP_APPEND )
1547- {
1548- firstline += bd .textlen ;
15491542 pre_textlen -= bd .textlen ;
1550- }
15511543 }
15521544
15531545 if (oap -> op_type == OP_APPEND )
@@ -1601,10 +1593,14 @@ op_insert(oparg_T *oap, long count1)
16011593
16021594 if (oap -> block_mode )
16031595 {
1596+ long ins_len ;
1597+ char_u * firstline , * ins_text ;
16041598 struct block_def bd2 ;
16051599 int did_indent = FALSE;
16061600 size_t len ;
16071601 int add ;
1602+ // offset when cursor was moved in insert mode
1603+ int offset = 0 ;
16081604
16091605 // If indent kicked in, the firstline might have changed
16101606 // but only do that, if the indent actually increased.
@@ -2654,6 +2650,7 @@ do_addsub(
26542650 uvarnumber_T n ;
26552651 uvarnumber_T oldn ;
26562652 char_u * ptr ;
2653+ int linelen ;
26572654 int c ;
26582655 int todel ;
26592656 int do_hex ;
@@ -2687,9 +2684,10 @@ do_addsub(
26872684
26882685 curwin -> w_cursor = * pos ;
26892686 ptr = ml_get (pos -> lnum );
2687+ linelen = ml_get_len (pos -> lnum );
26902688 col = pos -> col ;
26912689
2692- if (* ptr == NUL || col + !!save_coladd >= ( int ) STRLEN ( ptr ) )
2690+ if (col + !!save_coladd >= linelen )
26932691 goto theend ;
26942692
26952693 /*
@@ -2869,8 +2867,7 @@ do_addsub(
28692867 // get the number value (unsigned)
28702868 if (visual && VIsual_mode != 'V' )
28712869 maxlen = (curbuf -> b_visual .vi_curswant == MAXCOL
2872- ? (int )STRLEN (ptr ) - col
2873- : length );
2870+ ? linelen - col : length );
28742871
28752872 int overflow = FALSE;
28762873 vim_str2nr (ptr + col , & pre , & length ,
0 commit comments