diff options
author | Gary Johnson <garyjohn@spocom.com> | 2021-07-26 22:19:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-26 22:19:10 +0200 |
commit | 53ba05b09075f14227f9be831a22ed16f7cc26b2 (patch) | |
tree | 75d5ddb38aa9702416d73b7a7b8f158f1d0c320a /src/ops.c | |
parent | 29b857150c111a455f1a38a8f748243524f692e1 (diff) | |
download | vim-git-53ba05b09075f14227f9be831a22ed16f7cc26b2.tar.gz |
patch 8.2.3227: 'virtualedit' can only be set globallyv8.2.3227
Problem: 'virtualedit' can only be set globally.
Solution: Make 'virtualedit' global-local. (Gary Johnson, closes #8638)
Diffstat (limited to 'src/ops.c')
-rw-r--r-- | src/ops.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1474,18 +1474,22 @@ op_insert(oparg_T *oap, long count1) // doing block_prep(). When only "block" is used, virtual edit is // already disabled, but still need it when calling // coladvance_force(). + // coladvance_force() uses get_ve_flags() to get the 'virtualedit' + // state for the current buffer. To override that state, we need to + // set the buffer-local value of ve_flags rather than the global value. if (curwin->w_cursor.coladd > 0) { - int old_ve_flags = ve_flags; + int old_ve_flags = curbuf->b_ve_flags; - ve_flags = VE_ALL; if (u_save_cursor() == FAIL) return; + + curbuf->b_ve_flags = VE_ALL; coladvance_force(oap->op_type == OP_APPEND ? oap->end_vcol + 1 : getviscol()); if (oap->op_type == OP_APPEND) --curwin->w_cursor.col; - ve_flags = old_ve_flags; + curbuf->b_ve_flags = old_ve_flags; } // Get the info about the block before entering the text block_prep(oap, &bd, oap->start.lnum, TRUE); @@ -1816,15 +1820,17 @@ op_change(oparg_T *oap) void adjust_cursor_eol(void) { + unsigned int cur_ve_flags = get_ve_flags(); + if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL - && (ve_flags & VE_ONEMORE) == 0 + && (cur_ve_flags & VE_ONEMORE) == 0 && !(restart_edit || (State & INSERT))) { // Put the cursor on the last character in the line. dec_cursor(); - if (ve_flags == VE_ALL) + if (cur_ve_flags == VE_ALL) { colnr_T scol, ecol; |