diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-28 21:49:51 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-02-28 21:49:51 +0100 |
commit | 4e141c66b9104136ddcf9cc240d2fbc83d825a5a (patch) | |
tree | 3d1d9fcb2de233207301b5b045a299bb6fa151b6 /src/normal.c | |
parent | b1289f19efb75a3234c8f22bdd303a6ebe56f78c (diff) |
patch 9.1.0141: Put in Visual mode wrong if it replaces fold markerv9.1.0141
Problem: Put in Visual mode wrong if it replaces fold marker.
Solution: Temporarily disable folding during put in Visual mode.
(zeertzjq)
fixes: #14097
closes: #14100
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/normal.c b/src/normal.c index 015a250781..791b02f1cd 100644 --- a/src/normal.c +++ b/src/normal.c @@ -7323,6 +7323,9 @@ nv_put_opt(cmdarg_T *cap, int fix_indent) int dir; int flags = 0; int keep_registers = FALSE; +#ifdef FEAT_FOLDING + int save_fen = curwin->w_p_fen; +#endif if (cap->oap->op_type != OP_NOP) { @@ -7388,6 +7391,12 @@ nv_put_opt(cmdarg_T *cap, int fix_indent) reg1 = get_register(regname, TRUE); } +#ifdef FEAT_FOLDING + // Temporarily disable folding, as deleting a fold marker may cause + // the cursor to be included in a fold. + curwin->w_p_fen = FALSE; +#endif + // Now delete the selected text. Avoid messages here. cap->cmdchar = 'd'; cap->nchar = NUL; @@ -7435,10 +7444,14 @@ nv_put_opt(cmdarg_T *cap, int fix_indent) if (reg2 != NULL) put_register(regname, reg2); - // 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) { +#ifdef FEAT_FOLDING + if (save_fen) + curwin->w_p_fen = TRUE; +#endif + // 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 |