patch 8.2.3227: 'virtualedit' can only be set globally
Problem: 'virtualedit' can only be set globally.
Solution: Make 'virtualedit' global-local. (Gary Johnson, closes #8638)
diff --git a/src/misc2.c b/src/misc2.c
index a8e34df..8e99b01 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -22,14 +22,16 @@
int
virtual_active(void)
{
+ unsigned int cur_ve_flags = get_ve_flags();
+
// While an operator is being executed we return "virtual_op", because
// VIsual_active has already been reset, thus we can't check for "block"
// being used.
if (virtual_op != MAYBE)
return virtual_op;
- return (ve_flags == VE_ALL
- || ((ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V)
- || ((ve_flags & VE_INSERT) && (State & INSERT)));
+ return (cur_ve_flags == VE_ALL
+ || ((cur_ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V)
+ || ((cur_ve_flags & VE_INSERT) && (State & INSERT)));
}
/*
@@ -137,7 +139,7 @@
one_more = (State & INSERT)
|| restart_edit != NUL
|| (VIsual_active && *p_sel != 'o')
- || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL);
+ || ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL);
line = ml_get_buf(curbuf, pos->lnum, FALSE);
if (wcol >= MAXCOL)
@@ -549,9 +551,10 @@
void
check_cursor_col_win(win_T *win)
{
- colnr_T len;
- colnr_T oldcol = win->w_cursor.col;
- colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
+ colnr_T len;
+ colnr_T oldcol = win->w_cursor.col;
+ colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
+ unsigned int cur_ve_flags = get_ve_flags();
len = (colnr_T)STRLEN(ml_get_buf(win->w_buffer, win->w_cursor.lnum, FALSE));
if (len == 0)
@@ -564,7 +567,7 @@
// - 'virtualedit' is set
if ((State & INSERT) || restart_edit
|| (VIsual_active && *p_sel != 'o')
- || (ve_flags & VE_ONEMORE)
+ || (cur_ve_flags & VE_ONEMORE)
|| virtual_active())
win->w_cursor.col = len;
else
@@ -583,7 +586,7 @@
// line.
if (oldcol == MAXCOL)
win->w_cursor.coladd = 0;
- else if (ve_flags == VE_ALL)
+ else if (cur_ve_flags == VE_ALL)
{
if (oldcoladd > win->w_cursor.col)
{