diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-29 06:48:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 06:48:29 +0800 |
commit | e592657df8f727a3ce3b254fc72c027e36e08739 (patch) | |
tree | 1dceff7e494e8478c1d4a3bc5b6ac35c5d73febd /src | |
parent | f912030d4ed0998b3de90bad9f1b416fffff49c9 (diff) | |
download | rneovim-e592657df8f727a3ce3b254fc72c027e36e08739.tar.gz rneovim-e592657df8f727a3ce3b254fc72c027e36e08739.tar.bz2 rneovim-e592657df8f727a3ce3b254fc72c027e36e08739.zip |
vim-patch:9.1.0141: Put in Visual mode wrong if it replaces fold marker (#27661)
Problem: Put in Visual mode wrong if it replaces fold marker.
Solution: Temporarily disable folding during put in Visual mode.
(zeertzjq)
fixes: vim/vim#14097
closes: vim/vim#14100
https://github.com/vim/vim/commit/4e141c66b9104136ddcf9cc240d2fbc83d825a5a
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/normal.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d69e43e6b3..8ff47097fa 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6446,6 +6446,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) bool was_visual = false; int dir; int flags = 0; + const int save_fen = curwin->w_p_fen; if (cap->oap->op_type != OP_NOP) { // "dp" is ":diffput" @@ -6496,6 +6497,10 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) savereg = copy_register(regname); } + // Temporarily disable folding, as deleting a fold marker may cause + // the cursor to be included in a fold. + curwin->w_p_fen = false; + // To place the cursor correctly after a blockwise put, and to leave the // text in the correct position when putting over a selection with // 'virtualedit' and past the end of the line, we use the 'c' operator in @@ -6546,9 +6551,12 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) xfree(savereg); } - // What to reselect with "gv"? Selecting the just put text seems to - // be the most useful, since the original text was removed. if (was_visual) { + if (save_fen) { + curwin->w_p_fen = true; + } + // What to reselect with "gv"? Selecting the just put text seems to + // be the most useful, since the original text was removed. curbuf->b_visual.vi_start = curbuf->b_op_start; curbuf->b_visual.vi_end = curbuf->b_op_end; // need to adjust cursor position |