1
0
forked from aniani/vim

updated for version 7.0226

This commit is contained in:
Bram Moolenaar 2006-03-16 21:43:34 +00:00
parent efd2bf158a
commit 2eb25daffd
3 changed files with 25 additions and 20 deletions

View File

@ -6044,7 +6044,7 @@ beginline(flags)
* oneright oneleft cursor_down cursor_up * oneright oneleft cursor_down cursor_up
* *
* Move one char {right,left,down,up}. * Move one char {right,left,down,up}.
* Doesn't move onto the NUL past the end of the line. * Doesn't move onto the NUL past the end of the line, unless it is allowed.
* Return OK when successful, FAIL when we hit a line of file boundary. * Return OK when successful, FAIL when we hit a line of file boundary.
*/ */
@ -6052,9 +6052,7 @@ beginline(flags)
oneright() oneright()
{ {
char_u *ptr; char_u *ptr;
#ifdef FEAT_MBYTE
int l; int l;
#endif
#ifdef FEAT_VIRTUALEDIT #ifdef FEAT_VIRTUALEDIT
if (virtual_active()) if (virtual_active())
@ -6064,11 +6062,11 @@ oneright()
/* Adjust for multi-wide char (excluding TAB) */ /* Adjust for multi-wide char (excluding TAB) */
ptr = ml_get_cursor(); ptr = ml_get_cursor();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc( coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(
#ifdef FEAT_MBYTE # ifdef FEAT_MBYTE
(*mb_ptr2char)(ptr) (*mb_ptr2char)(ptr)
#else # else
*ptr *ptr
#endif # endif
)) ))
? ptr2cells(ptr) : 1)); ? ptr2cells(ptr) : 1));
curwin->w_set_curswant = TRUE; curwin->w_set_curswant = TRUE;
@ -6079,22 +6077,25 @@ oneright()
#endif #endif
ptr = ml_get_cursor(); ptr = ml_get_cursor();
if (*ptr == NUL)
return FAIL; /* already at the very end */
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (has_mbyte && (l = (*mb_ptr2len)(ptr)) > 1) if (has_mbyte)
{ l = (*mb_ptr2len)(ptr);
/* The character under the cursor is a multi-byte character, move
* several bytes right, but don't end up on the NUL. */
if (ptr[l] == NUL)
return FAIL;
curwin->w_cursor.col += l;
}
else else
#endif #endif
{ l = 1;
if (*ptr++ == NUL || *ptr == NUL)
/* move "l" bytes right, but don't end up on the NUL, unless 'virtualedit'
* contains "onemore". */
if (ptr[l] == NUL
#ifdef FEAT_VIRTUALEDIT
&& (ve_flags & VE_ONEMORE) == 0
#endif
)
return FAIL; return FAIL;
++curwin->w_cursor.col; curwin->w_cursor.col += l;
}
curwin->w_set_curswant = TRUE; curwin->w_set_curswant = TRUE;
return OK; return OK;

View File

@ -3733,6 +3733,9 @@ end:
/* If the cursor is past the end of the line put it at the end. */ /* If the cursor is past the end of the line put it at the end. */
if (gchar_cursor() == NUL if (gchar_cursor() == NUL
&& curwin->w_cursor.col > 0 && curwin->w_cursor.col > 0
#ifdef FEAT_VIRTUALEDIT
&& (ve_flags & VE_ONEMORE) == 0
#endif
&& !(restart_edit || (State & INSERT))) && !(restart_edit || (State & INSERT)))
{ {
/* Put the cursor on the last character in the line. */ /* Put the cursor on the last character in the line. */

View File

@ -813,11 +813,12 @@ EXTERN int p_vb; /* 'visualbell' */
EXTERN char_u *p_ve; /* 'virtualedit' */ EXTERN char_u *p_ve; /* 'virtualedit' */
EXTERN unsigned ve_flags; EXTERN unsigned ve_flags;
# ifdef IN_OPTION_C # ifdef IN_OPTION_C
static char *(p_ve_values[]) = {"block", "insert", "all", NULL}; static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", NULL};
# endif # endif
# define VE_BLOCK 5 /* includes "all" */ # define VE_BLOCK 5 /* includes "all" */
# define VE_INSERT 6 /* includes "all" */ # define VE_INSERT 6 /* includes "all" */
# define VE_ALL 4 # define VE_ALL 4
# define VE_ONEMORE 8
#endif #endif
EXTERN long p_verbose; /* 'verbose' */ EXTERN long p_verbose; /* 'verbose' */
EXTERN char_u *p_vfile; /* 'verbosefile' */ EXTERN char_u *p_vfile; /* 'verbosefile' */