Mercurial > vim
diff src/misc2.c @ 25380:ac88cd21ae88 v8.2.3227
patch 8.2.3227: 'virtualedit' can only be set globally
Commit: https://github.com/vim/vim/commit/53ba05b09075f14227f9be831a22ed16f7cc26b2
Author: Gary Johnson <garyjohn@spocom.com>
Date: Mon Jul 26 22:19:10 2021 +0200
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 https://github.com/vim/vim/issues/8638)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Jul 2021 22:30:05 +0200 |
parents | dc66d0284518 |
children | b80e4e9c4988 |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -22,14 +22,16 @@ static int coladvance2(pos_T *pos, int a 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 @@ coladvance2( 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 @@ check_cursor_col(void) 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 @@ check_cursor_col_win(win_T *win) // - '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 @@ check_cursor_col_win(win_T *win) // 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) {