From fa35d3c33a74123a3a3374566652161d3ad6ee5c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 2 Feb 2023 08:05:15 +0800 Subject: vim-patch:9.0.1273: "1v" may select block with wrong size (#22092) Problem: "1v" may select block with wrong size. (Evgeni Chasnovski) Solution: Compute "curswant" in the right line. (closes vim/vim#11925) https://github.com/vim/vim/commit/8f531662e28c37560bf5ac20a059bf00d01ee5a4 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 58a18ca5a8..b88cfb8926 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5072,9 +5072,13 @@ static void nv_visual(cmdarg_T *cap) curwin->w_curswant = MAXCOL; coladvance(MAXCOL); } else if (VIsual_mode == Ctrl_V) { + // Update curswant on the original line, that is where "col" is valid. + linenr_T lnum = curwin->w_cursor.lnum; + curwin->w_cursor.lnum = VIsual.lnum; update_curswant_force(); assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX); curwin->w_curswant += resel_VIsual_vcol * (int)cap->count0 - 1; + curwin->w_cursor.lnum = lnum; coladvance(curwin->w_curswant); } else { curwin->w_set_curswant = true; -- cgit From 27177e581902967dcf4f2f426464da1b636ca420 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:14:24 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22211) --- src/nvim/normal.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b88cfb8926..a84d5c73a4 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -401,10 +401,8 @@ void init_normal_cmds(void) /// @return -1 for invalid command. static int find_command(int cmdchar) { - int i; int idx; int top, bot; - int c; // A multi-byte character is never a command. if (cmdchar >= 0x100) { @@ -429,8 +427,8 @@ static int find_command(int cmdchar) top = NV_CMDS_SIZE - 1; idx = -1; while (bot <= top) { - i = (top + bot) / 2; - c = nv_cmds[nv_cmd_idx[i]].cmd_char; + int i = (top + bot) / 2; + int c = nv_cmds[nv_cmd_idx[i]].cmd_char; if (c < 0) { c = -c; } @@ -693,7 +691,6 @@ 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 - bool langmap_active = false; // using :lmap mappings int lang; // getting a text character no_mapping++; @@ -729,6 +726,7 @@ static void normal_get_additional_char(NormalState *s) // Get a second or third character. if (cp != NULL) { + bool langmap_active = false; // using :lmap mappings if (repl) { State = MODE_REPLACE; // pretend Replace mode ui_cursor_shape(); // show different cursor shape @@ -1848,7 +1846,6 @@ void clear_showcmd(void) snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines); } else { char *s, *e; - int l; int bytes = 0; int chars = 0; @@ -1860,7 +1857,7 @@ void clear_showcmd(void) e = ml_get_pos(&VIsual); } while ((*p_sel != 'e') ? s <= e : s < e) { - l = utfc_ptr2len(s); + int l = utfc_ptr2len(s); if (l == 0) { bytes++; chars++; @@ -2427,7 +2424,6 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) int linelen = linetabsize(get_cursor_line_ptr()); bool retval = true; bool atend = false; - int n; int col_off1; // margin offset for first screen line int col_off2; // margin offset for wrapped screen line int width1; // text width for first screen line @@ -2446,6 +2442,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) } if (curwin->w_width_inner != 0) { + int n; // Instead of sticking at the last character of the buffer line we // try to stick in the last column of the screen. if (curwin->w_curswant == MAXCOL) { @@ -2793,7 +2790,6 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar) /// Commands that start with "z". static void nv_zet(cmdarg_T *cap) { - int n; colnr_T col; int nchar = cap->nchar; long old_fdl = curwin->w_p_fdl; @@ -2949,7 +2945,7 @@ static void nv_zet(cmdarg_T *cap) } else { getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); } - n = curwin->w_width_inner - curwin_col_off(); + int n = curwin->w_width_inner - curwin_col_off(); if (col + siso < n) { col = 0; } else { @@ -3438,7 +3434,6 @@ static void nv_ident(cmdarg_T *cap) int cmdchar; bool g_cmd; // "g" command bool tag_cmd = false; - char *aux_ptr; if (cap->cmdchar == 'g') { // "g*", "g#", "g]" and "gCTRL-]" cmdchar = cap->nchar; @@ -3542,6 +3537,7 @@ static void nv_ident(cmdarg_T *cap) STRCAT(buf, p); xfree(p); } else { + char *aux_ptr; if (cmdchar == '*') { aux_ptr = (magic_isset() ? "/.*~[^$\\" : "/^$\\"); } else if (cmdchar == '#') { @@ -3653,10 +3649,8 @@ static void nv_tagpop(cmdarg_T *cap) /// Handle scrolling command 'H', 'L' and 'M'. static void nv_scroll(cmdarg_T *cap) { - int used = 0; long n; linenr_T lnum; - int half; cap->oap->motion_type = kMTLineWise; setpcmark(); @@ -3683,11 +3677,12 @@ static void nv_scroll(cmdarg_T *cap) } } else { if (cap->cmdchar == 'M') { + int used = 0; // Don't count filler lines above the window. used -= win_get_fill(curwin, curwin->w_topline) - curwin->w_topfill; validate_botline(curwin); // make sure w_empty_rows is valid - half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2; + int half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2; for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) { // Count half the number of filler lines to be "below this // line" and half to be "above the next line". @@ -4115,7 +4110,6 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) pos_T prev_pos; long n; int findc; - int c; if (cap->nchar == '*') { cap->nchar = '/'; @@ -4155,6 +4149,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) // Try finding the '{' or '}' we want to be at. // Also repeat for the given count. if (cap->nchar == 'm' || cap->nchar == 'M') { + int c; // norm is true for "]M" and "[m" int norm = ((findc == '{') == (cap->nchar == 'm')); @@ -4361,7 +4356,6 @@ static void nv_brackets(cmdarg_T *cap) /// Handle Normal mode "%" command. static void nv_percent(cmdarg_T *cap) { - pos_T *pos; linenr_T lnum = curwin->w_cursor.lnum; cap->oap->inclusive = true; @@ -4391,6 +4385,7 @@ static void nv_percent(cmdarg_T *cap) beginline(BL_SOL | BL_FIX); } } else { // "%" : go to matching paren + pos_T *pos; cap->oap->motion_type = kMTCharWise; cap->oap->use_reg_one = true; if ((pos = findmatch(cap->oap, NUL)) == NULL) { @@ -6046,9 +6041,8 @@ static void adjust_for_sel(cmdarg_T *cap) /// @return true when backed up to the previous line. bool unadjust_for_sel(void) { - pos_T *pp; - if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor)) { + pos_T *pp; if (lt(VIsual, curwin->w_cursor)) { pp = &curwin->w_cursor; } else { @@ -6460,7 +6454,6 @@ static void nv_put(cmdarg_T *cap) /// @param fix_indent true for "[p", "[P", "]p" and "]P". static void nv_put_opt(cmdarg_T *cap, bool fix_indent) { - int regname = 0; yankreg_T *savereg = NULL; bool empty = false; bool was_visual = false; @@ -6506,7 +6499,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) // Need to save and restore the registers that the delete // overwrites if the old contents is being put. was_visual = true; - regname = cap->oap->regname; + int regname = cap->oap->regname; bool keep_registers = cap->cmdchar == 'P'; // '+' and '*' could be the same selection bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK); -- cgit From 968cd1ed933c039b8d60b0110bc6b539c71e387d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 07:25:16 +0800 Subject: vim-patch:9.0.1309: scrolling two lines with even line count and 'scrolloff' set Problem: Scrolling two lines with even line count and 'scrolloff' set. Solution: Adjust how the topline is computed. (closes vim/vim#10545) https://github.com/vim/vim/commit/1d6539cf36a7b6d1afe76fb6316fe662f543bf60 Cherry-pick test_scroll_opt.vim changes from patch 8.2.1432. Co-authored-by: Bram Moolenaar --- 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 a84d5c73a4..f1226584d7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2856,7 +2856,7 @@ static void nv_zet(cmdarg_T *cap) FALLTHROUGH; case 'z': - scroll_cursor_halfway(true); + scroll_cursor_halfway(true, false); redraw_later(curwin, UPD_VALID); set_fraction(curwin); break; -- cgit From cbd4480f97a913e0e356ec02f652b693b0195767 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Sun, 19 Feb 2023 01:33:02 +0100 Subject: vim-patch:9.0.1324: "gj" and "gk" do not move correctly over a closed fold (#22320) Problem: "gj" and "gk" do not move correctly over a closed fold. Solution: Use the same code as used for "j"/"k" to go to the next/previous line. (Luuk van Baal, closes vim/vim#12007) https://github.com/vim/vim/commit/441a7a94482f704b66253b8d08130f27b6b13736 --- src/nvim/normal.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f1226584d7..5677c627a7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2479,19 +2479,10 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) curwin->w_curswant -= width2; } else { // to previous line - - // Move to the start of a closed fold. Don't do that when - // 'foldopen' contains "all": it will open in a moment. - if (!(fdo_flags & FDO_ALL)) { - (void)hasFolding(curwin->w_cursor.lnum, - &curwin->w_cursor.lnum, NULL); - } - if (curwin->w_cursor.lnum == 1) { + if (!cursor_up_inner(curwin, 1)) { retval = false; break; } - curwin->w_cursor.lnum--; - linelen = linetabsize(get_cursor_line_ptr()); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; @@ -2511,15 +2502,10 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) curwin->w_curswant += width2; } else { // to next line - - // Move to the end of a closed fold. - (void)hasFolding(curwin->w_cursor.lnum, NULL, - &curwin->w_cursor.lnum); - if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) { + if (!cursor_down_inner(curwin, 1)) { retval = false; break; } - curwin->w_cursor.lnum++; curwin->w_curswant %= width2; // Check if the cursor has moved below the number display // when width1 < width2 (with cpoptions+=n). Subtract width2 -- cgit From 5e846978e3bf85ea5ae5b505af267c01e98f6135 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 08:32:20 +0800 Subject: vim-patch:9.0.1354: "gr CTRL-G" stays in virtual replace mode Problem: "gr CTRL-G" stays in virtual replace mode. (Pierre Ganty) Solution: Prepend CTRL-V before control characters. (closes vim/vim#12045) https://github.com/vim/vim/commit/d6a4ea3aa0d3f4a886ea900e94bf4e8ca8ae8d63 Cherry-pick Test_edit_gr_special() from patch 9.0.1347. Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 5677c627a7..33d04f76af 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4720,6 +4720,11 @@ static void nv_vreplace(cmdarg_T *cap) if (cap->extra_char == Ctrl_V) { // get another character cap->extra_char = get_literal(false); } + if (cap->extra_char < ' ') { + // Prefix a control character with CTRL-V to avoid it being used as + // a command. + stuffcharReadbuff(Ctrl_V); + } stuffcharReadbuff(cap->extra_char); stuffcharReadbuff(ESC); if (virtual_active()) { -- cgit From 6644742c26e4d8da999cf00754b6e6ee0ba0618f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 23:02:01 +0800 Subject: vim-patch:9.0.1356: cannot cancel "gr" with Esc Problem: Cannot cancel "gr" with Esc. Solution: Make "gr" do nothing. (closes vim/vim#12064) https://github.com/vim/vim/commit/4f026ea9f1ad9db262f0dba522768c84e5ae37b4 N/A patches for version.c: vim-patch:9.0.1347: "gr CTRL-O" stays in Insert mode Problem: "gr CTRL-O" stays in Insert mode. (Pierre Ganty) Solution: Do not set restart_edit when "cmdchar" is 'v'. (closes vim/vim#12045) https://github.com/vim/vim/commit/2824d1ee325ea61855c26f77e7a4e095b9606720 vim-patch:9.0.1349: "gr" with a count fails Problem: "gr" with a count fails. Solution: Break out of the loop only after using the count. https://github.com/vim/vim/commit/3ddb1182b7b8d376e59b444f6b3e213f0dcd3417 --- 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 33d04f76af..ef8f6e7b0f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4710,7 +4710,7 @@ static void nv_vreplace(cmdarg_T *cap) return; } - if (checkclearopq(cap->oap)) { + if (checkclearopq(cap->oap) || cap->extra_char == ESC) { return; } -- cgit From cf07f2baabd3a1a072102e0cacb6d70509ada044 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 12:29:20 +0100 Subject: feat(edit)!: remove old c implementation of hebrew keymap This feature has long been obsolete. The 'keymap' option can be used to support language keymaps, including hebrew and hebrewp (phonetic mapping). There is no need to keep the old c code with hardcoded keymaps for some languages. --- src/nvim/normal.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ef8f6e7b0f..f7c99d5991 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -769,10 +769,6 @@ static void normal_get_additional_char(NormalState *s) // adjust chars > 127, except after "tTfFr" commands LANGMAP_ADJUST(*cp, !lang); - // adjust Hebrew mapped char - if (p_hkmap && lang && KeyTyped) { - *cp = hkmap(*cp); - } } // When the next character is CTRL-\ a following CTRL-N means the -- cgit From e389b189021cb6b72cfd7583ce6fb5d8d3346d45 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 6 Mar 2023 07:52:11 +0800 Subject: vim-patch:9.0.1385: g'Esc is considered an error (#22544) Problem: g'Esc is considered an error. Solution: Make g'Esc silently abandon the command. (closes vim/vim#12110) https://github.com/vim/vim/commit/f86dea8119f3141e3d2c680219036d1511101f9b --- src/nvim/normal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f7c99d5991..890215e754 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -963,7 +963,8 @@ normal_end: may_trigger_modechanged(); // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. - if (s->c || s->ca.cmdchar == 'r') { + if (s->c || s->ca.cmdchar == 'r' + || (s->ca.cmdchar == 'g' && s->ca.nchar == 'r')) { ui_cursor_shape(); // may show different cursor shape } @@ -1162,7 +1163,7 @@ static int normal_execute(VimState *state, int key) State = MODE_NORMAL; - if (s->ca.nchar == ESC) { + if (s->ca.nchar == ESC || s->ca.extra_char == ESC) { clearop(&s->oa); s->command_finished = true; goto finish; @@ -4706,7 +4707,7 @@ static void nv_vreplace(cmdarg_T *cap) return; } - if (checkclearopq(cap->oap) || cap->extra_char == ESC) { + if (checkclearopq(cap->oap)) { return; } -- cgit From 846a056744bf458d4376cd7638c94f7c82862046 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 9 Mar 2023 11:45:20 +0100 Subject: refactor(redraw): make cursor position redraw use the "redraw later" pattern --- src/nvim/normal.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 890215e754..2a8fbbb962 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1306,16 +1306,20 @@ static void normal_redraw(NormalState *s) update_topline(curwin); validate_cursor(); + show_cursor_info_later(false); + if (VIsual_active) { redraw_curbuf_later(UPD_INVERTED); // update inverted part - update_screen(); - } else if (must_redraw) { - update_screen(); - } else if (redraw_cmdline || clear_cmdline || redraw_mode) { - showmode(); } - redraw_statuslines(); + if (must_redraw) { + update_screen(); + } else { + redraw_statuslines(); + if (redraw_cmdline || clear_cmdline || redraw_mode) { + showmode(); + } + } if (need_maketitle) { maketitle(); @@ -1348,7 +1352,6 @@ static void normal_redraw(NormalState *s) did_emsg = false; msg_didany = false; // reset lines_left in msg_start() may_clear_sb_text(); // clear scroll-back text on next msg - show_cursor_info(false); setcursor(); } -- cgit From d6ecead36406233cc56353dd05f3380f0497630f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 14 Mar 2023 11:49:46 +0100 Subject: refactor(screen): screen.c delenda est drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now. --- 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 2a8fbbb962..605b0aee68 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -62,7 +62,6 @@ #include "nvim/plines.h" #include "nvim/profile.h" #include "nvim/quickfix.h" -#include "nvim/screen.h" #include "nvim/search.h" #include "nvim/spell.h" #include "nvim/spellfile.h" -- cgit From 4eef5ac453866dae7c03f5432fc8c4dfcda19f54 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Mar 2023 09:24:04 +0800 Subject: vim-patch:9.0.1428: cursor in wrong position when leaving insert mode (#22786) Problem: Cursor in wrong position when leaving insert mode. Solution: Update the w_valid flags. Position the cursor also when not redrawing. (closes vim/vim#12137) https://github.com/vim/vim/commit/c174c2e58c9e24a75b189e01143e6d057b84e96e Co-authored-by: Bram Moolenaar --- 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 605b0aee68..6ad1cbd987 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1377,6 +1377,7 @@ static int normal_check(VimState *state) // update cursor and redraw. if (skip_redraw || exmode_active) { skip_redraw = false; + setcursor(); } else if (do_redraw || stuff_empty()) { // Ensure curwin->w_topline and curwin->w_leftcol are up to date // before triggering a WinScrolled autocommand. -- cgit From 371823d407d7d7519735131bcad4670c62a731a7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:13:53 +0200 Subject: refactor: make error message definitions const message.c functions now take const char * as a format. Error message definitions can be made const. --- 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 6ad1cbd987..66c24fb444 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -117,7 +117,7 @@ static inline void normal_state_init(NormalState *s) // n_*(): functions called to handle Normal mode commands. // v_*(): functions called to handle Visual mode commands. -static char *e_noident = N_("E349: No identifier under cursor"); +static const char *e_noident = N_("E349: No identifier under cursor"); /// Function to be called for a Normal or Visual mode command. /// The argument is a cmdarg_T. -- cgit From 9408f2dcf7cade2631688300e9b58eed6bc5219a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:40:57 +0200 Subject: refactor: remove redundant const char * casts --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 66c24fb444..b11d5a3c32 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -668,7 +668,7 @@ static void normal_redraw_mode_message(NormalState *s) keep_msg = kmsg; kmsg = xstrdup(keep_msg); - msg_attr((const char *)kmsg, keep_msg_attr); + msg_attr(kmsg, keep_msg_attr); xfree(kmsg); } setcursor(); @@ -1336,7 +1336,7 @@ static void normal_redraw(NormalState *s) // check for duplicates. Never put this message in // history. msg_hist_off = true; - msg_attr((const char *)p, keep_msg_attr); + msg_attr(p, keep_msg_attr); msg_hist_off = false; xfree(p); } @@ -3512,7 +3512,7 @@ static void nv_ident(cmdarg_T *cap) ptr = xstrnsave(ptr, n); if (kp_ex) { // Escape the argument properly for an Ex command - p = vim_strsave_fnameescape((const char *)ptr, VSE_NONE); + p = vim_strsave_fnameescape(ptr, VSE_NONE); } else { // Escape the argument properly for a shell command p = vim_strsave_shellescape(ptr, true, true); @@ -5334,7 +5334,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) coladvance((colnr_T)i); // if the character doesn't fit move one back - if (curwin->w_cursor.col > 0 && utf_ptr2cells((const char *)get_cursor_pos_ptr()) > 1) { + if (curwin->w_cursor.col > 0 && utf_ptr2cells(get_cursor_pos_ptr()) > 1) { colnr_T vcol; getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); -- cgit From 086088ce4499d50c3b2377e217917370bd6387c2 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 13 Apr 2023 23:09:41 +0200 Subject: vim-patch:9.0.1451: unnecessary redrawing when 'showcmdloc' is not "last" Problem: Unnecessary redrawing when 'showcmdloc' is not "last". Solution: Redraw later when "showcmd_is_clear" is set. (Luuk van Baal, closes vim/vim#12260) https://github.com/vim/vim/commit/aa7f25ebf16b8be99239af1134b441e3da93060a --- src/nvim/normal.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b11d5a3c32..718c51deb0 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1173,7 +1173,7 @@ static int normal_execute(VimState *state, int key) msg_col = 0; } - s->old_pos = curwin->w_cursor; // remember where cursor was + s->old_pos = curwin->w_cursor; // remember where the cursor was // When 'keymodel' contains "startsel" some keys start Select/Visual // mode. @@ -1997,13 +1997,21 @@ static void display_showcmd(void) showcmd_is_clear = (len == 0); if (*p_sloc == 's') { - win_redr_status(curwin); - setcursor(); // put cursor back where it belongs + if (showcmd_is_clear) { + curwin->w_redr_status = true; + } else { + win_redr_status(curwin); + setcursor(); // put cursor back where it belongs + } return; } if (*p_sloc == 't') { - draw_tabline(); - setcursor(); // put cursor back where it belongs + if (showcmd_is_clear) { + redraw_tabline = true; + } else { + draw_tabline(); + setcursor(); // put cursor back where it belongs + } return; } // 'showcmdloc' is "last" or empty -- cgit From b28683d25281847716ca0003cecedb3f3a34d089 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 17:44:14 +0800 Subject: vim-patch:9.0.0947: invalid memory access in substitute with function (#23126) Problem: Invalid memory access in substitute with function that goes to another file. Solution: Check for text locked in CTRL-W gf. https://github.com/vim/vim/commit/cc762a48d42b579fb7bdec2c614636b830342dd5 Co-authored-by: Bram Moolenaar --- 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 718c51deb0..5fcdf5d4c1 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -462,7 +462,7 @@ static bool check_text_locked(oparg_T *oap) /// If text is locked, "curbuf->b_ro_locked" or "allbuf_lock" is set: /// Give an error message, possibly beep and return true. /// "oap" may be NULL. -static bool check_text_or_curbuf_locked(oparg_T *oap) +bool check_text_or_curbuf_locked(oparg_T *oap) { if (check_text_locked(oap)) { return true; -- cgit From 706f871014b46300180156590ff269ee38473989 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 19 Apr 2023 17:04:00 +0100 Subject: build: update uncrustify to 0.76 --- src/nvim/normal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 5fcdf5d4c1..2bafeccba4 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2180,7 +2180,8 @@ static void nv_ignore(cmdarg_T *cap) /// Command character that doesn't do anything, but unlike nv_ignore() does /// start edit(). Used for "startinsert" executed while starting up. static void nv_nop(cmdarg_T *cap) -{} +{ +} /// Command character doesn't exist. static void nv_error(cmdarg_T *cap) -- cgit From e0d6703a6a37592780c0d6c02ea8802fc531cf62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Apr 2023 23:53:55 +0800 Subject: vim-patch:9.0.1490: the ModeChanged event may be triggered too often Problem: The ModeChanged event may be triggered too often. Solution: Only trigger ModeChanged when no operator is pending. (closes vim/vim#12298) https://github.com/vim/vim/commit/73916bac5ac2a054a0c71adfe8d742691cdfd95c --- src/nvim/normal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2bafeccba4..635d177ecc 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -956,10 +956,12 @@ normal_end: set_reg_var(get_default_register_name()); } - // Reset finish_op, in case it was set s->c = finish_op; - finish_op = false; - may_trigger_modechanged(); + if (s->oa.op_type == OP_NOP) { + // Reset finish_op, in case it was set + finish_op = false; + may_trigger_modechanged(); + } // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. if (s->c || s->ca.cmdchar == 'r' @@ -1729,9 +1731,9 @@ void prep_redo_num2(int regname, long num1, int cmd1, int cmd2, long num2, int c } } -/// check for operator active and clear it +/// Check for operator active and clear it. /// -/// @return true if operator was active +/// Beep and return true if an operator was active. static bool checkclearop(oparg_T *oap) { if (oap->op_type == OP_NOP) { @@ -1743,7 +1745,7 @@ static bool checkclearop(oparg_T *oap) /// Check for operator or Visual active. Clear active operator. /// -/// @return true if operator or Visual was active. +/// Beep and return true if an operator or Visual was active. static bool checkclearopq(oparg_T *oap) { if (oap->op_type == OP_NOP && !VIsual_active) { -- cgit From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 635d177ecc..da693371f3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2342,7 +2342,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar // Search forward for the identifier, ignore comment lines. clearpos(&found_pos); - for (;;) { + while (true) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { @@ -2692,7 +2692,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) } long n = nchar - '0'; - for (;;) { + while (true) { no_mapping++; allow_keys++; // no mapping for nchar, but allow key codes nchar = plain_vgetc(); @@ -4162,7 +4162,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) pos = NULL; } while (n > 0) { - for (;;) { + while (true) { if ((findc == '{' ? dec_cursor() : inc_cursor()) < 0) { // if not found anything, that's an error if (pos == NULL) { @@ -4310,7 +4310,7 @@ static void nv_brackets(cmdarg_T *cap) fm = prev_fm; } MarkMove flags = kMarkContext; - flags |= cap->nchar == '\'' ? kMarkBeginLine: 0; + flags |= cap->nchar == '\'' ? kMarkBeginLine : 0; nv_mark_move_to(cap, flags, fm); } else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) { // [ or ] followed by a middle mouse click: put selected text with -- cgit From e9fa6f10a0e99e888d9aecf09808ae07ff7d4f02 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Apr 2023 23:42:30 +0800 Subject: vim-patch:9.0.1336: functions without arguments are not always declared properly Problem: Functions without arguments are not always declared properly. Solution: Use "(void)" instead of "()". (Yegappan Lakshmanan, closes vim/vim#12031) https://github.com/vim/vim/commit/a23a11b5bf03454b71fdb5deac0d5f641e222160 Co-authored-by: Yegappan Lakshmanan --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index da693371f3..5a5286905f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -956,7 +956,7 @@ normal_end: set_reg_var(get_default_register_name()); } - s->c = finish_op; + const bool prev_finish_op = finish_op; if (s->oa.op_type == OP_NOP) { // Reset finish_op, in case it was set finish_op = false; @@ -964,7 +964,7 @@ normal_end: } // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. - if (s->c || s->ca.cmdchar == 'r' + if (prev_finish_op || s->ca.cmdchar == 'r' || (s->ca.cmdchar == 'g' && s->ca.nchar == 'r')) { ui_cursor_shape(); // may show different cursor shape } -- cgit From 088cdf69e3faf5cf6c9ef743379638127e6e7c0b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 11:09:27 +0800 Subject: fix(normal): make "g$" work properly with resized grid --- 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 5a5286905f..88741e1527 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5349,7 +5349,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) colnr_T vcol; getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); - if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) { + if (vcol >= curwin->w_leftcol + curwin->w_width_inner - col_off) { curwin->w_cursor.col--; } } -- cgit From e51e63c9bae88bb2d4da669c667e8dbee3ec3562 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 26 Apr 2023 03:48:02 +0200 Subject: vim-patch:9.0.0643: smoothscroll test fails Problem: Smoothscroll test fails. Solution: Check if skipcol changed. https://github.com/vim/vim/commit/b34c4b7863af8718ad726173585dd38a7c292f0f Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 88741e1527..a51bde967e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2633,6 +2633,7 @@ static void nv_scroll_line(cmdarg_T *cap) void scroll_redraw(int up, long count) { linenr_T prev_topline = curwin->w_topline; + int prev_skipcol = curwin->w_skipcol; int prev_topfill = curwin->w_topfill; linenr_T prev_lnum = curwin->w_cursor.lnum; @@ -2651,6 +2652,7 @@ void scroll_redraw(int up, long count) // we get stuck at one position. Don't move the cursor up if the // first line of the buffer is already on the screen while (curwin->w_topline == prev_topline + && curwin->w_skipcol == prev_skipcol && curwin->w_topfill == prev_topfill) { if (up) { if (curwin->w_cursor.lnum > prev_lnum -- cgit From bf12a85a69f03bb5321fe0a32e1a9ac81f31750c Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 26 Apr 2023 22:32:38 +0200 Subject: vim-patch:9.0.0734: cursor position invalid when scrolling with 'smoothscroll' Problem: Cursor position invalid when scrolling with 'smoothscroll' set. (Ernie Rael) Solution: Add w_valid_skipcol and clear flags when it changes. Adjust w_skipcol after moving the cursor. https://github.com/vim/vim/commit/2fbabd238a94022c99506e920186a5b6cdf15426 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a51bde967e..d4759aeaba 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2566,6 +2566,8 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) if (atend) { curwin->w_curswant = MAXCOL; // stick in the last column } + adjust_skipcol(); + return retval; } -- cgit From c426f7a6228cb82af0f75ac4f2421543408ff091 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 27 Apr 2023 00:03:46 +0200 Subject: vim-patch:9.0.0751: 'scrolloff' does not work well with 'smoothscroll' Problem: 'scrolloff' does not work well with 'smoothscroll'. Solution: Make positioning the cursor a bit better. Rename functions. https://github.com/vim/vim/commit/c9121f798f49fa71e814912cb186d89c164090c3 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d4759aeaba..9792f5950e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2432,7 +2432,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar /// @return true if able to move cursor, false otherwise. static bool nv_screengo(oparg_T *oap, int dir, long dist) { - int linelen = linetabsize(get_cursor_line_ptr()); + int linelen = linetabsize_str(get_cursor_line_ptr()); bool retval = true; bool atend = false; int col_off1; // margin offset for first screen line @@ -2494,7 +2494,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) retval = false; break; } - linelen = linetabsize(get_cursor_line_ptr()); + linelen = linetabsize_str(get_cursor_line_ptr()); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; assert(curwin->w_curswant <= INT_MAX - w); @@ -2525,7 +2525,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) if (curwin->w_curswant >= width1) { curwin->w_curswant -= width2; } - linelen = linetabsize(get_cursor_line_ptr()); + linelen = linetabsize_str(get_cursor_line_ptr()); } } } @@ -5497,7 +5497,7 @@ static void nv_g_cmd(cmdarg_T *cap) case 'M': oap->motion_type = kMTCharWise; oap->inclusive = false; - i = linetabsize(get_cursor_line_ptr()); + i = linetabsize_str(get_cursor_line_ptr()); if (cap->count0 > 0 && cap->count0 <= 100) { coladvance((colnr_T)(i * cap->count0 / 100)); } else { -- cgit From 26a9f0e94eb62047f0c2bb99401a8ac09840d0dd Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 27 Apr 2023 19:08:20 +0200 Subject: vim-patch:9.0.0901: setting w_leftcol and handling side effects is confusing Problem: Setting w_leftcol and handling side effects is confusing. Solution: Use a function to set w_leftcol() and handle side effects. https://github.com/vim/vim/commit/0c34d562647f029faca40f7733ccfb7b5377672b Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9792f5950e..e39a5e1ab7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2158,9 +2158,8 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff) } // do the horizontal scroll - if (want_hor && curwin->w_leftcol != tgt_leftcol) { - curwin->w_leftcol = tgt_leftcol; - leftcol_changed(); + if (want_hor) { + (void)set_leftcol(tgt_leftcol); } } @@ -2643,7 +2642,7 @@ void scroll_redraw(int up, long count) scrollup(count, true) : scrolldown(count, true); - if (get_scrolloff_value(curwin)) { + if (get_scrolloff_value(curwin) > 0) { // Adjust the cursor position for 'scrolloff'. Mark w_topline as // valid, otherwise the screen jumps back at the end of the file. cursor_correct(); @@ -2894,27 +2893,21 @@ static void nv_zet(cmdarg_T *cap) case 'h': case K_LEFT: if (!curwin->w_p_wrap) { - if ((colnr_T)cap->count1 > curwin->w_leftcol) { - curwin->w_leftcol = 0; - } else { - curwin->w_leftcol -= (colnr_T)cap->count1; - } - leftcol_changed(); + (void)set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol + ? 0 : curwin->w_leftcol - (colnr_T)cap->count1); } break; - // "zL" - scroll screen left half-page + // "zL" - scroll window left half-page case 'L': cap->count1 *= curwin->w_width_inner / 2; FALLTHROUGH; - // "zl" - scroll screen to the left + // "zl" - scroll window to the left if not wrapping case 'l': case K_RIGHT: if (!curwin->w_p_wrap) { - // scroll the window left - curwin->w_leftcol += (colnr_T)cap->count1; - leftcol_changed(); + (void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1); } break; -- cgit From 88cfb49bee3c9102082c7010acb92244e4ad1348 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 07:14:39 +0800 Subject: vim-patch:8.2.4890: inconsistent capitalization in error messages Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e39a5e1ab7..890fa0f80a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -106,6 +106,8 @@ static int VIsual_mode_orig = NUL; // saved Visual mode # include "normal.c.generated.h" #endif +static const char e_changelist_is_empty[] = N_("E664: Changelist is empty"); + static inline void normal_state_init(NormalState *s) { memset(s, 0, sizeof(NormalState)); @@ -4963,7 +4965,7 @@ static void nv_pcmark(cmdarg_T *cap) move_res = nv_mark_move_to(cap, flags, fm); } else if (cap->cmdchar == 'g') { if (curbuf->b_changelistlen == 0) { - emsg(_("E664: changelist is empty")); + emsg(_(e_changelist_is_empty)); } else if (cap->count1 < 0) { emsg(_("E662: At start of changelist")); } else { -- cgit From 5ac2e47acc999472042df4f10f8f7b5ffa72ba3e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 May 2023 17:42:14 +0800 Subject: fix(redo): make redo of Lua mappings in op-pending mode work (#23566) --- 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 890fa0f80a..fa6cdb0ad8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3232,7 +3232,7 @@ static void nv_colon(cmdarg_T *cap) } if (is_lua) { - cmd_result = map_execute_lua(); + cmd_result = map_execute_lua(true); } else { // get a command line and execute it cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL, -- cgit From a6d63591f1fc61d570b646306d7c259b5ec2cace Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sat, 13 May 2023 02:15:01 +0200 Subject: vim-patch:9.0.1545: text not scrolled when cursor moved with "g0" and "h" (#23599) Problem: Text not scrolled when cursor moved with "g0" and "h". Solution: Adjust w_skipcol when needed. (Luuk van Baal, closes vim/vim#12387) https://github.com/vim/vim/commit/8667a5678f983ba899825b810ab849952d49bcb8 --- 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 fa6cdb0ad8..7e44e55a8e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5272,6 +5272,7 @@ static void nv_g_home_m_cmd(cmdarg_T *cap) curwin->w_valid &= ~VALID_WCOL; } curwin->w_set_curswant = true; + adjust_skipcol(); } /// "g_": to the last non-blank character in the line or lines downward. -- cgit From c8dc34795b552ac69183e803bfff474ba4e595b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:23:02 +0800 Subject: vim-patch:9.0.0064: confusing error when using "q:" in command line window Problem: Confusing error when using "q:" in command line window. Solution: Check for the situation and give a better error message. (closes vim/vim#10756) https://github.com/vim/vim/commit/c963ec31a0c293d629e40cb082d4bfb1651def49 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 7e44e55a8e..c3fdb304a3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -107,6 +107,8 @@ static int VIsual_mode_orig = NUL; // saved Visual mode #endif static const char e_changelist_is_empty[] = N_("E664: Changelist is empty"); +static const char e_cmdline_window_already_open[] + = N_("E1292: Command-line window is already open"); static inline void normal_state_init(NormalState *s) { @@ -6372,6 +6374,10 @@ static void nv_record(cmdarg_T *cap) } if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { + if (cmdwin_type != 0) { + emsg(_(e_cmdline_window_already_open)); + return; + } stuffcharReadbuff(cap->nchar); stuffcharReadbuff(K_CMDWIN); } else { -- cgit From cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 23 May 2023 14:25:10 +0600 Subject: refactor(api): new helper macros Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner. --- 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 c3fdb304a3..60fff45323 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2031,7 +2031,7 @@ static void display_showcmd(void) if (len > 0) { // placeholder for future highlight support ADD_C(chunk, INTEGER_OBJ(0)); - ADD_C(chunk, STRING_OBJ(cstr_as_string(showcmd_buf))); + ADD_C(chunk, CSTR_AS_OBJ(showcmd_buf)); ADD_C(content, ARRAY_OBJ(chunk)); } ui_call_msg_showcmd(content); -- cgit From c45a111e35478d2173d8ed5bab2eb73ab2de590c Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 2 Jun 2023 17:26:41 +0200 Subject: vim-patch:9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor" (#23884) Problem: Cursor not adjusted when near top or bottom of window and 'splitkeep' is not "cursor". Solution: Move boundary checks to outer cursor move functions, inner functions should only return valid cursor positions. (Luuk van Baal, closes vim/vim#12480) https://github.com/vim/vim/commit/a109f39ef54bc3894768170f02c1b6ac56164488 --- src/nvim/normal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 60fff45323..f3909030c9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2493,10 +2493,12 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) curwin->w_curswant -= width2; } else { // to previous line - if (!cursor_up_inner(curwin, 1)) { + if (curwin->w_cursor.lnum <= 1) { retval = false; break; } + cursor_up_inner(curwin, 1); + linelen = linetabsize_str(get_cursor_line_ptr()); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; @@ -2516,11 +2518,13 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) curwin->w_curswant += width2; } else { // to next line - if (!cursor_down_inner(curwin, 1)) { + if (curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) { retval = false; break; } + cursor_down_inner(curwin, 1); curwin->w_curswant %= width2; + // Check if the cursor has moved below the number display // when width1 < width2 (with cpoptions+=n). Subtract width2 // to get a negative value for w_curswant, which will get -- cgit From fcf3519c65a2d6736de437f686e788684a6c8564 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 17 Apr 2023 22:18:58 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/normal.c | 100 ++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 51 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f3909030c9..c5538fb7dd 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1406,7 +1406,7 @@ static int normal_check(VimState *state) // Scroll-binding for diff mode may have been postponed until // here. Avoids doing it for every change. if (diff_need_scrollbind) { - check_scrollbind((linenr_T)0, 0L); + check_scrollbind(0, 0L); diff_need_scrollbind = false; } @@ -2116,8 +2116,8 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff) int old_VIsual_select = VIsual_select; int old_VIsual_active = VIsual_active; colnr_T tgt_leftcol = curwin->w_leftcol; - long topline; - long y; + linenr_T topline; + linenr_T y; // check 'scrollopt' string for vertical and horizontal scroll options want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); @@ -2140,7 +2140,7 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff) diff_set_topline(old_curwin, curwin); } else { curwin->w_scbind_pos += topline_diff; - topline = curwin->w_scbind_pos; + topline = (linenr_T)curwin->w_scbind_pos; if (topline > curbuf->b_ml.ml_line_count) { topline = curbuf->b_ml.ml_line_count; } @@ -2210,7 +2210,7 @@ static void nv_addsub(cmdarg_T *cap) } else if (!VIsual_active && cap->oap->op_type == OP_NOP) { prep_redo_cmd(cap); cap->oap->op_type = cap->cmdchar == Ctrl_A ? OP_NR_ADD : OP_NR_SUB; - op_addsub(cap->oap, (linenr_T)cap->count1, cap->arg); + op_addsub(cap->oap, cap->count1, cap->arg); cap->oap->op_type = OP_NOP; } else if (VIsual_active) { nv_operator(cap); @@ -2229,9 +2229,9 @@ static void nv_page(cmdarg_T *cap) if (mod_mask & MOD_MASK_CTRL) { // : tab page back; : tab page forward if (cap->arg == BACKWARD) { - goto_tabpage(-(int)cap->count1); + goto_tabpage(-cap->count1); } else { - goto_tabpage((int)cap->count0); + goto_tabpage(cap->count0); } } else { (void)onepage(cap->arg, cap->count1); @@ -2604,10 +2604,10 @@ static void nv_mousescroll(cmdarg_T *cap) if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) { if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { - (void)onepage(cap->arg ? FORWARD : BACKWARD, 1L); + (void)onepage(cap->arg ? FORWARD : BACKWARD, 1); } else if (p_mousescroll_vert > 0) { - cap->count1 = p_mousescroll_vert; - cap->count0 = p_mousescroll_vert; + cap->count1 = (int)p_mousescroll_vert; + cap->count0 = (int)p_mousescroll_vert; nv_scroll_line(cap); } } else { @@ -2639,7 +2639,7 @@ static void nv_scroll_line(cmdarg_T *cap) } /// Scroll "count" lines up or down, and redraw. -void scroll_redraw(int up, long count) +void scroll_redraw(int up, linenr_T count) { linenr_T prev_topline = curwin->w_topline; int prev_skipcol = curwin->w_skipcol; @@ -2701,7 +2701,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) if (checkclearop(cap->oap)) { return false; } - long n = nchar - '0'; + int n = nchar - '0'; while (true) { no_mapping++; @@ -2717,7 +2717,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) } else if (ascii_isdigit(nchar)) { n = n * 10 + (nchar - '0'); } else if (nchar == CAR) { - win_setheight((int)n); + win_setheight(n); break; } else if (nchar == 'l' || nchar == 'h' @@ -2789,7 +2789,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar) assert(len <= INT_MAX); spell_add_word(ptr, (int)len, nchar == 'w' || nchar == 'W' ? SPELL_ADD_BAD : SPELL_ADD_GOOD, - (nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1, + (nchar == 'G' || nchar == 'W') ? 0 : cap->count1, undo); return OK; @@ -2828,7 +2828,7 @@ static void nv_zet(cmdarg_T *cap) if (cap->count0 > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; } else { - curwin->w_cursor.lnum = (linenr_T)cap->count0; + curwin->w_cursor.lnum = cap->count0; } check_cursor_col(); } @@ -3009,7 +3009,7 @@ static void nv_zet(cmdarg_T *cap) clearFolding(curwin); changed_window_setting(); } else if (foldmethodIsMarker(curwin)) { - deleteFold(curwin, (linenr_T)1, curbuf->b_ml.ml_line_count, true, false); + deleteFold(curwin, 1, curbuf->b_ml.ml_line_count, true, false); } else { emsg(_("E352: Cannot erase folds with current 'foldmethod'")); } @@ -3163,7 +3163,7 @@ static void nv_zet(cmdarg_T *cap) case '=': // "z=": suggestions for a badly spelled word if (!checkclearop(cap->oap)) { - spell_suggest((int)cap->count0); + spell_suggest(cap->count0); } break; @@ -3267,7 +3267,7 @@ static void nv_ctrlg(cmdarg_T *cap) showmode(); } else if (!checkclearop(cap->oap)) { // print full name if count given or :cd used - fileinfo((int)cap->count0, false, true); + fileinfo(cap->count0, false, true); } } @@ -3317,7 +3317,7 @@ static void nv_ctrlo(cmdarg_T *cap) static void nv_hat(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) { - (void)buflist_getfile((int)cap->count0, (linenr_T)0, + (void)buflist_getfile(cap->count0, 0, GETF_SETMARK|GETF_ALT, false); } } @@ -3644,14 +3644,14 @@ bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp) static void nv_tagpop(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) { - do_tag("", DT_POP, (int)cap->count1, false, true); + do_tag("", DT_POP, cap->count1, false, true); } } /// Handle scrolling command 'H', 'L' and 'M'. static void nv_scroll(cmdarg_T *cap) { - long n; + int n; linenr_T lnum; cap->oap->motion_type = kMTLineWise; @@ -3674,7 +3674,7 @@ static void nv_scroll(cmdarg_T *cap) } } } else { - curwin->w_cursor.lnum -= (linenr_T)cap->count1 - 1; + curwin->w_cursor.lnum -= cap->count1 - 1; } } } else { @@ -3688,15 +3688,15 @@ static void nv_scroll(cmdarg_T *cap) for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) { // Count half the number of filler lines to be "below this // line" and half to be "above the next line". - if (n > 0 && used + win_get_fill(curwin, curwin->w_topline + (linenr_T)n) / 2 >= half) { + if (n > 0 && used + win_get_fill(curwin, curwin->w_topline + n) / 2 >= half) { n--; break; } - used += plines_win(curwin, curwin->w_topline + (linenr_T)n, true); + used += plines_win(curwin, curwin->w_topline + n, true); if (used >= half) { break; } - if (hasFolding(curwin->w_topline + (linenr_T)n, NULL, &lnum)) { + if (hasFolding(curwin->w_topline + n, NULL, &lnum)) { n = lnum - curwin->w_topline; } } @@ -3715,7 +3715,7 @@ static void nv_scroll(cmdarg_T *cap) n = lnum - curwin->w_topline; } } - curwin->w_cursor.lnum = curwin->w_topline + (linenr_T)n; + curwin->w_cursor.lnum = curwin->w_topline + n; if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; } @@ -3731,7 +3731,7 @@ static void nv_scroll(cmdarg_T *cap) /// Cursor right commands. static void nv_right(cmdarg_T *cap) { - long n; + int n; if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { // and move a word or WORD right @@ -3809,7 +3809,7 @@ static void nv_right(cmdarg_T *cap) /// @return true when operator end should not be adjusted. static void nv_left(cmdarg_T *cap) { - long n; + int n; if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { // and move a word or WORD left @@ -4110,7 +4110,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) pos_T new_pos = { 0, 0, 0 }; pos_T *pos = NULL; // init for GCC pos_T prev_pos; - long n; + int n; int findc; if (cap->nchar == '*') { @@ -4224,7 +4224,7 @@ static void nv_brackets(cmdarg_T *cap) { pos_T old_pos; // cursor position before command int flag; - long n; + int n; cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; @@ -4261,7 +4261,7 @@ static void nv_brackets(cmdarg_T *cap) ACTION_GOTO), (cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 - : (linenr_T)1), + : 1), MAXLNUM); xfree(ptr); curwin->w_set_curswant = true; @@ -4373,10 +4373,10 @@ static void nv_percent(cmdarg_T *cap) // to avoid overflows. if (curbuf->b_ml.ml_line_count >= 21474836) { curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99) - / 100 * (linenr_T)cap->count0; + / 100 * cap->count0; } else { curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * - (linenr_T)cap->count0 + 99) / 100; + cap->count0 + 99) / 100; } if (curwin->w_cursor.lnum < 1) { curwin->w_cursor.lnum = 1; @@ -4487,7 +4487,7 @@ static void nv_kundo(cmdarg_T *cap) clearopbeep(cap->oap); return; } - u_undo((int)cap->count1); + u_undo(cap->count1); curwin->w_set_curswant = true; } @@ -4611,7 +4611,7 @@ static void nv_replace(cmdarg_T *cap) // This is slow, but it handles replacing a single-byte with a // multi-byte and the other way around. Also handles adding // composing characters for utf-8. - for (long n = cap->count1; n > 0; n--) { + for (int n = cap->count1; n > 0; n--) { State = MODE_REPLACE; if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { int c = ins_copychar(curwin->w_cursor.lnum @@ -4753,7 +4753,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) { - long n; + int n; pos_T startpos; int did_change = 0; @@ -4959,9 +4959,9 @@ static void nv_pcmark(cmdarg_T *cap) } if (cap->cmdchar == 'g') { - fm = get_changelist(curbuf, curwin, (int)cap->count1); + fm = get_changelist(curbuf, curwin, cap->count1); } else { - fm = get_jumplist(curwin, (int)cap->count1); + fm = get_jumplist(curwin, cap->count1); flags |= KMarkNoContext | kMarkJumpList; } // Changelist and jumplist have their own error messages. Therefore avoid @@ -5053,7 +5053,7 @@ static void nv_visual(cmdarg_T *cap) // For V and ^V, we multiply the number of lines even if there // was only one -- webb if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) { - curwin->w_cursor.lnum += resel_VIsual_line_count * (linenr_T)cap->count0 - 1; + curwin->w_cursor.lnum += resel_VIsual_line_count * cap->count0 - 1; check_cursor(); } VIsual_mode = resel_VIsual_mode; @@ -5061,7 +5061,7 @@ static void nv_visual(cmdarg_T *cap) if (resel_VIsual_line_count <= 1) { update_curswant_force(); assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX); - curwin->w_curswant += resel_VIsual_vcol * (int)cap->count0; + curwin->w_curswant += resel_VIsual_vcol * cap->count0; if (*p_sel != 'e') { curwin->w_curswant--; } @@ -5079,7 +5079,7 @@ static void nv_visual(cmdarg_T *cap) curwin->w_cursor.lnum = VIsual.lnum; update_curswant_force(); assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX); - curwin->w_curswant += resel_VIsual_vcol * (int)cap->count0 - 1; + curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; curwin->w_cursor.lnum = lnum; coladvance(curwin->w_curswant); } else { @@ -5632,7 +5632,7 @@ static void nv_g_cmd(cmdarg_T *cap) // "gD": idem, but in the current file. case 'd': case 'D': - nv_gd(oap, cap->nchar, (int)cap->count0); + nv_gd(oap, cap->nchar, cap->count0); break; // g<*Mouse> : @@ -5688,12 +5688,12 @@ static void nv_g_cmd(cmdarg_T *cap) case 't': if (!checkclearop(oap)) { - goto_tabpage((int)cap->count0); + goto_tabpage(cap->count0); } break; case 'T': if (!checkclearop(oap)) { - goto_tabpage(-(int)cap->count1); + goto_tabpage(-cap->count1); } break; @@ -5733,10 +5733,8 @@ static void n_opencmd(cmdarg_T *cap) (void)hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum); } - if (u_save((linenr_T)(curwin->w_cursor.lnum - - (cap->cmdchar == 'O' ? 1 : 0)), - (linenr_T)(curwin->w_cursor.lnum + - (cap->cmdchar == 'o' ? 1 : 0))) + if (u_save(curwin->w_cursor.lnum - (cap->cmdchar == 'O' ? 1 : 0), + curwin->w_cursor.lnum + (cap->cmdchar == 'o' ? 1 : 0)) && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, 0, NULL)) { @@ -5787,7 +5785,7 @@ static void nv_redo_or_register(cmdarg_T *cap) return; } - u_redo((int)cap->count1); + u_redo(cap->count1); curwin->w_set_curswant = true; } @@ -6099,7 +6097,7 @@ static void nv_goto(cmdarg_T *cap) // When a count is given, use it instead of the default lnum if (cap->count0 != 0) { - lnum = (linenr_T)cap->count0; + lnum = cap->count0; } if (lnum < 1L) { lnum = 1L; @@ -6421,7 +6419,7 @@ static void nv_halfpage(cmdarg_T *cap) && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) { clearopbeep(cap->oap); } else if (!checkclearop(cap->oap)) { - halfpage(cap->cmdchar == Ctrl_D, (linenr_T)cap->count0); + halfpage(cap->cmdchar == Ctrl_D, cap->count0); } } -- cgit From 8c5d81997e56a72fbb1392846a146cab2eb74b7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 12 Aug 2023 06:41:23 +0800 Subject: vim-patch:9.0.1693: Ctrl-Q not handled like Ctrl-V in replace mode (#24669) Problem: Ctrl-Q not handled like Ctrl-V in replace mode Solution: Handle Ctrl-Q like Ctrl-V closes: vim/vim#12686 closes: vim/vim#12684 https://github.com/vim/vim/commit/2d63e4b3ccc0bb34db21a3c1d024cb114f8c4071 Co-authored-by: Christian Brabandt --- src/nvim/normal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index c5538fb7dd..b82a6b928d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4506,7 +4506,7 @@ static void nv_replace(cmdarg_T *cap) } // get another character - if (cap->nchar == Ctrl_V) { + if (cap->nchar == Ctrl_V || cap->nchar == Ctrl_Q) { had_ctrl_v = Ctrl_V; cap->nchar = get_literal(false); // Don't redo a multibyte character with CTRL-V. @@ -4733,7 +4733,8 @@ static void nv_vreplace(cmdarg_T *cap) if (!MODIFIABLE(curbuf)) { emsg(_(e_modifiable)); } else { - if (cap->extra_char == Ctrl_V) { // get another character + if (cap->extra_char == Ctrl_V || cap->extra_char == Ctrl_Q) { + // get another character cap->extra_char = get_literal(false); } if (cap->extra_char < ' ') { -- cgit From 72cf94fc0e69b7a049ae2990572876d641cf5cb9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 12 Aug 2023 06:50:52 +0800 Subject: vim-patch:9.0.1694: wrong mapping applied when replaying a char search (#24670) Problem: wrong mapping applied when replaying a char search Solution: Store a NOP after the ESC closes: vim/vim#12708 closes: vim/vim#6350 https://github.com/vim/vim/commit/bacc83009bc38c9ba0247aaa22b76d1993d57993 --- src/nvim/normal.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b82a6b928d..1e9bc78fe3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -807,25 +807,32 @@ static void normal_get_additional_char(NormalState *s) } } - // When getting a text character and the next character is a - // multi-byte character, it could be a composing character. - // However, don't wait for it to arrive. Also, do enable mapping, - // because if it's put back with vungetc() it's too late to apply - // mapping. - no_mapping--; - while (lang && (s->c = vpeekc()) > 0 - && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { - s->c = plain_vgetc(); - if (!utf_iscomposing(s->c)) { - vungetc(s->c); // it wasn't, put it back - break; - } else if (s->ca.ncharC1 == 0) { - s->ca.ncharC1 = s->c; - } else { - s->ca.ncharC2 = s->c; + if (lang) { + // When getting a text character and the next character is a + // multi-byte character, it could be a composing character. + // However, don't wait for it to arrive. Also, do enable mapping, + // because if it's put back with vungetc() it's too late to apply + // mapping. + no_mapping--; + while (lang && (s->c = vpeekc()) > 0 + && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { + s->c = plain_vgetc(); + if (!utf_iscomposing(s->c)) { + vungetc(s->c); // it wasn't, put it back + break; + } else if (s->ca.ncharC1 == 0) { + s->ca.ncharC1 = s->c; + } else { + s->ca.ncharC2 = s->c; + } } + 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. + gotchars_nop(); } - no_mapping++; } no_mapping--; allow_keys--; -- cgit From 58a1ef8e6a93c615379f6fbe7234697bcdc42b3e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 12 Aug 2023 09:50:17 +0800 Subject: fix(events): avoid unnecessary CursorMoved (#24675) Problem: Temporarily changing current window in a script causes CursorMoved to be triggerd. Solution: Don't trigger CursorMoved if neither curwin nor cursor changed between two checks. --- src/nvim/normal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1e9bc78fe3..edfc62ae17 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1267,9 +1267,11 @@ static void normal_check_cursor_moved(NormalState *s) { // Trigger CursorMoved if the cursor moved. if (!finish_op && has_event(EVENT_CURSORMOVED) - && !equalpos(curwin->w_last_cursormoved, curwin->w_cursor)) { + && (last_cursormoved_win != curwin + || !equalpos(last_cursormoved, curwin->w_cursor))) { apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, false, curbuf); - curwin->w_last_cursormoved = curwin->w_cursor; + last_cursormoved_win = curwin; + last_cursormoved = curwin->w_cursor; } } -- cgit From 5a564bf242828a04c8fe12c7e83154cb09acf4aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 20:35:51 +0800 Subject: refactor: cast to int earlier when using 'so' and 'siso' (#24756) --- 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 edfc62ae17..f9689d7593 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2812,7 +2812,7 @@ static void nv_zet(cmdarg_T *cap) long old_fdl = curwin->w_p_fdl; int old_fen = curwin->w_p_fen; - int siso = (int)get_sidescrolloff_value(curwin); + int siso = get_sidescrolloff_value(curwin); if (ascii_isdigit(nchar) && !nv_z_get_count(cap, &nchar)) { return; -- cgit From 7485fd0518557f7f49f9b636a80e4e3b523dd9dd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 06:08:28 +0800 Subject: vim-patch:9.0.1753: can't move to last non-blank char Problem: can't move to last non-blank char Solution: Make g behave like that Make it possible to move to last non-blank char on a line We can distinguish between g0 and g^ to move to the very first character and the first non-blank char. And while we can move to the last screen char, we cannot go to the last non-blank screen char. Since I think g$ is the more widely used and known movement command (and g is synonymous to it) change the behaviour of g to move to last non-screen char instead and don't have this be the same command as the g$ command anymore. If you want to keep the old behaviour, you can use: ``` nnoremap g g$ ``` Add a test to verify the behaviour. closes: vim/vim#12593 https://github.com/vim/vim/commit/b5f6fe9ca2661d06bc0be839447ce1995450b9de Co-authored-by: Christian Brabandt --- src/nvim/normal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f9689d7593..4a4b675591 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5284,7 +5284,7 @@ static void nv_g_home_m_cmd(cmdarg_T *cap) if (flag) { do { i = gchar_cursor(); - } while (ascii_iswhite(i) && oneright()); + } while (ascii_iswhite(i) && oneright() == OK); curwin->w_valid &= ~VALID_WCOL; } curwin->w_set_curswant = true; @@ -5323,6 +5323,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) oparg_T *oap = cap->oap; int i; int col_off = curwin_col_off(); + const bool flag = cap->nchar == K_END; oap->motion_type = kMTCharWise; oap->inclusive = true; @@ -5373,6 +5374,12 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) // Make sure we stick in this column. update_curswant_force(); } + if (flag) { + do { + i = gchar_cursor(); + } while (ascii_iswhite(i) && oneleft() == OK); + curwin->w_valid &= ~VALID_WCOL; + } } /// "gi": start Insert at the last position. -- cgit From 0c91cb4f03814bfdfe262c6d2693c6883c38719b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 06:11:23 +0800 Subject: vim-patch:9.0.1761: g behaves different from g Problem: g behaves different from g Solution: Make g behave like g closes: vim/vim#12861 https://github.com/vim/vim/commit/654bdbbd329e7267051cc2eb496bc52b66053081 --- 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 4a4b675591..e72a0fe385 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5323,7 +5323,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) oparg_T *oap = cap->oap; int i; int col_off = curwin_col_off(); - const bool flag = cap->nchar == K_END; + const bool flag = cap->nchar == K_END || cap->nchar == K_KEND; oap->motion_type = kMTCharWise; oap->inclusive = true; -- cgit From ab45d5bf6d46abd9b29389dee6689044fd63e225 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 10:45:25 +0800 Subject: vim-patch:8.1.2044: no easy way to process postponed work Problem: No easy way to process postponed work. (Paul Jolly) Solution: Add the SafeState autocommand event. https://github.com/vim/vim/commit/8aeec40207b5adcd3a155277dc4f29189343b963 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e72a0fe385..253a3f288e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -482,6 +482,40 @@ bool check_text_or_curbuf_locked(oparg_T *oap) return true; } +static bool was_safe = false; +static int not_safe_now = 0; + +/// Trigger SafeState if currently in s safe state, that is "safe" is TRUE and +/// there is no typeahead. +void may_trigger_safestate(bool safe) +{ + bool is_safe = safe + && stuff_empty() + && typebuf.tb_len == 0 + && !global_busy; + + if (is_safe) { + apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); + } + was_safe = is_safe; +} + +/// Entering a not-safe state. +void enter_unsafe_state(void) +{ + not_safe_now++; +} + +/// Leaving a not-safe state. Trigger SafeState if we were in a safe state +/// before first calling enter_not_safe_state(). +void leave_unsafe_state(void) +{ + not_safe_now--; + if (not_safe_now == 0 && was_safe) { + apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); + } +} + /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. @@ -1295,6 +1329,18 @@ static void normal_check_buffer_modified(NormalState *s) } } +/// If nothing is pending and we are going to wait for the user to +/// type a character, trigger SafeState. +static void normal_check_safe_state(NormalState *s) +{ + may_trigger_safestate(!finish_op + && s->oa.prev_opcount > 0 + && s->oa.prev_count0 == 0 + && s->oa.op_type == OP_NOP + && s->oa.regname == NUL + && restart_edit == 0); +} + static void normal_check_folds(NormalState *s) { // Include a closed fold completely in the Visual area. @@ -1387,6 +1433,9 @@ static int normal_check(VimState *state) } quit_more = false; + // it's not safe unless normal_check_safe_state() is called + was_safe = false; + // If skip redraw is set (for ":" in wait_return()), don't redraw now. // If there is nothing in the stuff_buffer or do_redraw is true, // update cursor and redraw. @@ -1403,6 +1452,7 @@ static int normal_check(VimState *state) normal_check_text_changed(s); normal_check_window_scrolled(s); normal_check_buffer_modified(s); + normal_check_safe_state(s); // Updating diffs from changed() does not always work properly, // esp. updating folds. Do an update just before redrawing if -- cgit From 4956f267449ca7526145c63ef095bfd731174635 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 11:11:02 +0800 Subject: vim-patch:8.1.2046: SafeState may be triggered at the wrong moment Problem: SafeState may be triggered at the wrong moment. Solution: Move it up higher to after where messages are processed. Add a SafeStateAgain event to tigger there. https://github.com/vim/vim/commit/69198cb8c08f124729c41a4681f2d142228a9139 SafeStateAgain is N/A. Move SafeState functions to state.c. Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 253a3f288e..324bfc0c46 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -482,40 +482,6 @@ bool check_text_or_curbuf_locked(oparg_T *oap) return true; } -static bool was_safe = false; -static int not_safe_now = 0; - -/// Trigger SafeState if currently in s safe state, that is "safe" is TRUE and -/// there is no typeahead. -void may_trigger_safestate(bool safe) -{ - bool is_safe = safe - && stuff_empty() - && typebuf.tb_len == 0 - && !global_busy; - - if (is_safe) { - apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); - } - was_safe = is_safe; -} - -/// Entering a not-safe state. -void enter_unsafe_state(void) -{ - not_safe_now++; -} - -/// Leaving a not-safe state. Trigger SafeState if we were in a safe state -/// before first calling enter_not_safe_state(). -void leave_unsafe_state(void) -{ - not_safe_now--; - if (not_safe_now == 0 && was_safe) { - apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); - } -} - /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. @@ -1434,7 +1400,7 @@ static int normal_check(VimState *state) quit_more = false; // it's not safe unless normal_check_safe_state() is called - was_safe = false; + state_no_longer_safe(); // If skip redraw is set (for ":" in wait_return()), don't redraw now. // If there is nothing in the stuff_buffer or do_redraw is true, -- cgit From 64ccfdaafef56b451e3a5eed94367fad93978ec8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 11:22:25 +0800 Subject: vim-patch:8.1.2047: cannot check the current state Problem: Cannot check the current state. Solution: Add the state() function. https://github.com/vim/vim/commit/0e57dd859ecb1e8a3b91509d2f4343e839340eb8 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 324bfc0c46..56bc75d658 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -482,6 +482,20 @@ bool check_text_or_curbuf_locked(oparg_T *oap) return true; } +static oparg_T *current_oap = NULL; + +/// Check if an operator was started but not finished yet. +/// Includes typing a count or a register name. +bool op_pending(void) +{ + return !(current_oap != NULL + && !finish_op + && current_oap->prev_opcount == 0 + && current_oap->prev_count0 == 0 + && current_oap->op_type == OP_NOP + && current_oap->regname == NUL); +} + /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. @@ -490,15 +504,18 @@ bool check_text_or_curbuf_locked(oparg_T *oap) /// for example. Returns when re-entering ex mode(because ex mode recursion is /// not allowed) /// -/// This used to be called main_loop on main.c +/// This used to be called main_loop() on main.c void normal_enter(bool cmdwin, bool noexmode) { NormalState state; normal_state_init(&state); + oparg_T *prev_oap = current_oap; + current_oap = &state.oa; state.cmdwin = cmdwin; state.noexmode = noexmode; state.toplevel = (!cmdwin || cmdwin_result == 0) && !noexmode; state_enter(&state.state); + current_oap = prev_oap; } static void normal_prepare(NormalState *s) @@ -1299,12 +1316,7 @@ static void normal_check_buffer_modified(NormalState *s) /// type a character, trigger SafeState. static void normal_check_safe_state(NormalState *s) { - may_trigger_safestate(!finish_op - && s->oa.prev_opcount > 0 - && s->oa.prev_count0 == 0 - && s->oa.op_type == OP_NOP - && s->oa.regname == NUL - && restart_edit == 0); + may_trigger_safestate(!op_pending() && restart_edit == 0); } static void normal_check_folds(NormalState *s) -- cgit From 7ce2acd59be89e5e6d2ac778ad074a9ae42951cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 12:16:33 +0800 Subject: vim-patch:8.1.2053: SafeStateAgain not triggered if callback uses feedkeys() Problem: SafeStateAgain not triggered if callback uses feedkeys(). Solution: Check for safe state in the input loop. Make log messages easier to find. Add 'S' flag to state(). https://github.com/vim/vim/commit/d103ee78432f9036d243b18dd5aac1263d3b7dc9 Include misc1.c change from patch 8.1.2062. Co-authored-by: Bram Moolenaar --- 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 56bc75d658..40bef6b580 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1412,7 +1412,7 @@ static int normal_check(VimState *state) quit_more = false; // it's not safe unless normal_check_safe_state() is called - state_no_longer_safe(); + state_no_longer_safe(NULL); // If skip redraw is set (for ":" in wait_return()), don't redraw now. // If there is nothing in the stuff_buffer or do_redraw is true, -- cgit From cc35352f65f823259675f84a915ee03d2423913e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 15:23:32 +0800 Subject: vim-patch:8.1.2062: the mouse code is spread out (#24817) Problem: The mouse code is spread out. Solution: Move all the mouse code to mouse.c. (Yegappan Lakshmanan, closes vim/vim#4959) https://github.com/vim/vim/commit/b20b9e14ddd8db111e886ad0494e15b955159426 Also move getmousepos() there. N/A patches for version.c: vim-patch:8.1.2070: mouse code is spread out Problem: Mouse code is spread out. Solution: Move mouse terminal code parsing to mouse.c. (Yegappan Lakshmanan, closes vim/vim#4966) https://github.com/vim/vim/commit/b8ff5c271ee5dcef6f63436b77e228e062ff9a0e Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 53 +---------------------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 40bef6b580..a6f64d22ce 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2615,60 +2615,9 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) return retval; } -/// Mouse scroll wheel: Default action is to scroll three lines, or one page -/// when Shift or Ctrl is used. -/// K_MOUSEUP (cap->arg == 1) or K_MOUSEDOWN (cap->arg == 0) or -/// K_MOUSELEFT (cap->arg == -1) or K_MOUSERIGHT (cap->arg == -2) -static void nv_mousescroll(cmdarg_T *cap) -{ - win_T *old_curwin = curwin; - - if (mouse_row >= 0 && mouse_col >= 0) { - int grid, row, col; - - grid = mouse_grid; - row = mouse_row; - col = mouse_col; - - // find the window at the pointer coordinates - win_T *wp = mouse_find_win(&grid, &row, &col); - if (wp == NULL) { - return; - } - curwin = wp; - curbuf = curwin->w_buffer; - } - - if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) { - if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { - (void)onepage(cap->arg ? FORWARD : BACKWARD, 1); - } else if (p_mousescroll_vert > 0) { - cap->count1 = (int)p_mousescroll_vert; - cap->count0 = (int)p_mousescroll_vert; - nv_scroll_line(cap); - } - } else { - mouse_scroll_horiz(cap->arg); - } - if (curwin != old_curwin && curwin->w_p_cul) { - redraw_for_cursorline(curwin); - } - - curwin->w_redr_status = true; - - curwin = old_curwin; - curbuf = curwin->w_buffer; -} - -/// Mouse clicks and drags. -static void nv_mouse(cmdarg_T *cap) -{ - (void)do_mouse(cap->oap, cap->cmdchar, BACKWARD, cap->count1, 0); -} - /// Handle CTRL-E and CTRL-Y commands: scroll a line up or down. /// cap->arg must be true for CTRL-E. -static void nv_scroll_line(cmdarg_T *cap) +void nv_scroll_line(cmdarg_T *cap) { if (!checkclearop(cap->oap)) { scroll_redraw(cap->arg, cap->count1); -- cgit From cefd774fac76b91f5368833555818c80c992c3b1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 24 Aug 2023 15:14:23 +0200 Subject: refactor(memline): distinguish mutating uses of ml_get_buf() ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline. --- 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 a6f64d22ce..20680df144 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1638,7 +1638,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text // if i == 0: try to find an identifier // if i == 1: try to find any non-white text - char *ptr = ml_get_buf(wp->w_buffer, lnum, false); + char *ptr = ml_get_buf(wp->w_buffer, lnum); for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; i++) { // 1. skip to start of identifier/text col = startcol; -- cgit From b1cfb299df2ef412339f594173ed23c75c090c8a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 26 Aug 2023 08:35:05 +0800 Subject: docs: various clarifications (#24876) --- 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 20680df144..1a220bc962 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1411,7 +1411,6 @@ static int normal_check(VimState *state) } quit_more = false; - // it's not safe unless normal_check_safe_state() is called state_no_longer_safe(NULL); // If skip redraw is set (for ":" in wait_return()), don't redraw now. -- cgit From 008154954791001efcc46c28146e21403f3a698b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 21 Aug 2023 14:52:17 +0200 Subject: refactor(change): do API changes to buffer without curbuf switch Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired. --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1a220bc962..82b930d2ff 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3922,7 +3922,7 @@ static void nv_gotofile(cmdarg_T *cap) buf_hide(curbuf) ? ECMD_HIDE : 0, curwin) == OK && cap->nchar == 'F' && lnum >= 0) { curwin->w_cursor.lnum = lnum; - check_cursor_lnum(); + check_cursor_lnum(curwin); beginline(BL_SOL | BL_FIX); } xfree(ptr); @@ -4771,7 +4771,7 @@ static void n_swapchar(cmdarg_T *cap) if (u_savesub(curwin->w_cursor.lnum) == false) { break; } - u_clearline(); + u_clearline(curbuf); } } else { break; @@ -4782,7 +4782,7 @@ static void n_swapchar(cmdarg_T *cap) check_cursor(); curwin->w_set_curswant = true; if (did_change) { - changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, + changed_lines(curbuf, startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, 0L, true); curbuf->b_op_start = startpos; curbuf->b_op_end = curwin->w_cursor; @@ -5363,7 +5363,7 @@ static void nv_gi_cmd(cmdarg_T *cap) { if (curbuf->b_last_insert.mark.lnum != 0) { curwin->w_cursor = curbuf->b_last_insert.mark; - check_cursor_lnum(); + check_cursor_lnum(curwin); int i = (int)strlen(get_cursor_line_ptr()); if (curwin->w_cursor.col > (colnr_T)i) { if (virtual_active()) { -- cgit From 1f49c980368616345d8d0e121fed66a2013f9e96 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 27 Aug 2023 20:04:44 +0800 Subject: vim-patch:9.0.1792: problem with gj/gk/gM and virtual text (#24898) Problem: Normal mode "gM", "gj", "gk" commands behave incorrectly with virtual text. Solution: Use linetabsize() instead of linetabsize_str(). closes: vim/vim#12909 https://github.com/vim/vim/commit/d809c0a90387a23aed21ba37d0b65332fb5dafe7 --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 82b930d2ff..0764cbec7a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2471,7 +2471,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar /// @return true if able to move cursor, false otherwise. static bool nv_screengo(oparg_T *oap, int dir, long dist) { - int linelen = linetabsize_str(get_cursor_line_ptr()); + int linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); bool retval = true; bool atend = false; int col_off1; // margin offset for first screen line @@ -2535,7 +2535,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) } cursor_up_inner(curwin, 1); - linelen = linetabsize_str(get_cursor_line_ptr()); + linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; assert(curwin->w_curswant <= INT_MAX - w); @@ -2568,7 +2568,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) if (curwin->w_curswant >= width1) { curwin->w_curswant -= width2; } - linelen = linetabsize_str(get_cursor_line_ptr()); + linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); } } } @@ -5492,7 +5492,7 @@ static void nv_g_cmd(cmdarg_T *cap) case 'M': oap->motion_type = kMTCharWise; oap->inclusive = false; - i = linetabsize_str(get_cursor_line_ptr()); + i = (int)linetabsize(curwin, curwin->w_cursor.lnum); if (cap->count0 > 0 && cap->count0 <= 100) { coladvance((colnr_T)(i * cap->count0 / 100)); } else { -- cgit From a1bec02c1e105eb9f49d577e04bdbeadd5a05e38 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sun, 13 Aug 2023 10:29:43 +0100 Subject: fix: use snprintf instead of sprintf Clang 14 now reports sprintf as deprecated. --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 0764cbec7a..513fb5b202 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2350,13 +2350,13 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar bool incll; int searchflags = flags_arg; - pat = xmalloc(len + 7); + size_t patlen = len + 7; + pat = xmalloc(patlen); // Put "\V" before the pattern to avoid that the special meaning of "." // and "~" causes trouble. - assert(len <= INT_MAX); - sprintf(pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf) - (int)len, ptr); + assert(patlen <= INT_MAX); + snprintf(pat, patlen, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", (int)len, ptr); old_pos = curwin->w_cursor; save_p_ws = p_ws; save_p_scs = p_scs; -- cgit From 65d3378009cf2b94e4a240d2c5c3d4d19fa7fc92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 5 Sep 2023 06:25:51 +0800 Subject: vim-patch:9.0.1866: undo is synced after character find (#25021) vim-patch:9.0.1866: undo is synced after character find Problem: Undo is synced after character find. Solution: Set no_u_sync when calling gotchars_nop(). closes: vim/vim#13022 closes: vim/vim#13024 https://github.com/vim/vim/commit/dccc29c228f8336ef7dd069a447886639af4458e --- src/nvim/normal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 513fb5b202..4280d62a95 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -831,7 +831,7 @@ static void normal_get_additional_char(NormalState *s) // because if it's put back with vungetc() it's too late to apply // mapping. no_mapping--; - while (lang && (s->c = vpeekc()) > 0 + while ((s->c = vpeekc()) > 0 && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { s->c = plain_vgetc(); if (!utf_iscomposing(s->c)) { @@ -848,7 +848,9 @@ static void normal_get_additional_char(NormalState *s) // 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. + no_u_sync++; gotchars_nop(); + no_u_sync--; } } no_mapping--; -- cgit From c4f4c7a356013c6f1e10b7bf239d9e3c4c0c336e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Sep 2023 06:37:29 +0800 Subject: vim-patch:9.0.1915: r_CTRL-C works differently in visual mode (#25248) Problem: r_CTRL-C works differently in visual mode Solution: Make r_CTRL-C behave consistent in visual mode in terminal and Windows GUI in visual mode, r CTRL-C behaves strange in Unix like environments. It seems to end visual mode, but still is waiting for few more chars, however it never seems to replace it by any characters and eventually just returns back into normal mode. In contrast in Windows GUI mode, r_CTRL-C replaces in the selected area all characters by a literal CTRL-C. Not sure why it behaves like this. It seems in the Windows GUI, got_int is not set and therefore behaves as if any other normal character has been pressed. So remove the special casing of what happens when got_int is set and make it always behave like in Windows GUI mode. Add a test to verify it always behaves like replacing in the selected area each selected character by a literal CTRL-C. closes: vim/vim#13091 closes: vim/vim#13112 https://github.com/vim/vim/commit/476733f3d06876c7ac105e064108c973a57984d3 Co-authored-by: Christian Brabandt --- 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 4280d62a95..d730f247a9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4513,7 +4513,7 @@ static void nv_replace(cmdarg_T *cap) // Visual mode "r" if (VIsual_active) { if (got_int) { - reset_VIsual(); + got_int = false; } if (had_ctrl_v) { // Use a special (negative) number to make a difference between a -- cgit From 3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 13:42:37 +0200 Subject: refactor(grid): properly namespace and separate stateful grid functions This is a step in an ongoing refactor where the "grid_puts" and "grid_put_linebuf" code paths will share more of the implementation (in particular for delta calculation, doublewidth and 'arabicshape' handling). But it also makes sense by its own as a cleanup, and is thus committed separately. Before this change many of the low level grid functions grid_puts, grid_fill etc could both be used in a standalone fashion but also as part of a batched line update which would be finally transmitted as a single grid_line call (via ui_line() ). This was initially useful to quickly refactor pre-existing vim code to use batched logic safely. However, this pattern is not really helpful for maintainable and newly written code, where the "grid" and "row" arguments are just needlessly repeated. This simplifies these calls to just use grid and row as specified in the initial grid_line_start(grid, row) call. This also makes the intent clear whether any grid_puts() call is actually part of a batch or not, which is better in the long run when more things get refactored to use effective (properly batched) updates. --- src/nvim/normal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d730f247a9..309b6e2568 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2078,18 +2078,16 @@ static void display_showcmd(void) msg_grid_validate(); int showcmd_row = Rows - 1; - grid_puts_line_start(&msg_grid_adj, showcmd_row); + grid_line_start(&msg_grid_adj, showcmd_row); if (!showcmd_is_clear) { - grid_puts(&msg_grid_adj, showcmd_buf, showcmd_row, sc_col, - HL_ATTR(HLF_MSG)); + grid_line_puts(sc_col, showcmd_buf, -1, HL_ATTR(HLF_MSG)); } // clear the rest of an old message by outputting up to SHOWCMD_COLS spaces - grid_puts(&msg_grid_adj, (char *)" " + len, showcmd_row, - sc_col + len, HL_ATTR(HLF_MSG)); + grid_line_puts(sc_col + len, (char *)" " + len, -1, HL_ATTR(HLF_MSG)); - grid_puts_line_flush(false); + grid_line_flush(false); } /// When "check" is false, prepare for commands that scroll the window. -- cgit From b85f1dafc7c0a19704135617454f1c66f41202c1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 22:21:17 +0200 Subject: refactor(messages): fold msg_attr into msg problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 309b6e2568..adb0aa8998 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -689,7 +689,7 @@ static void normal_redraw_mode_message(NormalState *s) keep_msg = kmsg; kmsg = xstrdup(keep_msg); - msg_attr(kmsg, keep_msg_attr); + msg(kmsg, keep_msg_attr); xfree(kmsg); } setcursor(); @@ -1377,7 +1377,7 @@ static void normal_redraw(NormalState *s) // check for duplicates. Never put this message in // history. msg_hist_off = true; - msg_attr(p, keep_msg_attr); + msg(p, keep_msg_attr); msg_hist_off = false; xfree(p); } @@ -6140,9 +6140,9 @@ static void nv_esc(cmdarg_T *cap) if (restart_edit == 0 && cmdwin_type == 0 && !VIsual_active && no_reason) { if (anyBufIsChanged()) { msg(_("Type :qa! and press to abandon all changes" - " and exit Nvim")); + " and exit Nvim"), 0); } else { - msg(_("Type :qa and press to exit Nvim")); + msg(_("Type :qa and press to exit Nvim"), 0); } } -- cgit From af7d317f3ff31d5ac5d8724b5057a422e1451b54 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 26 Sep 2023 22:36:08 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/normal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index adb0aa8998..b6fe24a961 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -803,13 +803,13 @@ static void normal_get_additional_char(NormalState *s) && s->ca.cmdchar == 'g') { s->ca.oap->op_type = get_op_type(*cp, NUL); } else if (*cp == Ctrl_BSL) { - long towait = (p_ttm >= 0 ? p_ttm : p_tm); + int towait = (p_ttm >= 0 ? (int)p_ttm : (int)p_tm); // There is a busy wait here when typing "f" and then // something different from CTRL-N. Can't be avoided. - while ((s->c = vpeekc()) <= 0 && towait > 0L) { - do_sleep(towait > 50L ? 50L : towait); - towait -= 50L; + while ((s->c = vpeekc()) <= 0 && towait > 0) { + do_sleep(towait > 50 ? 50 : towait); + towait -= 50; } if (s->c > 0) { s->c = plain_vgetc(); @@ -2785,7 +2785,7 @@ static void nv_zet(cmdarg_T *cap) { colnr_T col; int nchar = cap->nchar; - long old_fdl = curwin->w_p_fdl; + long old_fdl = (long)curwin->w_p_fdl; int old_fen = curwin->w_p_fen; int siso = get_sidescrolloff_value(curwin); -- cgit From e33269578b5bea2528cc48afc5b009eb8d4ad1d6 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 10:08:05 +0200 Subject: refactor(grid): unify the two put-text-on-the-screen code paths The screen grid refactors will continue until morale improves. Jokes aside, this is quite a central installment in the series. Before this refactor, there were two fundamentally distinct codepaths for getting some text on the screen: - the win_line() -> grid_put_linebuf() -> ui_line() call chain used for buffer text, with linebuf_char as a temporary scratch buffer - the grid_line_start/grid_line_puts/grid_line_flush() -> ui_line() path used for every thing else: statuslines, messages and the command line. Here the grid->chars[] array itself doubles as a scratch buffer. With this refactor, the later family of functions still exist, however they now as well render to linebuf_char just like win_line() did, and grid_put_linebuf() is called in the end to calculate delta changes. This means we don't need any duplicate logic for delta calculations anymore. Later down the line, it will be possible to share more logic operating on this scratch buffer, like doing 'rightleft' reversal and arabic shaping as a post-processing step. --- 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 b6fe24a961..834204e5e1 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2087,7 +2087,7 @@ static void display_showcmd(void) // clear the rest of an old message by outputting up to SHOWCMD_COLS spaces grid_line_puts(sc_col + len, (char *)" " + len, -1, HL_ATTR(HLF_MSG)); - grid_line_flush(false); + grid_line_flush(); } /// When "check" is false, prepare for commands that scroll the window. -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/normal.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 834204e5e1..872aec89b9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -17,7 +17,6 @@ #include #include -#include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" @@ -73,7 +72,6 @@ #include "nvim/tag.h" #include "nvim/textformat.h" #include "nvim/textobject.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/vim.h" -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- 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 872aec89b9..715b98377a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -56,6 +56,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/input.h" #include "nvim/os/time.h" #include "nvim/plines.h" -- cgit From e72b546354cd90bf0cd8ee6dd045538d713009ad Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 715b98377a..1a212661c5 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1735,13 +1735,13 @@ static void prep_redo_cmd(cmdarg_T *cap) /// Prepare for redo of any command. /// Note that only the last argument can be a multi-byte char. -void prep_redo(int regname, long num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5) +void prep_redo(int regname, int num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5) { prep_redo_num2(regname, num, cmd1, cmd2, 0L, cmd3, cmd4, cmd5); } /// Prepare for redo of any command with extra count after "cmd2". -void prep_redo_num2(int regname, long num1, int cmd1, int cmd2, long num2, int cmd3, int cmd4, +void prep_redo_num2(int regname, int num1, int cmd1, int cmd2, int num2, int cmd3, int cmd4, int cmd5) { ResetRedobuff(); -- cgit From 8e932480f61d6101bf8bea1abc07ed93826221fd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/normal.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1a212661c5..f1bc46412f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1496,7 +1496,7 @@ static int normal_check(VimState *state) /// Set v:prevcount only when "set_prevcount" is true. static void set_vcount_ca(cmdarg_T *cap, bool *set_prevcount) { - long count = cap->count0; + int64_t count = cap->count0; // multiply with cap->opcount the same way as above if (cap->opcount != 0) { @@ -1856,7 +1856,7 @@ void clear_showcmd(void) if (VIsual_active && !char_avail()) { int cursor_bot = lt(VIsual, curwin->w_cursor); - long lines; + int lines; colnr_T leftcol, rightcol; linenr_T top, bot; @@ -2115,8 +2115,7 @@ void do_check_scrollbind(bool check) && (curwin->w_topline != old_topline || curwin->w_topfill != old_topfill || curwin->w_leftcol != old_leftcol)) { - check_scrollbind(curwin->w_topline - old_topline, - (long)(curwin->w_leftcol - old_leftcol)); + check_scrollbind(curwin->w_topline - old_topline, curwin->w_leftcol - old_leftcol); } } else if (vim_strchr(p_sbo, 'j')) { // jump flag set in 'scrollopt' // When switching between windows, make sure that the relative @@ -2142,7 +2141,7 @@ void do_check_scrollbind(bool check) /// Synchronize any windows that have "scrollbind" set, based on the /// number of rows by which the current window has changed /// (1998-11-02 16:21:01 R. Edward Ralston ) -void check_scrollbind(linenr_T topline_diff, long leftcol_diff) +void check_scrollbind(linenr_T topline_diff, int leftcol_diff) { bool want_ver; bool want_hor; @@ -2468,7 +2467,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar /// 'dist' must be positive. /// /// @return true if able to move cursor, false otherwise. -static bool nv_screengo(oparg_T *oap, int dir, long dist) +static bool nv_screengo(oparg_T *oap, int dir, int dist) { int linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); bool retval = true; @@ -2784,7 +2783,7 @@ static void nv_zet(cmdarg_T *cap) { colnr_T col; int nchar = cap->nchar; - long old_fdl = (long)curwin->w_p_fdl; + int old_fdl = (int)curwin->w_p_fdl; int old_fen = curwin->w_p_fen; int siso = get_sidescrolloff_value(curwin); -- cgit From af010e23f38a23bb74ea5b61e1b1a05e76410b5f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Fri, 13 Oct 2023 20:16:15 +0600 Subject: refactor(options): rename `empty_option` to `empty_string_option` --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f1bc46412f..1f2403450f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1878,8 +1878,8 @@ void clear_showcmd(void) char *const saved_w_sbr = curwin->w_p_sbr; // Make 'sbr' empty for a moment to get the correct size. - p_sbr = empty_option; - curwin->w_p_sbr = empty_option; + p_sbr = empty_string_option; + curwin->w_p_sbr = empty_string_option; getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol); p_sbr = saved_sbr; curwin->w_p_sbr = saved_w_sbr; -- cgit From ac353e87aecf02315d82a3ad22725d2bc8140f0c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 28 Oct 2023 10:42:18 +0800 Subject: vim-patch:9.0.2075: TextChangedI may not always trigger (#25808) Problem: TextChangedI may not always trigger Solution: trigger it in more cases: for insert/ append/change operations, and when opening a new line, fixes: vim/vim#13367 closes: vim/vim#13375 https://github.com/vim/vim/commit/4bca4897a12dfb91b3b27e3083fd5f370bd857d1 Co-authored-by: Christian Brabandt --- src/nvim/normal.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1f2403450f..93bbdd3be9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5724,6 +5724,8 @@ static void n_opencmd(cmdarg_T *cap) (void)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); if (u_save(curwin->w_cursor.lnum - (cap->cmdchar == 'O' ? 1 : 0), curwin->w_cursor.lnum + (cap->cmdchar == 'o' ? 1 : 0)) && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, @@ -6265,6 +6267,11 @@ static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln) // Always reset "restart_edit", this is not a restarted edit. restart_edit = 0; + // Reset Changedtick_i, so that TextChangedI will only be triggered for stuff + // from insert mode, for 'o/O' this has already been done in n_opencmd + if (cap->cmdchar != 'O' && cap->cmdchar != 'o') { + curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf); + } if (edit(cmd, startln, cap->count1)) { cap->retval |= CA_COMMAND_BUSY; } -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/normal.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 93bbdd3be9..54e1e49d97 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -695,9 +695,9 @@ static void normal_redraw_mode_message(NormalState *s) ui_cursor_shape(); // show different cursor shape ui_flush(); if (msg_scroll || emsg_on_display) { - os_delay(1003L, true); // wait at least one second + os_delay(1003, true); // wait at least one second } - os_delay(3003L, false); // wait up to three seconds + os_delay(3003, false); // wait up to three seconds State = save_State; msg_scroll = false; @@ -896,8 +896,8 @@ static bool normal_get_command_count(NormalState *s) if (s->c == K_DEL || s->c == K_KDEL) { s->ca.count0 /= 10; del_from_showcmd(4); // delete the digit and ~@% - } else if (s->ca.count0 > 99999999L) { - s->ca.count0 = 999999999L; + } else if (s->ca.count0 > 99999999) { + s->ca.count0 = 999999999; } else { s->ca.count0 = s->ca.count0 * 10 + (s->c - '0'); } @@ -1035,7 +1035,7 @@ normal_end: restart_VIsual_select = 0; } if (restart_edit != 0 && !VIsual_active && s->old_mapped_len == 0) { - (void)edit(restart_edit, false, 1L); + (void)edit(restart_edit, false, 1); } } @@ -1113,8 +1113,8 @@ static int normal_execute(VimState *state, int key) // If you give a count before AND after the operator, they are // multiplied. if (s->ca.count0) { - if (s->ca.opcount >= 999999999L / s->ca.count0) { - s->ca.count0 = 999999999L; + if (s->ca.opcount >= 999999999 / s->ca.count0) { + s->ca.count0 = 999999999; } else { s->ca.count0 *= s->ca.opcount; } @@ -1443,7 +1443,7 @@ static int normal_check(VimState *state) // Scroll-binding for diff mode may have been postponed until // here. Avoids doing it for every change. if (diff_need_scrollbind) { - check_scrollbind(0, 0L); + check_scrollbind(0, 0); diff_need_scrollbind = false; } @@ -1737,7 +1737,7 @@ static void prep_redo_cmd(cmdarg_T *cap) /// Note that only the last argument can be a multi-byte char. void prep_redo(int regname, int num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5) { - prep_redo_num2(regname, num, cmd1, cmd2, 0L, cmd3, cmd4, cmd5); + prep_redo_num2(regname, num, cmd1, cmd2, 0, cmd3, cmd4, cmd5); } /// Prepare for redo of any command with extra count after "cmd2". @@ -2126,7 +2126,7 @@ void do_check_scrollbind(bool check) // resync is performed, some of the other 'scrollbind' windows may // need to jump so that the current window's relative position is // visible on-screen. - check_scrollbind(curwin->w_topline - (linenr_T)curwin->w_scbind_pos, 0L); + check_scrollbind(curwin->w_topline - (linenr_T)curwin->w_scbind_pos, 0); } curwin->w_scbind_pos = curwin->w_topline; } @@ -2364,7 +2364,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar // With "gD" go to line 1. // With "gd" Search back for the start of the current function, then go // back until a blank line. If this fails go to line 1. - if (!locally || !findpar(&incll, BACKWARD, 1L, '{', false)) { + if (!locally || !findpar(&incll, BACKWARD, 1, '{', false)) { setpcmark(); // Set in findpar() otherwise curwin->w_cursor.lnum = 1; par_pos = curwin->w_cursor; @@ -2381,7 +2381,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar clearpos(&found_pos); while (true) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, - pat, 1L, searchflags, RE_LAST, NULL); + pat, 1, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { t = false; // match after start is failure too } @@ -2648,13 +2648,13 @@ void scroll_redraw(int up, linenr_T count) && curwin->w_topfill == prev_topfill) { if (up) { if (curwin->w_cursor.lnum > prev_lnum - || cursor_down(1L, false) == false) { + || cursor_down(1, false) == false) { break; } } else { if (curwin->w_cursor.lnum < prev_lnum - || prev_topline == 1L - || cursor_up(1L, false) == false) { + || prev_topline == 1 + || cursor_up(1, false) == false) { break; } } @@ -3211,7 +3211,7 @@ static void nv_colon(cmdarg_T *cap) stuffcharReadbuff('.'); if (cap->count0 > 1) { stuffReadbuff(",.+"); - stuffnumReadbuff(cap->count0 - 1L); + stuffnumReadbuff(cap->count0 - 1); } } @@ -4781,7 +4781,7 @@ static void n_swapchar(cmdarg_T *cap) curwin->w_set_curswant = true; if (did_change) { changed_lines(curbuf, startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, - 0L, true); + 0, true); curbuf->b_op_start = startpos; curbuf->b_op_end = curwin->w_cursor; if (curbuf->b_op_end.col > 0) { @@ -5568,7 +5568,7 @@ static void nv_g_cmd(cmdarg_T *cap) // "gs": Goto sleep. case 's': - do_sleep(cap->count1 * 1000L); + do_sleep(cap->count1 * 1000); break; // "ga": Display the ascii value of the character under the @@ -5870,7 +5870,7 @@ static void set_op_var(int optype) static void nv_lineop(cmdarg_T *cap) { cap->oap->motion_type = kMTLineWise; - if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == false) { + if (cursor_down(cap->count1 - 1, cap->oap->op_type == OP_NOP) == false) { clearopbeep(cap->oap); } else if ((cap->oap->op_type == OP_DELETE // only with linewise motions @@ -6083,7 +6083,7 @@ static void nv_goto(cmdarg_T *cap) if (cap->arg) { lnum = curbuf->b_ml.ml_line_count; } else { - lnum = 1L; + lnum = 1; } cap->oap->motion_type = kMTLineWise; setpcmark(); @@ -6092,8 +6092,8 @@ static void nv_goto(cmdarg_T *cap) if (cap->count0 != 0) { lnum = cap->count0; } - if (lnum < 1L) { - lnum = 1L; + if (lnum < 1) { + lnum = 1; } else if (lnum > curbuf->b_ml.ml_line_count) { lnum = curbuf->b_ml.ml_line_count; } -- cgit From cd63a9addd6e1114c3524fa041ece560550cfe7b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 10 Nov 2023 08:39:21 +0800 Subject: refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959) When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer. --- 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 54e1e49d97..418097a82a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4232,7 +4232,7 @@ static void nv_brackets(cmdarg_T *cap) clearop(cap->oap); } else { // Make a copy, if the line was changed it will be freed. - ptr = xstrnsave(ptr, len); + ptr = xmemdupz(ptr, len); find_pattern_in_path(ptr, 0, len, true, cap->count0 == 0 ? !isupper(cap->nchar) : false, (((cap->nchar & 0xf) == ('d' & 0xf)) -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- 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 418097a82a..f0f3d35468 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // // normal.c: Contains the main routine for processing characters in command // mode. Communicates closely with the code in ops.c to handle @@ -1712,7 +1709,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text col = 0; // Search for point of changing multibyte character class. this_class = mb_get_class(ptr); - while (ptr[col] != NUL // -V781 + while (ptr[col] != NUL && ((i == 0 ? mb_get_class(ptr + col) == this_class : mb_get_class(ptr + col) != 0) -- cgit From 016c6fae2740781a4c62f382673de1f86732533a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Nov 2023 07:11:56 +0800 Subject: vim-patch:9.0.2109: [security]: overflow in nv_z_get_count Problem: [security]: overflow in nv_z_get_count Solution: break out, if count is too large When getting the count for a normal z command, it may overflow for large counts given. So verify, that we can safely store the result in a long. https://github.com/vim/vim/commit/58f9befca1fa172068effad7f2ea5a9d6a7b0cca Co-authored-by: Christian Brabandt --- src/nvim/normal.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f0f3d35468..a68d1098e5 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2695,6 +2695,10 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) if (nchar == K_DEL || nchar == K_KDEL) { n /= 10; } else if (ascii_isdigit(nchar)) { + if (n > INT_MAX / 10) { + clearopbeep(cap->oap); + break; + } n = n * 10 + (nchar - '0'); } else if (nchar == CAR) { win_setheight(n); -- cgit From 6952b1951b6a60df8d477279f4451094fb51c413 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Nov 2023 08:40:02 +0800 Subject: vim-patch:9.0.2107: [security]: FPE in adjust_plines_for_skipcol (#26082) Problem: [security]: FPE in adjust_plines_for_skipcol Solution: don't divide by zero, return zero Prevent a floating point exception when calculating w_skipcol (which can happen with a small window when the number option is set and cpo+=n). Add a test to verify https://github.com/vim/vim/commit/cb0b99f0672d8446585d26e998343dceca17d1ce Co-authored-by: Christian Brabandt --- src/nvim/normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a68d1098e5..38fdff95d7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2466,7 +2466,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar /// @return true if able to move cursor, false otherwise. static bool nv_screengo(oparg_T *oap, int dir, int dist) { - int linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); + int linelen = linetabsize(curwin, curwin->w_cursor.lnum); bool retval = true; bool atend = false; int col_off1; // margin offset for first screen line @@ -2530,7 +2530,7 @@ static bool nv_screengo(oparg_T *oap, int dir, int dist) } cursor_up_inner(curwin, 1); - linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); + linelen = linetabsize(curwin, curwin->w_cursor.lnum); if (linelen > width1) { int w = (((linelen - width1 - 1) / width2) + 1) * width2; assert(curwin->w_curswant <= INT_MAX - w); @@ -2563,7 +2563,7 @@ static bool nv_screengo(oparg_T *oap, int dir, int dist) if (curwin->w_curswant >= width1) { curwin->w_curswant -= width2; } - linelen = (int)linetabsize(curwin, curwin->w_cursor.lnum); + linelen = linetabsize(curwin, curwin->w_cursor.lnum); } } } @@ -5491,7 +5491,7 @@ static void nv_g_cmd(cmdarg_T *cap) case 'M': oap->motion_type = kMTCharWise; oap->inclusive = false; - i = (int)linetabsize(curwin, curwin->w_cursor.lnum); + i = linetabsize(curwin, curwin->w_cursor.lnum); if (cap->count0 > 0 && cap->count0 <= 100) { coladvance((colnr_T)(i * cap->count0 / 100)); } else { -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/normal.c | 77 +++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 51 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 38fdff95d7..c4ced7670d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -358,11 +358,9 @@ static int nv_max_linear; /// through the index in nv_cmd_idx[]. static int nv_compare(const void *s1, const void *s2) { - int c1, c2; - // The commands are sorted on absolute value. - c1 = nv_cmds[*(const int16_t *)s1].cmd_char; - c2 = nv_cmds[*(const int16_t *)s2].cmd_char; + int c1 = nv_cmds[*(const int16_t *)s1].cmd_char; + int c2 = nv_cmds[*(const int16_t *)s2].cmd_char; if (c1 < 0) { c1 = -c1; } @@ -400,9 +398,6 @@ void init_normal_cmds(void) /// @return -1 for invalid command. static int find_command(int cmdchar) { - int idx; - int top, bot; - // A multi-byte character is never a command. if (cmdchar >= 0x100) { return -1; @@ -422,9 +417,9 @@ static int find_command(int cmdchar) } // Perform a binary search. - bot = nv_max_linear + 1; - top = NV_CMDS_SIZE - 1; - idx = -1; + int bot = nv_max_linear + 1; + int top = NV_CMDS_SIZE - 1; + int idx = -1; while (bot <= top) { int i = (top + bot) / 2; int c = nv_cmds[nv_cmd_idx[i]].cmd_char; @@ -1994,13 +1989,11 @@ void add_to_showcmd_c(int c) /// Delete 'len' characters from the end of the shown command. static void del_from_showcmd(int len) { - int old_len; - if (!p_sc) { return; } - old_len = (int)strlen(showcmd_buf); + int old_len = (int)strlen(showcmd_buf); if (len > old_len) { len = old_len; } @@ -2140,8 +2133,6 @@ void do_check_scrollbind(bool check) /// (1998-11-02 16:21:01 R. Edward Ralston ) void check_scrollbind(linenr_T topline_diff, int leftcol_diff) { - bool want_ver; - bool want_hor; win_T *old_curwin = curwin; buf_T *old_curbuf = curbuf; int old_VIsual_select = VIsual_select; @@ -2151,9 +2142,9 @@ void check_scrollbind(linenr_T topline_diff, int leftcol_diff) linenr_T y; // check 'scrollopt' string for vertical and horizontal scroll options - want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); + bool want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); want_ver |= old_curwin->w_p_diff; - want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); + bool want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); // loop through the scrollbound windows and scroll accordingly VIsual_select = VIsual_active = 0; @@ -2334,27 +2325,23 @@ static bool is_ident(const char *line, int offset) /// @return fail when not found. bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_arg) { - char *pat; - pos_T old_pos; pos_T par_pos; pos_T found_pos; bool t; - bool save_p_ws; - bool save_p_scs; bool retval = true; bool incll; int searchflags = flags_arg; size_t patlen = len + 7; - pat = xmalloc(patlen); + char *pat = xmalloc(patlen); // Put "\V" before the pattern to avoid that the special meaning of "." // and "~" causes trouble. assert(patlen <= INT_MAX); snprintf(pat, patlen, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", (int)len, ptr); - old_pos = curwin->w_cursor; - save_p_ws = p_ws; - save_p_scs = p_scs; + pos_T old_pos = curwin->w_cursor; + bool save_p_ws = p_ws; + bool save_p_scs = p_scs; p_ws = false; // don't wrap around end of file now p_scs = false; // don't switch ignorecase off now @@ -3902,14 +3889,13 @@ static void nv_down(cmdarg_T *cap) /// Grab the file name under the cursor and edit it. static void nv_gotofile(cmdarg_T *cap) { - char *ptr; linenr_T lnum = -1; if (check_text_or_curbuf_locked(cap->oap)) { return; } - ptr = grab_file_name(cap->count1, &lnum); + char *ptr = grab_file_name(cap->count1, &lnum); if (ptr != NULL) { // do autowrite if necessary @@ -4206,13 +4192,12 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) /// cap->arg is BACKWARD for "[" and FORWARD for "]". static void nv_brackets(cmdarg_T *cap) { - pos_T old_pos; // cursor position before command int flag; int n; cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; - old_pos = curwin->w_cursor; + pos_T old_pos = curwin->w_cursor; // cursor position before command curwin->w_cursor.coladd = 0; // TODO(Unknown): don't do this for an error. // "[f" or "]f" : Edit file under the cursor (same as "gf") @@ -4478,7 +4463,6 @@ static void nv_kundo(cmdarg_T *cap) /// Handle the "r" command. static void nv_replace(cmdarg_T *cap) { - char *ptr; int had_ctrl_v; if (checkclearop(cap->oap)) { @@ -4541,7 +4525,7 @@ static void nv_replace(cmdarg_T *cap) } // Abort if not enough characters to replace. - ptr = get_cursor_pos_ptr(); + char *ptr = get_cursor_pos_ptr(); if (strlen(ptr) < (unsigned)cap->count1 || (mb_charlen(ptr) < cap->count1)) { clearopbeep(cap->oap); @@ -4633,11 +4617,10 @@ static void nv_replace(cmdarg_T *cap) /// 'O': same, but in block mode exchange left and right corners. static void v_swap_corners(int cmdchar) { - pos_T old_cursor; colnr_T left, right; if (cmdchar == 'O' && VIsual_mode == Ctrl_V) { - old_cursor = curwin->w_cursor; + pos_T old_cursor = curwin->w_cursor; getvcols(curwin, &old_cursor, &VIsual, &left, &right); curwin->w_cursor.lnum = VIsual.lnum; coladvance(left); @@ -4667,7 +4650,7 @@ static void v_swap_corners(int cmdchar) curwin->w_curswant = left; } } else { - old_cursor = curwin->w_cursor; + pos_T old_cursor = curwin->w_cursor; curwin->w_cursor = VIsual; VIsual = old_cursor; curwin->w_set_curswant = true; @@ -4738,8 +4721,6 @@ 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 n; - pos_T startpos; int did_change = 0; if (checkclearopq(cap->oap)) { @@ -4757,8 +4738,8 @@ static void n_swapchar(cmdarg_T *cap) return; } - startpos = curwin->w_cursor; - for (n = cap->count1; n > 0; n--) { + pos_T startpos = curwin->w_cursor; + for (int n = cap->count1; n > 0; n--) { did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); inc_cursor(); if (gchar_cursor() == NUL) { @@ -5759,10 +5740,9 @@ static void nv_dot(cmdarg_T *cap) static void nv_redo_or_register(cmdarg_T *cap) { if (VIsual_select && VIsual_active) { - int reg; // Get register name no_mapping++; - reg = plain_vgetc(); + int reg = plain_vgetc(); LANGMAP_ADJUST(reg, true); no_mapping--; @@ -5822,9 +5802,7 @@ static void nv_tilde(cmdarg_T *cap) /// The actual work is done by do_pending_operator(). static void nv_operator(cmdarg_T *cap) { - int op_type; - - op_type = get_op_type(cap->cmdchar, cap->nchar); + int op_type = get_op_type(cap->cmdchar, cap->nchar); if (bt_prompt(curbuf) && op_is_change(op_type) && !prompt_curpos_editable()) { @@ -6130,12 +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; - - no_reason = (cap->oap->op_type == OP_NOP - && cap->opcount == 0 - && cap->count0 == 0 - && cap->oap->regname == 0); + int 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) { @@ -6287,7 +6263,6 @@ static void nv_object(cmdarg_T *cap) { bool flag; bool include; - char *mps_save; if (cap->cmdchar == 'i') { include = false; // "ix" = inner object: exclude white space @@ -6295,7 +6270,7 @@ static void nv_object(cmdarg_T *cap) include = true; // "ax" = an object: include white space } // Make sure (), [], {} and <> are in 'matchpairs' - mps_save = curbuf->b_p_mps; + char *mps_save = curbuf->b_p_mps; curbuf->b_p_mps = "(:),{:},[:],<:>"; switch (cap->nchar) { -- cgit From a6e3d93421ba13c407a96fac9cc01fa41ec7ad98 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 16 Nov 2023 10:59:11 +0100 Subject: refactor: enable formatting for ternaries This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators. --- src/nvim/normal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index c4ced7670d..77ad6d0f89 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2613,9 +2613,9 @@ void scroll_redraw(int up, linenr_T count) int prev_topfill = curwin->w_topfill; linenr_T prev_lnum = curwin->w_cursor.lnum; - bool moved = up ? - scrollup(count, true) : - scrolldown(count, true); + bool moved = up + ? scrollup(count, true) + : scrolldown(count, true); if (get_scrolloff_value(curwin) > 0) { // Adjust the cursor position for 'scrolloff'. Mark w_topline as @@ -4225,9 +4225,9 @@ static void nv_brackets(cmdarg_T *cap) ? FIND_DEFINE : FIND_ANY), cap->count1, - (isupper(cap->nchar) ? ACTION_SHOW_ALL : - islower(cap->nchar) ? ACTION_SHOW : - ACTION_GOTO), + (isupper(cap->nchar) ? ACTION_SHOW_ALL + : islower(cap->nchar) ? ACTION_SHOW + : ACTION_GOTO), (cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : 1), @@ -6463,7 +6463,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) if (fix_indent) { dir = (cap->cmdchar == ']' && cap->nchar == 'p') - ? FORWARD : BACKWARD; + ? FORWARD : BACKWARD; flags |= PUT_FIXINDENT; } else { dir = (cap->cmdchar == 'P' -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- 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 77ad6d0f89..10463aacb7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -34,6 +34,7 @@ #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 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- 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 10463aacb7..503b3671fa 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -15,7 +15,7 @@ #include #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -42,7 +42,7 @@ #include "nvim/help.h" #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/mark.h" #include "nvim/mbyte.h" @@ -73,7 +73,7 @@ #include "nvim/textobject.h" #include "nvim/ui.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" typedef struct normal_state { -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- 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 503b3671fa..1f789dc153 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -40,7 +40,7 @@ #include "nvim/globals.h" #include "nvim/grid.h" #include "nvim/help.h" -#include "nvim/highlight_defs.h" +#include "nvim/highlight.h" #include "nvim/keycodes.h" #include "nvim/macros_defs.h" #include "nvim/mapping.h" -- cgit