|| ((ve_flags & VE_ONEMORE) && wcol < MAXCOL)
#endif
;
- line = ml_get_curline();
+ line = ml_get_buf(curbuf, pos->lnum, FALSE);
if (wcol >= MAXCOL)
{
#endif
#ifdef FEAT_MBYTE
- /* prevent cursor from moving on the trail byte */
+ /* prevent from moving onto a trail byte */
if (has_mbyte)
- mb_adjust_cursor();
+ mb_adjustpos(pos);
#endif
if (col < wcol)
bd.is_MAX = (curwin->w_curswant == MAXCOL);
for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum)
{
+ curwin->w_cursor.col = 0; /* make sure cursor position is valid */
block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE);
if (bd.textlen == 0 && (!virtual_op || bd.is_MAX))
continue; /* nothing to replace */
{
pos_T vpos;
+ vpos.lnum = curwin->w_cursor.lnum;
getvpos(&vpos, oap->start_vcol);
bd.startspaces += vpos.coladd;
n = bd.startspaces;
* initial coladd offset as part of "startspaces" */
if (bd.is_short)
{
- linenr_T lnum = curwin->w_cursor.lnum;
-
- curwin->w_cursor.lnum = linenr;
+ vpos.lnum = linenr;
(void)getvpos(&vpos, oap->start_vcol);
- curwin->w_cursor.lnum = lnum;
}
else
vpos.coladd = 0;