Yukihiro Nakadaira wrote:
> I defined InsertEnter autocommand
>
> :autocmd InsertEnter * call setline(1, strftime("%c"))
>
> and started Insert mode at end of line with "a" or "A". I expected
>
> 1 Tue Mar 27 20:00:00 2007
> 2 abc|
> (| is cursor)
>
> But cursor was moved before last character.
>
> 1 Tue Mar 27 20:00:00 2007
> 2 ab|c
>
> If "c" is multi-byte character, cursor is displayed at end of line.
>
> 1 Tue Mar 27 20:00:00 2007
> 2 abc|
>
> But it is actually placed in middle of multi-byte character. Then
> typing key breaks that character.
>
> 1 Tue Mar 27 20:00:00 2007
> 2 ab<first-byte><second-byte>X|<last-byte>
This should help:
*** eval.c~ Tue Mar 27 16:47:56 2007
--- eval.c Tue Mar 27 21:55:26 2007
***************
*** 14397,14403 ****
if (u_savesub(lnum) == OK && ml_replace(lnum, line, TRUE) == OK)
{
changed_bytes(lnum, 0);
! check_cursor_col();
rettv->vval.v_number = 0; /* OK */
}
}
--- 14397,14404 ----
if (u_savesub(lnum) == OK && ml_replace(lnum, line, TRUE) == OK)
{
changed_bytes(lnum, 0);
! if (lnum == curwin->w_cursor.lnum)
! check_cursor_col();
rettv->vval.v_number = 0; /* OK */
}
}
There can still be a problem when appending to line 1 and it ends in a
multi-byte character. Then this patch should help:
*** misc2.c~ Wed Feb 7 05:00:13 2007
--- misc2.c Tue Mar 27 21:59:56 2007
***************
*** 516,522 ****
--- 516,529 ----
|| virtual_active())
curwin->w_cursor.col = len;
else
+ {
curwin->w_cursor.col = len - 1;
+ #ifdef FEAT_MBYTE
+ /* prevent cursor from moving on the trail byte */
+ if (has_mbyte)
+ mb_adjust_cursor();
+ #endif
+ }
}
#ifdef FEAT_VIRTUALEDIT
--
SIGIRO -- irony detected (iron core dumped)
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///