From 543e0256c19f397921a332e06b423215fd9aecb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Nov 2023 15:51:05 +0800 Subject: build: don't define FUNC_ATTR_* as empty in headers (#26317) FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header. --- src/nvim/normal.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1f789dc153..8083bb00f5 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -34,7 +34,6 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" -- cgit From 7f6b775b45de5011ff1c44e63e57551566d80704 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 16 Dec 2023 22:14:28 +0100 Subject: refactor: use `bool` to represent boolean values --- src/nvim/normal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8083bb00f5..d9988cb94b 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4721,7 +4721,7 @@ static void nv_vreplace(cmdarg_T *cap) /// Swap case for "~" command, when it does not work like an operator. static void n_swapchar(cmdarg_T *cap) { - int did_change = 0; + bool did_change = false; if (checkclearopq(cap->oap)) { return; -- cgit From 0c120307ca1ab613e63865c634d7e10ad67fb0ba Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 20 Dec 2023 14:32:22 +0100 Subject: refactor: eliminate cyclic includes --- src/nvim/normal.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d9988cb94b..dbcec0721f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -70,6 +70,7 @@ #include "nvim/tag.h" #include "nvim/textformat.h" #include "nvim/textobject.h" +#include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim_defs.h" -- cgit From 8533adb4844b771b84dac2141fa2fa60e0487b47 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Dec 2023 16:50:05 +0800 Subject: refactor(IWYU): move decor provider types to decoration_defs.h (#26692) --- src/nvim/normal.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index dbcec0721f..3937533d36 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -18,7 +18,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdhist.h" -- cgit From c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 28 Dec 2023 13:42:24 +0100 Subject: refactor: follow style guide --- src/nvim/normal.c | 82 +++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3937533d36..88ebcbe690 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -702,7 +702,7 @@ static void normal_get_additional_char(NormalState *s) int *cp; bool repl = false; // get character for replace mode bool lit = false; // get extra character literally - int lang; // getting a text character + bool lang; // getting a text character no_mapping++; allow_keys++; // no mapping for nchar, but allow key codes @@ -1027,7 +1027,7 @@ normal_end: restart_VIsual_select = 0; } if (restart_edit != 0 && !VIsual_active && s->old_mapped_len == 0) { - (void)edit(restart_edit, false, 1); + edit(restart_edit, false, 1); } } @@ -1256,7 +1256,7 @@ static void normal_check_interrupt(NormalState *s) } else if (!global_busy || !exmode_active) { if (!quit_more) { // flush all buffers - (void)vgetc(); + vgetc(); } got_int = false; } @@ -1847,7 +1847,7 @@ void clear_showcmd(void) } if (VIsual_active && !char_avail()) { - int cursor_bot = lt(VIsual, curwin->w_cursor); + bool cursor_bot = lt(VIsual, curwin->w_cursor); int lines; colnr_T leftcol, rightcol; linenr_T top, bot; @@ -1861,8 +1861,8 @@ void clear_showcmd(void) bot = VIsual.lnum; } // Include closed folds as a whole. - (void)hasFolding(top, &top, NULL); - (void)hasFolding(bot, NULL, &bot); + hasFolding(top, &top, NULL); + hasFolding(bot, NULL, &bot); lines = bot - top + 1; if (VIsual_mode == Ctrl_V) { @@ -2185,7 +2185,7 @@ void check_scrollbind(linenr_T topline_diff, int leftcol_diff) // do the horizontal scroll if (want_hor) { - (void)set_leftcol(tgt_leftcol); + set_leftcol(tgt_leftcol); } } @@ -2256,7 +2256,7 @@ static void nv_page(cmdarg_T *cap) goto_tabpage(cap->count0); } } else { - (void)onepage(cap->arg, cap->count1); + onepage(cap->arg, cap->count1); } } @@ -2606,7 +2606,7 @@ void nv_scroll_line(cmdarg_T *cap) } /// Scroll "count" lines up or down, and redraw. -void scroll_redraw(int up, linenr_T count) +void scroll_redraw(bool up, linenr_T count) { linenr_T prev_topline = curwin->w_topline; int prev_skipcol = curwin->w_skipcol; @@ -2677,7 +2677,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) LANGMAP_ADJUST(nchar, true); no_mapping--; allow_keys--; - (void)add_to_showcmd(nchar); + add_to_showcmd(nchar); if (nchar == K_DEL || nchar == K_KDEL) { n /= 10; @@ -2722,7 +2722,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar) LANGMAP_ADJUST(nchar, true); no_mapping--; allow_keys--; - (void)add_to_showcmd(nchar); + add_to_showcmd(nchar); if (vim_strchr("gGwW", nchar) == NULL) { clearopbeep(cap->oap); @@ -2872,8 +2872,8 @@ static void nv_zet(cmdarg_T *cap) case 'h': case K_LEFT: if (!curwin->w_p_wrap) { - (void)set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol - ? 0 : curwin->w_leftcol - (colnr_T)cap->count1); + set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol + ? 0 : curwin->w_leftcol - (colnr_T)cap->count1); } break; @@ -2886,7 +2886,7 @@ static void nv_zet(cmdarg_T *cap) case 'l': case K_RIGHT: if (!curwin->w_p_wrap) { - (void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1); + set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1); } break; @@ -3288,8 +3288,8 @@ static void nv_ctrlo(cmdarg_T *cap) static void nv_hat(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) { - (void)buflist_getfile(cap->count0, 0, - GETF_SETMARK|GETF_ALT, false); + buflist_getfile(cap->count0, 0, + GETF_SETMARK|GETF_ALT, false); } } @@ -3554,7 +3554,7 @@ static void nv_ident(cmdarg_T *cap) init_history(); add_to_history(HIST_SEARCH, buf, true, NUL); - (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); + normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); } else { g_tag_at_cursor = true; do_cmdline_cmd(buf); @@ -3638,8 +3638,8 @@ static void nv_scroll(cmdarg_T *cap) // Count a fold for one screen line. for (n = cap->count1 - 1; n > 0 && curwin->w_cursor.lnum > curwin->w_topline; n--) { - (void)hasFolding(curwin->w_cursor.lnum, - &curwin->w_cursor.lnum, NULL); + hasFolding(curwin->w_cursor.lnum, + &curwin->w_cursor.lnum, NULL); if (curwin->w_cursor.lnum > curwin->w_topline) { curwin->w_cursor.lnum--; } @@ -3680,7 +3680,7 @@ static void nv_scroll(cmdarg_T *cap) // Count a fold for one screen line. lnum = curwin->w_topline; while (n-- > 0 && lnum < curwin->w_botline - 1) { - (void)hasFolding(lnum, NULL, &lnum); + hasFolding(lnum, NULL, &lnum); lnum++; } n = lnum - curwin->w_topline; @@ -3900,7 +3900,7 @@ static void nv_gotofile(cmdarg_T *cap) if (ptr != NULL) { // do autowrite if necessary if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) { - (void)autowrite(curbuf, false); + autowrite(curbuf, false); } setpcmark(); if (do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, @@ -3971,9 +3971,9 @@ static void nv_search(cmdarg_T *cap) return; } - (void)normal_search(cap, cap->cmdchar, cap->searchbuf, - (cap->arg || !equalpos(save_cursor, curwin->w_cursor)) - ? 0 : SEARCH_MARK, NULL); + normal_search(cap, cap->cmdchar, cap->searchbuf, + (cap->arg || !equalpos(save_cursor, curwin->w_cursor)) + ? 0 : SEARCH_MARK, NULL); } /// Handle "N" and "n" commands. @@ -3989,7 +3989,7 @@ static void nv_next(cmdarg_T *cap) // an offset is given and the cursor is on the last char in the buffer: // Repeat with count + 1. cap->count1 += 1; - (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); + normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); cap->count1 -= 1; } } @@ -4123,7 +4123,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) if (cap->nchar == 'm' || cap->nchar == 'M') { int c; // norm is true for "]M" and "[m" - int norm = ((findc == '{') == (cap->nchar == 'm')); + bool norm = ((findc == '{') == (cap->nchar == 'm')); n = cap->count1; // found a match: we were inside a method @@ -4289,9 +4289,9 @@ static void nv_brackets(cmdarg_T *cap) } else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) { // [ or ] followed by a middle mouse click: put selected text with // indent adjustment. Any other button just does as usual. - (void)do_mouse(cap->oap, cap->nchar, - (cap->cmdchar == ']') ? FORWARD : BACKWARD, - cap->count1, PUT_FIXINDENT); + do_mouse(cap->oap, cap->nchar, + (cap->cmdchar == ']') ? FORWARD : BACKWARD, + cap->count1, PUT_FIXINDENT); } else if (cap->nchar == 'z') { // "[z" and "]z": move to start or end of open fold. if (foldMoveTo(false, cap->cmdchar == ']' ? FORWARD : BACKWARD, @@ -4556,7 +4556,7 @@ static void nv_replace(cmdarg_T *cap) // Insert the newline with an insert command, takes care of // autoindent. The insert command depends on being on the last // character of a line or not. - (void)del_chars(cap->count1, false); // delete the characters + del_chars(cap->count1, false); // delete the characters stuffcharReadbuff('\r'); stuffcharReadbuff(ESC); @@ -5312,7 +5312,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) } else { if (cap->count1 > 1) { // if it fails, let the cursor still move to the last char - (void)cursor_down(cap->count1 - 1, false); + cursor_down(cap->count1 - 1, false); } i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1; coladvance((colnr_T)i); @@ -5626,7 +5626,7 @@ static void nv_g_cmd(cmdarg_T *cap) case K_X2DRAG: case K_X2RELEASE: mod_mask = MOD_MASK_CTRL; - (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); + do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); break; case K_IGNORE: @@ -5699,12 +5699,12 @@ static void n_opencmd(cmdarg_T *cap) if (cap->cmdchar == 'O') { // Open above the first line of a folded sequence of lines - (void)hasFolding(curwin->w_cursor.lnum, - &curwin->w_cursor.lnum, NULL); + hasFolding(curwin->w_cursor.lnum, + &curwin->w_cursor.lnum, NULL); } else { // Open below the last line of a folded sequence of lines - (void)hasFolding(curwin->w_cursor.lnum, - NULL, &curwin->w_cursor.lnum); + hasFolding(curwin->w_cursor.lnum, + NULL, &curwin->w_cursor.lnum); } // trigger TextChangedI for the 'o/O' command curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf); @@ -6108,10 +6108,10 @@ static void nv_normal(cmdarg_T *cap) /// Don't even beep if we are canceling a command. static void nv_esc(cmdarg_T *cap) { - int no_reason = (cap->oap->op_type == OP_NOP - && cap->opcount == 0 - && cap->count0 == 0 - && cap->oap->regname == 0); + bool no_reason = (cap->oap->op_type == OP_NOP + && cap->opcount == 0 + && cap->count0 == 0 + && cap->oap->regname == 0); if (cap->arg) { // true for CTRL-C if (restart_edit == 0 && cmdwin_type == 0 && !VIsual_active && no_reason) { @@ -6618,6 +6618,6 @@ void normal_cmd(oparg_T *oap, bool toplevel) s.toplevel = toplevel; s.oa = *oap; normal_prepare(&s); - (void)normal_execute(&s.state, safe_vgetc()); + normal_execute(&s.state, safe_vgetc()); *oap = s.oa; } -- cgit From 735aa4c4c89943b26f1d6ba0d3e076002490c09d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 31 Dec 2023 01:54:34 +0100 Subject: refactor: remove redundant struct names A struct can be anonymous if only its typedef is used. --- src/nvim/normal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 88ebcbe690..42ae7519c1 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -75,7 +75,7 @@ #include "nvim/vim_defs.h" #include "nvim/window.h" -typedef struct normal_state { +typedef struct { VimState state; bool command_finished; bool ctrl_w; -- cgit From 1813661a6197c76ea6621284570aca1d56597099 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 4 Jan 2024 15:38:16 +0100 Subject: refactor(IWYU): fix headers Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want. --- src/nvim/normal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 42ae7519c1..ed2b1437ec 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -17,7 +17,9 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" +#include "nvim/buffer_defs.h" #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdhist.h" @@ -34,17 +36,20 @@ #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/getchar.h" -#include "nvim/gettext.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/help.h" #include "nvim/highlight.h" +#include "nvim/highlight_defs.h" #include "nvim/keycodes.h" #include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" +#include "nvim/mark_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" +#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/mouse.h" @@ -60,9 +65,11 @@ #include "nvim/quickfix.h" #include "nvim/search.h" #include "nvim/spell.h" +#include "nvim/spell_defs.h" #include "nvim/spellfile.h" #include "nvim/spellsuggest.h" #include "nvim/state.h" +#include "nvim/state_defs.h" #include "nvim/statusline.h" #include "nvim/strings.h" #include "nvim/syntax.h" @@ -71,6 +78,7 @@ #include "nvim/textobject.h" #include "nvim/types_defs.h" #include "nvim/ui.h" +#include "nvim/ui_defs.h" #include "nvim/undo.h" #include "nvim/vim_defs.h" #include "nvim/window.h" -- cgit From ba7a52dedc5dd335f22522ec17a0393e068187e3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 29 Jan 2024 07:27:15 +0800 Subject: vim-patch:9.1.0060: Recorded register cannot be translated using keytrans() (#27247) Problem: Recorded register cannot be translated using keytrans() when it involves character search (iddqd505) Solution: Record a K_IGNORE instead of a K_NOP (zeertzjq) related: vim/vim#13916 closes: vim/vim#13925 https://github.com/vim/vim/commit/bf321806bf44d59f108fd7e5a0eaead04682701d --- src/nvim/normal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ed2b1437ec..8c388b4318 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -845,10 +845,10 @@ static void normal_get_additional_char(NormalState *s) no_mapping++; // Vim may be in a different mode when the user types the next key, // but when replaying a recording the next key is already in the - // typeahead buffer, so record a before that to prevent the - // vpeekc() above from applying wrong mappings when replaying. + // typeahead buffer, so record an before that to prevent + // the vpeekc() above from applying wrong mappings when replaying. no_u_sync++; - gotchars_nop(); + gotchars_ignore(); no_u_sync--; } } -- cgit From 18e62c1bdbbb6b93bfb74d974bc511fc4c03748e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Feb 2024 11:08:52 +0800 Subject: perf(redraw): only redraw Visual area when cursor has moved (#27340) --- src/nvim/normal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8c388b4318..9966e6129c 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1347,10 +1347,6 @@ static void normal_redraw(NormalState *s) show_cursor_info_later(false); - if (VIsual_active) { - redraw_curbuf_later(UPD_INVERTED); // update inverted part - } - if (must_redraw) { update_screen(); } else { @@ -5129,6 +5125,7 @@ static void n_start_visual_mode(int c) curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; curwin->w_old_visual_lnum = curwin->w_cursor.lnum; } + redraw_curbuf_later(UPD_VALID); } /// CTRL-W: Window commands -- cgit From 8e739af064dec28886694aa448f60a570acd2173 Mon Sep 17 00:00:00 2001 From: Pablo Arias Date: Fri, 9 Feb 2024 23:56:52 +0100 Subject: fix(startup): multiprocess startuptime #26790 Problem: Since 24488169564c39a506c235bf6a33b8e23a8cb528, the --startuptime report shows two blocks of data. The TUI process and its embedded nvim process write to the file concurrently, which may interleave the two startup sequences into the same timeline. Solution: Report each process as a separate section in the same file. 1. Each process buffers the full report. 2. After startup is finished, the buffer is flushed (appended) to the file. Fix #23036 Sample report: --- Startup times for process: Primary/TUI --- times in msec clock self+sourced self: sourced script clock elapsed: other lines 000.006 000.006: --- NVIM STARTING --- 000.428 000.422: event init 000.728 000.301: early init ... 005.880 000.713: init highlight 005.882 000.002: --- NVIM STARTED --- --- Startup times for process: Embedded --- times in msec clock self+sourced self: sourced script clock elapsed: other lines 000.006 000.006: --- NVIM STARTING --- 000.409 000.403: event init 000.557 000.148: early init 000.633 000.077: locale set ... 014.383 000.430: first screen update 014.387 000.003: --- NVIM STARTED --- --- src/nvim/normal.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9966e6129c..8b6ef62873 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1451,9 +1451,7 @@ static int normal_check(VimState *state) // has been done, close any file for startup messages. if (time_fd != NULL) { TIME_MSG("first screen update"); - TIME_MSG("--- NVIM STARTED ---"); - fclose(time_fd); - time_fd = NULL; + time_finish(); } // After the first screen update may start triggering WinScrolled // autocmd events. Store all the scroll positions and sizes now. -- cgit From 00e785b17fde8c476031e3c24ea77bed45b88a89 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 10 Feb 2024 21:38:48 +0800 Subject: refactor: don't use subtraction in qsort() comparison functions --- src/nvim/normal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8b6ef62873..d69e43e6b3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -375,7 +375,7 @@ static int nv_compare(const void *s1, const void *s2) if (c2 < 0) { c2 = -c2; } - return c1 - c2; + return c1 == c2 ? 0 : c1 > c2 ? 1 : -1; } /// Initialize the nv_cmd_idx[] table. -- cgit From e592657df8f727a3ce3b254fc72c027e36e08739 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Feb 2024 06:48:29 +0800 Subject: 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 --- src/nvim/normal.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') 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 -- cgit