From 97b82553e09b949cae90c6e755d218d5cdca8f12 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 22 Sep 2019 19:49:03 +0200 Subject: vim-patch:8.1.2052: using "x" before a closed fold may delete that fold Problem: Using "x" before a closed fold may delete that fold. Solution: Do not translate 'x' do "dl". (Christian Brabandt, closes vim/vim#4927) https://github.com/vim/vim/commit/7a9bd7c1e0ce1baf5a02daf36eeae3638aa315c7 --- 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 e7e6d2b365..ffdc8e23d7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6248,7 +6248,14 @@ static void nv_optrans(cmdarg_T *cap) if (cap->count0) { stuffnumReadbuff(cap->count0); } - stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); + // If on an empty line and using 'x' and "l" is included in the + // whichwrap option, do not delete the next line. + if (cap->cmdchar == 'x' && vim_strchr(p_ww, 'l') != NULL + && gchar_cursor() == NUL) { + stuffReadbuff((char *)"dd"); + } else { + stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); + } } cap->opcount = 0; } -- cgit From 6c3d34e4dfc7fd3f810dd78f9dec016540c13bda Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 22 Sep 2019 20:04:34 +0200 Subject: vim-patch:8.1.2059: fix for "x" deleting a fold has side effects Problem: Fix for "x" deleting a fold has side effects. Solution: Fix it where the fold is included. https://github.com/vim/vim/commit/56ebbabea1d8409ba67127b9674f6c714739c8e0 --- src/nvim/normal.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ffdc8e23d7..4dfde96e94 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1553,9 +1553,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (!VIsual_active) { if (hasFolding(oap->start.lnum, &oap->start.lnum, NULL)) oap->start.col = 0; - if (hasFolding(curwin->w_cursor.lnum, NULL, - &curwin->w_cursor.lnum)) + if ((curwin->w_cursor.col > 0 || oap->inclusive) + && hasFolding(curwin->w_cursor.lnum, NULL, + &curwin->w_cursor.lnum)) { curwin->w_cursor.col = (colnr_T)STRLEN(get_cursor_line_ptr()); + } } oap->end = curwin->w_cursor; curwin->w_cursor = oap->start; @@ -5125,14 +5127,10 @@ static void nv_right(cmdarg_T *cap) break; } else if (PAST_LINE) { curwin->w_set_curswant = true; - if (virtual_active()) + if (virtual_active()) { oneright(); - else { - if (has_mbyte) - curwin->w_cursor.col += - (*mb_ptr2len)(get_cursor_pos_ptr()); - else - ++curwin->w_cursor.col; + } else { + curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr()); } } } @@ -6248,14 +6246,7 @@ static void nv_optrans(cmdarg_T *cap) if (cap->count0) { stuffnumReadbuff(cap->count0); } - // If on an empty line and using 'x' and "l" is included in the - // whichwrap option, do not delete the next line. - if (cap->cmdchar == 'x' && vim_strchr(p_ww, 'l') != NULL - && gchar_cursor() == NUL) { - stuffReadbuff((char *)"dd"); - } else { - stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); - } + stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); } cap->opcount = 0; } -- cgit From 24c4d4e1258f8ca34eb581550776ef613c27a689 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Sep 2019 20:01:58 -0400 Subject: vim-patch:8.1.2072: "gk" moves to start of line instead of upwards Problem: "gk" moves to start of line instead of upwards. Solution: Fix off-by-one error. (Christian Brabandt, closes vim/vim#4969) https://github.com/vim/vim/commit/03ac52fc025790c474030ea556cec799400aa046 --- 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 4dfde96e94..d4065cc06e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3932,11 +3932,11 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) while (dist--) { if (dir == BACKWARD) { - if ((long)curwin->w_curswant >= width2) - /* move back within line */ + if (curwin->w_curswant > width2) { + // move back within line curwin->w_curswant -= width2; - else { - /* to previous line */ + } else { + // to previous line if (curwin->w_cursor.lnum == 1) { retval = false; break; -- cgit From 8d0bc3c18964db51fec4b204a122e946393f2d6d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Sep 2019 20:11:30 -0400 Subject: vim-patch:8.1.1758: count of g$ not used correctly when text is not wrapped Problem: Count of g$ not used correctly when text is not wrapped. Solution: Do use the count. (Christian Brabandt, closes vim/vim#4729, closes vim/vim#4566) https://github.com/vim/vim/commit/d5c8234517c18fa059b78f59eb96c35eda323dae --- src/nvim/normal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d4065cc06e..6b76082772 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6795,10 +6795,14 @@ static void nv_g_cmd(cmdarg_T *cap) } else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == false) clearopbeep(oap); } else { + if (cap->count1 > 1) { + // if it fails, let the cursor still move to the last char + cursor_down(cap->count1 - 1, false); + } i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1; coladvance((colnr_T)i); - /* Make sure we stick in this column. */ + // Make sure we stick in this column. validate_virtcol(); curwin->w_curswant = curwin->w_virtcol; curwin->w_set_curswant = false; -- cgit From 17e96d96bac4ea9074a337b263fe85d4755106b6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Sep 2019 22:53:20 -0400 Subject: vim-patch:8.1.0514: CTRL-W ^ does not work when alternate buffer has no name Problem: CTRL-W ^ does not work when alternate buffer has no name. Solution: Use another method to split and edit the alternate buffer. (Jason Franklin) https://github.com/vim/vim/commit/1bbb61948342b5cf6e363629f145c65eb455c388 --- src/nvim/normal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 6b76082772..e32b738c7e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4680,9 +4680,8 @@ static void nv_ctrlo(cmdarg_T *cap) } } -/* - * CTRL-^ command, short for ":e #" - */ +// CTRL-^ command, short for ":e #". Works even when the alternate buffer is +// not named. static void nv_hat(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) -- cgit From 0586a4b512b2495d32f20c46946d35a0d403bd52 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Mon, 23 Sep 2019 21:19:26 +0200 Subject: vim-patch:8.1.1588: in :let-heredoc line continuation is recognized Problem: In :let-heredoc line continuation is recognized. Solution: Do not consume line continuation. (Ozaki Kiichi, closes vim/vim#4580) https://github.com/vim/vim/commit/e96a2498f9a2d3e93ac07431f6d4afd77f30afdf --- 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 e32b738c7e..e0dc9d4f23 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5343,7 +5343,7 @@ static void nv_search(cmdarg_T *cap) // When using 'incsearch' the cursor may be moved to set a different search // start position. - cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0); + cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, true); if (cap->searchbuf == NULL) { clearop(oap); -- cgit From 0785f8e8b11b2fa290cfbc0604d570f49b954ba6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 17 Oct 2019 04:24:23 -0400 Subject: vim-patch:8.1.2140: "gk" and "gj" do not work correctly in number column #11208 Problem: "gk" and "gj" do not work correctly in number column. Solution: Allow for a negative "curswant". (Zach Wegner, closes vim/vim#4969) https://github.com/vim/vim/commit/ceba3dd5187788e09f65bd41b07b40f6f9aab953 --- src/nvim/normal.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e0dc9d4f23..d051ba33b8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3925,15 +3925,17 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else n = width1; - if (curwin->w_curswant > (colnr_T)n + 1) - curwin->w_curswant -= ((curwin->w_curswant - n) / width2 + 1) - * width2; + if (curwin->w_curswant >= n) { + curwin->w_curswant = n - 1; + } } while (dist--) { if (dir == BACKWARD) { - if (curwin->w_curswant > width2) { - // move back within line + if (curwin->w_curswant >= width1) { + // Move back within the line. This can give a negative value + // for w_curswant if width1 < width2 (with cpoptions+=n), + // which will get clipped to column 0. curwin->w_curswant -= width2; } else { // to previous line @@ -3973,6 +3975,13 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) } 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 + // to get a negative value for w_curswant, which will get + // clipped to column 0. + if (curwin->w_curswant >= width1) { + curwin->w_curswant -= width2; + } linelen = linetabsize(get_cursor_line_ptr()); } } -- cgit From 194f7bfacea934177d524197127242947bd28471 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 10 Oct 2019 22:06:45 +0100 Subject: vim-patch:8.1.1228: not possible to process tags with a function Problem: Not possible to process tags with a function. Solution: Add tagfunc() (Christian Brabandt, Andy Massimino, closes vim/vim#4010) https://github.com/vim/vim/commit/45e18cbdc40afd8144d20dcc07ad2d981636f4c9 --- 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 e0dc9d4f23..28183ffa1d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4929,7 +4929,9 @@ static void nv_ident(cmdarg_T *cap) add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL); (void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0); } else { + g_tag_at_cursor = true; do_cmdline_cmd(buf); + g_tag_at_cursor = false; } xfree(buf); -- cgit From 034077ed1c1fa71aa15829ed2dfb27de4a5e5359 Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Fri, 25 Oct 2019 19:54:53 +0900 Subject: vim-patch:8.1.2173: searchit() has too many arguments Problem: Searchit() has too many arguments. Solution: Move optional arguments to a struct. Add the "wrapped" argument. https://github.com/vim/vim/commit/92ea26b925a0835badb0af2d5887238a4198cabb --- src/nvim/normal.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f6222f9d3f..d1c6362931 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3794,7 +3794,7 @@ find_decl ( valid = false; (void)valid; // Avoid "dead assignment" warning. t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, - pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL); + pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { t = false; // match after start is failure too } @@ -4936,7 +4936,8 @@ static void nv_ident(cmdarg_T *cap) /* put pattern in search history */ init_history(); add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL); - (void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0); + (void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0, + NULL); } else { g_tag_at_cursor = true; do_cmdline_cmd(buf); @@ -5363,7 +5364,7 @@ static void nv_search(cmdarg_T *cap) (void)normal_search(cap, cap->cmdchar, cap->searchbuf, (cap->arg || !equalpos(save_cursor, curwin->w_cursor)) - ? 0 : SEARCH_MARK); + ? 0 : SEARCH_MARK, NULL); } /* @@ -5373,14 +5374,15 @@ static void nv_search(cmdarg_T *cap) static void nv_next(cmdarg_T *cap) { pos_T old = curwin->w_cursor; - int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); + int wrapped = false; + int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped); - if (i == 1 && equalpos(old, curwin->w_cursor)) { + if (i == 1 && !wrapped && equalpos(old, curwin->w_cursor)) { // Avoid getting stuck on the current cursor position, which can happen when // an offset is given and the cursor is on the last char in the buffer: // Repeat with count + 1. cap->count1 += 1; - (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); + (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); cap->count1 -= 1; } } @@ -5394,18 +5396,24 @@ static int normal_search( cmdarg_T *cap, int dir, char_u *pat, - int opt /* extra flags for do_search() */ + int opt, // extra flags for do_search() + int *wrapped ) { int i; + searchit_arg_T sia; cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; cap->oap->use_reg_one = true; curwin->w_set_curswant = true; + memset(&sia, 0, sizeof(sia)); i = do_search(cap->oap, dir, pat, cap->count1, - opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL); + opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); + if (wrapped != NULL) { + *wrapped = sia.sa_wrapped; + } if (i == 0) { clearop(cap->oap); } else { -- cgit From 471427d045f74fa9d2e47b2975ef178e719c2ae8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 1 Nov 2019 00:43:20 -0400 Subject: vim-patch:8.1.2231: introduce gM command #11321 Problem: Not easy to move to the middle of a text line. Solution: Add the gM command. (Yasuhiro Matsumoto, closes vim/vim#2070) https://github.com/vim/vim/commit/8b530c1ff91f07cf6b0289a536992b7dfbc86598 --- src/nvim/normal.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d1c6362931..2ef2c3101f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6749,6 +6749,22 @@ static void nv_g_cmd(cmdarg_T *cap) curwin->w_set_curswant = true; break; + case 'M': + { + const char_u *const ptr = get_cursor_line_ptr(); + + oap->motion_type = kMTCharWise; + oap->inclusive = false; + i = (int)mb_string2cells_len(ptr, STRLEN(ptr)); + if (cap->count0 > 0 && cap->count0 <= 100) { + coladvance((colnr_T)(i * cap->count0 / 100)); + } else { + coladvance((colnr_T)(i / 2)); + } + curwin->w_set_curswant = true; + } + break; + case '_': /* "g_": to the last non-blank character in the line or lines * downward. */ -- cgit From fd5710ae9a3bcbc0f9cbb71de9e39253350ff09c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 25 Nov 2019 01:08:02 -0800 Subject: doc + extmarks tweaks #11421 - nvim_buf_get_extmarks: rename "amount" => "limit" - rename `set_extmark_index_from_obj` --- src/nvim/normal.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2ef2c3101f..b9dbcc6805 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1422,12 +1422,12 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (oap->motion_type == kMTLineWise) { oap->inclusive = false; } else if (oap->motion_type == kMTCharWise) { - // If the motion already was characterwise, toggle "inclusive" + // If the motion already was charwise, toggle "inclusive" oap->inclusive = !oap->inclusive; } oap->motion_type = kMTCharWise; } else if (oap->motion_force == Ctrl_V) { - // Change line- or characterwise motion into Visual block mode. + // Change line- or charwise motion into Visual block mode. if (!VIsual_active) { VIsual_active = true; VIsual = oap->start; @@ -1516,7 +1516,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) } // In Select mode, a linewise selection is operated upon like a - // characterwise selection. + // charwise selection. // Special case: gH deletes the last line. if (VIsual_select && VIsual_mode == 'V' && cap->oap->op_type != OP_DELETE) { @@ -4588,7 +4588,7 @@ static void nv_colon(cmdarg_T *cap) nv_operator(cap); } else { if (cap->oap->op_type != OP_NOP) { - // Using ":" as a movement is characterwise exclusive. + // Using ":" as a movement is charwise exclusive. cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; } else if (cap->count0 && !is_cmdkey) { @@ -6372,8 +6372,8 @@ static void nv_visual(cmdarg_T *cap) if (cap->cmdchar == Ctrl_Q) cap->cmdchar = Ctrl_V; - /* 'v', 'V' and CTRL-V can be used while an operator is pending to make it - * characterwise, linewise, or blockwise. */ + // 'v', 'V' and CTRL-V can be used while an operator is pending to make it + // charwise, linewise, or blockwise. if (cap->oap->op_type != OP_NOP) { motion_force = cap->oap->motion_force = cap->cmdchar; finish_op = false; // operator doesn't finish now but later @@ -7887,15 +7887,17 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) cap->oap->regname = regname; } - /* When deleted a linewise Visual area, put the register as - * lines to avoid it joined with the next line. When deletion was - * characterwise, split a line when putting lines. */ - if (VIsual_mode == 'V') + // When deleted a linewise Visual area, put the register as + // lines to avoid it joined with the next line. When deletion was + // charwise, split a line when putting lines. + if (VIsual_mode == 'V') { flags |= PUT_LINE; - else if (VIsual_mode == 'v') + } else if (VIsual_mode == 'v') { flags |= PUT_LINE_SPLIT; - if (VIsual_mode == Ctrl_V && dir == FORWARD) + } + if (VIsual_mode == Ctrl_V && dir == FORWARD) { flags |= PUT_LINE_FORWARD; + } dir = BACKWARD; if ((VIsual_mode != 'V' && curwin->w_cursor.col < curbuf->b_op_start.col) -- cgit From 63cd5dd0ae3e079e0b69382f905637978a1e2300 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 13 Dec 2019 21:17:57 -0500 Subject: vim-patch:8.2.0002: "dj" only deletes first line of closed fold Problem: "dj" only deletes first line of closed fold. Solution: Adjust last line of operator for linewise motion. (closes vim/vim#5354) https://github.com/vim/vim/commit/3b68123cd271fb781da4055cf1a1cf52f4fee6a5 --- 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 b9dbcc6805..9c5434a0dd 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1553,7 +1553,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (!VIsual_active) { if (hasFolding(oap->start.lnum, &oap->start.lnum, NULL)) oap->start.col = 0; - if ((curwin->w_cursor.col > 0 || oap->inclusive) + if ((curwin->w_cursor.col > 0 + || oap->inclusive + || oap->motion_type == kMTLineWise) && hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) { curwin->w_cursor.col = (colnr_T)STRLEN(get_cursor_line_ptr()); -- cgit From 78aa41354ea9b6bb2d6ce750f02f0f8b3d7d4418 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 30 Dec 2019 00:47:32 -0500 Subject: vim-patch:8.1.2377: GUI: when losing focus a pending operator is executed Problem: GUI: when losing focus a pending operator is executed. Solution: Do not execute an operator when getting K_IGNORE. (closes vim/vim#5300) https://github.com/vim/vim/commit/fa5612c7d836eb789e0f8ff4b10461b8640a14b2 --- 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 9c5434a0dd..9c707a6fdc 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -874,8 +874,10 @@ static void normal_finish_command(NormalState *s) s->old_mapped_len = typebuf_maplen(); } - // If an operation is pending, handle it... - do_pending_operator(&s->ca, s->old_col, false); + // If an operation is pending, handle it. But not for K_IGNORE. + if (s->ca.cmdchar != K_IGNORE) { + do_pending_operator(&s->ca, s->old_col, false); + } // Wait for a moment when a message is displayed that will be overwritten // by the mode message. -- cgit From cbc8d72fde4b19176028490934ff7a447afe523c Mon Sep 17 00:00:00 2001 From: butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Thu, 2 Jan 2020 06:06:11 -0800 Subject: tabpage: track last-used tabpage #11626 In a multi-window scenario, it is possible to return focus to the last accessed window via n_CTRL-W_p. However, in the case of a multi-tab scenario, there was previously no way to return focus to the last accessed *tab*. Here, that ability is added via n_g. Additionally, the index of the previous tab is exposed via tabpagenr('#'), mirroring the existing functionality of winnr('#'). --- src/nvim/normal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9c707a6fdc..d0b9fd4589 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6312,9 +6312,7 @@ static void nv_gomark(cmdarg_T *cap) } } -/* - * Handle CTRL-O, CTRL-I, "g;" and "g," commands. - */ +// Handle CTRL-O, CTRL-I, "g;", "g,", and "CTRL-Tab" commands. static void nv_pcmark(cmdarg_T *cap) { pos_T *pos; @@ -6322,11 +6320,16 @@ static void nv_pcmark(cmdarg_T *cap) const bool old_KeyTyped = KeyTyped; // getting file may reset it if (!checkclearopq(cap->oap)) { - if (cap->cmdchar == 'g') + if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) { + goto_tabpage_lastused(); + return; + } + if (cap->cmdchar == 'g') { pos = movechangelist((int)cap->count1); - else + } else { pos = movemark((int)cap->count1); - if (pos == (pos_T *)-1) { /* jump to other file */ + } + if (pos == (pos_T *)-1) { // jump to other file curwin->w_set_curswant = true; check_cursor(); } else if (pos != NULL) /* can jump */ @@ -7059,6 +7062,11 @@ static void nv_g_cmd(cmdarg_T *cap) if (!checkclearop(oap)) goto_tabpage(-(int)cap->count1); break; + case TAB: + if (!checkclearop(oap)) { + goto_tabpage_lastused(); + } + break; case '+': case '-': /* "g+" and "g-": undo or redo along the timeline */ -- cgit From 45759e44f9cff9deef1538933fad3e42f94d5930 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 8 Jan 2020 01:08:55 -0500 Subject: Remove (void) hacks, Mark unused attrs --- 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 d0b9fd4589..3aff3cef84 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3760,7 +3760,6 @@ find_decl ( bool retval = true; bool incll; int searchflags = flags_arg; - bool valid; pat = xmalloc(len + 7); @@ -3795,8 +3794,6 @@ find_decl ( /* Search forward for the identifier, ignore comment lines. */ clearpos(&found_pos); for (;; ) { - valid = false; - (void)valid; // Avoid "dead assignment" warning. t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { @@ -3831,7 +3828,7 @@ find_decl ( curwin->w_cursor.col = 0; continue; } - valid = is_ident(get_cursor_line_ptr(), curwin->w_cursor.col); + bool valid = is_ident(get_cursor_line_ptr(), curwin->w_cursor.col); // If the current position is not a valid identifier and a previous match is // present, favor that one instead. -- cgit From e22d0cf12c985e670fcc562a6ce75e82a0b3a741 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 23 Jan 2020 19:36:39 -0500 Subject: vim-patch:8.2.0147: block Visual mode operators not correct when 'linebreak' set Problem: Block Visual mode operators not correct when 'linebreak' set. Solution: Set w_p_lbr to lbr_saved more often. (Ken Takata, closes vim/vim#5524) https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053 --- src/nvim/normal.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3aff3cef84..be6819d19f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1846,10 +1846,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) restart_edit = 0; // Restore linebreak, so that when the user edits it looks as before. - if (curwin->w_p_lbr != lbr_saved) { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, false); - } + curwin->w_p_lbr = lbr_saved; // Reset finish_op now, don't want it set inside edit(). finish_op = false; @@ -1935,10 +1932,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) restart_edit = 0; // Restore linebreak, so that when the user edits it looks as before. - if (curwin->w_p_lbr != lbr_saved) { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, false); - } + curwin->w_p_lbr = lbr_saved; op_insert(oap, cap->count1); @@ -1964,10 +1958,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) CancelRedo(); } else { // Restore linebreak, so that when the user edits it looks as before. - if (curwin->w_p_lbr != lbr_saved) { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, false); - } + curwin->w_p_lbr = lbr_saved; op_replace(oap, cap->nchar); } -- cgit From 94ad6652f11e1d6791292d0a2bf2d777ddeefbcc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 24 Jan 2020 23:40:47 -0500 Subject: Remove enc_utf8,has_mbyte dead code --- src/nvim/normal.c | 161 ++++++++++++++++++++---------------------------------- 1 file changed, 60 insertions(+), 101 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index be6819d19f..dac4c8f527 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -760,7 +760,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 (enc_utf8 && lang && (s->c = vpeekc()) > 0 + while (lang && (s->c = vpeekc()) > 0 && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { s->c = plain_vgetc(); if (!utf_iscomposing(s->c)) { @@ -1711,13 +1711,12 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) } } - /* Include the trailing byte of a multi-byte char. */ - if (has_mbyte && oap->inclusive) { - int l; - - l = (*mb_ptr2len)(ml_get_pos(&oap->end)); - if (l > 1) + // Include the trailing byte of a multi-byte char. + if (oap->inclusive) { + const int l = utfc_ptr2len(ml_get_pos(&oap->end)); + if (l > 1) { oap->end.col += l - 1; + } } curwin->w_set_curswant = true; @@ -2897,17 +2896,17 @@ static void find_end_of_word(pos_T *pos) */ static int get_mouse_class(char_u *p) { - int c; - - if (has_mbyte && MB_BYTE2LEN(p[0]) > 1) + if (MB_BYTE2LEN(p[0]) > 1) { return mb_get_class(p); + } - c = *p; - if (c == ' ' || c == '\t') + const int c = *p; + if (c == ' ' || c == '\t') { return 0; - - if (vim_iswordc(c)) + } + if (vim_iswordc(c)) { return 2; + } /* * There are a few special cases where we want certain combinations of @@ -4907,10 +4906,9 @@ static void nv_ident(cmdarg_T *cap) *p++ = '\\'; /* When current byte is a part of multibyte character, copy all * bytes of that character. */ - if (has_mbyte) { - size_t len = (size_t)((*mb_ptr2len)(ptr) - 1); - for (size_t i = 0; i < len && n > 0; ++i, --n) - *p++ = *ptr++; + const size_t len = (size_t)(utfc_ptr2len(ptr) - 1); + for (size_t i = 0; i < len && n > 0; i++, n--) { + *p++ = *ptr++; } *p++ = *ptr++; } @@ -4921,11 +4919,11 @@ static void nv_ident(cmdarg_T *cap) * Execute the command. */ if (cmdchar == '*' || cmdchar == '#') { - if (!g_cmd && ( - has_mbyte ? vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr)) : - vim_iswordc(ptr[-1]))) + if (!g_cmd + && vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr))) { STRCAT(buf, "\\>"); - /* put pattern in search history */ + } + // put pattern in search history init_history(); add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL); (void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0, @@ -4968,9 +4966,8 @@ get_visual_text ( *pp = ml_get_pos(&VIsual); *lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1; } - if (has_mbyte) - /* Correct the length to include the whole last character. */ - *lenp += (size_t)((*mb_ptr2len)(*pp + (*lenp - 1)) - 1); + // Correct the length to include the whole last character. + *lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1); } reset_VIsual_and_resel(); return true; @@ -5188,11 +5185,7 @@ static void nv_left(cmdarg_T *cap) char_u *cp = get_cursor_pos_ptr(); if (*cp != NUL) { - if (has_mbyte) { - curwin->w_cursor.col += (*mb_ptr2len)(cp); - } else { - curwin->w_cursor.col++; - } + curwin->w_cursor.col += utfc_ptr2len(cp); } cap->retval |= CA_NO_ADJ_OP_END; } @@ -5850,7 +5843,6 @@ static void nv_replace(cmdarg_T *cap) { char_u *ptr; int had_ctrl_v; - long n; if (checkclearop(cap->oap)) return; @@ -5904,7 +5896,7 @@ static void nv_replace(cmdarg_T *cap) /* Abort if not enough characters to replace. */ ptr = get_cursor_pos_ptr(); if (STRLEN(ptr) < (unsigned)cap->count1 - || (has_mbyte && mb_charlen(ptr) < cap->count1) + || (mb_charlen(ptr) < cap->count1) ) { clearopbeep(cap->oap); return; @@ -5946,71 +5938,44 @@ static void nv_replace(cmdarg_T *cap) NUL, 'r', NUL, had_ctrl_v, cap->nchar); curbuf->b_op_start = curwin->w_cursor; - if (has_mbyte) { - int old_State = State; - - if (cap->ncharC1 != 0) - AppendCharToRedobuff(cap->ncharC1); - if (cap->ncharC2 != 0) - AppendCharToRedobuff(cap->ncharC2); - - /* 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 (n = cap->count1; n > 0; --n) { - State = REPLACE; - if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { - int c = ins_copychar(curwin->w_cursor.lnum - + (cap->nchar == Ctrl_Y ? -1 : 1)); - if (c != NUL) - ins_char(c); - else - /* will be decremented further down */ - ++curwin->w_cursor.col; - } else - ins_char(cap->nchar); - State = old_State; - if (cap->ncharC1 != 0) - ins_char(cap->ncharC1); - if (cap->ncharC2 != 0) - ins_char(cap->ncharC2); - } - } else { - /* - * Replace the characters within one line. - */ - for (n = cap->count1; n > 0; --n) { - /* - * Get ptr again, because u_save and/or showmatch() will have - * released the line. At the same time we let know that the - * line will be changed. - */ - ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true); - if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { - int c = ins_copychar(curwin->w_cursor.lnum - + (cap->nchar == Ctrl_Y ? -1 : 1)); - if (c != NUL) { - assert(c >= 0 && c <= UCHAR_MAX); - ptr[curwin->w_cursor.col] = (char_u)c; - } + const int old_State = State; + + if (cap->ncharC1 != 0) { + AppendCharToRedobuff(cap->ncharC1); + } + if (cap->ncharC2 != 0) { + AppendCharToRedobuff(cap->ncharC2); + } + + // 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--) { + State = REPLACE; + if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { + int c = ins_copychar(curwin->w_cursor.lnum + + (cap->nchar == Ctrl_Y ? -1 : 1)); + if (c != NUL) { + ins_char(c); } else { - assert(cap->nchar >= 0 && cap->nchar <= UCHAR_MAX); - ptr[curwin->w_cursor.col] = (char_u)cap->nchar; + // will be decremented further down + curwin->w_cursor.col++; } - if (p_sm && msg_silent == 0) - showmatch(cap->nchar); - ++curwin->w_cursor.col; + } else { + ins_char(cap->nchar); + } + State = old_State; + if (cap->ncharC1 != 0) { + ins_char(cap->ncharC1); + } + if (cap->ncharC2 != 0) { + ins_char(cap->ncharC2); } - - /* mark the buffer as changed and prepare for displaying */ - changed_bytes(curwin->w_cursor.lnum, - (colnr_T)(curwin->w_cursor.col - cap->count1)); } --curwin->w_cursor.col; /* cursor on the last replaced char */ /* if the character on the left of the current cursor is a multi-byte * character, move two characters left */ - if (has_mbyte) - mb_adjust_cursor(); + mb_adjust_cursor(); curbuf->b_op_end = curwin->w_cursor; curwin->w_set_curswant = true; set_last_insert(cap->nchar); @@ -7356,10 +7321,9 @@ static void adjust_cursor(oparg_T *oap) && (!VIsual_active || *p_sel == 'o') && !virtual_active() && (ve_flags & VE_ONEMORE) == 0 ) { - --curwin->w_cursor.col; - /* prevent cursor from moving on the trail byte */ - if (has_mbyte) - mb_adjust_cursor(); + curwin->w_cursor.col--; + // prevent cursor from moving on the trail byte + mb_adjust_cursor(); oap->inclusive = true; } } @@ -7386,10 +7350,7 @@ static void adjust_for_sel(cmdarg_T *cap) { if (VIsual_active && cap->oap->inclusive && *p_sel == 'e' && gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor)) { - if (has_mbyte) - inc_cursor(); - else - ++curwin->w_cursor.col; + inc_cursor(); cap->oap->inclusive = false; } } @@ -7979,9 +7940,7 @@ static void get_op_vcol( oap->motion_type = kMTBlockWise; // prevent from moving onto a trail byte - if (has_mbyte) { - mark_mb_adjustpos(curwin->w_buffer, &oap->end); - } + mark_mb_adjustpos(curwin->w_buffer, &oap->end); getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol); if (!redo_VIsual_busy) { -- cgit From 4813ad48cd12a03ca50c01ac1b20518bf4df57f2 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 20 May 2019 11:57:45 +0900 Subject: vim-patch:8.1.0027: difficult to make a plugin that feeds a line to a job Problem: Difficult to make a plugin that feeds a line to a job. Solution: Add the nitial code for the "prompt" buftype. https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787 --- src/nvim/normal.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 9 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index dac4c8f527..c69b10f99a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3642,7 +3642,9 @@ static void nv_help(cmdarg_T *cap) */ static void nv_addsub(cmdarg_T *cap) { - if (!VIsual_active && cap->oap->op_type == OP_NOP) { + if (bt_prompt(curbuf) && !prompt_curpos_editable()) { + clearopbeep(cap->oap); + } 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, cap->count1, cap->arg); @@ -5239,6 +5241,13 @@ static void nv_down(cmdarg_T *cap) // In the cmdline window a executes the command. if (cmdwin_type != 0 && cap->cmdchar == CAR) { cmdwin_result = CAR; + } else if (bt_prompt(curbuf) && cap->cmdchar == CAR + && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) { + // In a prompt buffer a in the last line invokes the callback. + invoke_prompt_callback(); + if (restart_edit == 0) { + restart_edit = 'a'; + } } else { cap->oap->motion_type = kMTLineWise; if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == false) { @@ -5831,6 +5840,10 @@ static void nv_undo(cmdarg_T *cap) static void nv_kundo(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) { + if (bt_prompt(curbuf)) { + clearopbeep(cap->oap); + return; + } u_undo((int)cap->count1); curwin->w_set_curswant = true; } @@ -5844,8 +5857,13 @@ static void nv_replace(cmdarg_T *cap) char_u *ptr; int had_ctrl_v; - if (checkclearop(cap->oap)) + if (checkclearop(cap->oap)) { + return; + } + if (bt_prompt(curbuf) && !prompt_curpos_editable()) { + clearopbeep(cap->oap); return; + } /* get another character */ if (cap->nchar == Ctrl_V) { @@ -6182,7 +6200,11 @@ static void v_visop(cmdarg_T *cap) */ static void nv_subst(cmdarg_T *cap) { - if (VIsual_active) { /* "vs" and "vS" are the same as "vc" */ + if (bt_prompt(curbuf) && !prompt_curpos_editable()) { + clearopbeep(cap->oap); + return; + } + if (VIsual_active) { // "vs" and "vS" are the same as "vc" if (cap->cmdchar == 'S') { VIsual_mode_orig = VIsual_mode; VIsual_mode = 'V'; @@ -7120,10 +7142,15 @@ static void nv_tilde(cmdarg_T *cap) { if (!p_to && !VIsual_active - && cap->oap->op_type != OP_TILDE) + && cap->oap->op_type != OP_TILDE) { + if (bt_prompt(curbuf) && !prompt_curpos_editable()) { + clearopbeep(cap->oap); + return; + } n_swapchar(cap); - else + } else { nv_operator(cap); + } } /* @@ -7136,6 +7163,12 @@ static void nv_operator(cmdarg_T *cap) op_type = get_op_type(cap->cmdchar, cap->nchar); + if (bt_prompt(curbuf) && op_is_change(op_type) + && !prompt_curpos_editable()) { + clearopbeep(cap->oap); + return; + } + if (op_type == cap->oap->op_type) /* double operator works on lines */ nv_lineop(cap); else if (!checkclearop(cap->oap)) { @@ -7796,8 +7829,11 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) clearop(cap->oap); assert(cap->opcount >= 0); nv_diffgetput(true, (size_t)cap->opcount); - } else + } else { clearopbeep(cap->oap); + } + } else if (bt_prompt(curbuf) && !prompt_curpos_editable()) { + clearopbeep(cap->oap); } else { if (fix_indent) { dir = (cap->cmdchar == ']' && cap->nchar == 'p') @@ -7809,8 +7845,9 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) ? BACKWARD : FORWARD; } prep_redo_cmd(cap); - if (cap->cmdchar == 'g') + if (cap->cmdchar == 'g') { flags |= PUT_CURSEND; + } if (VIsual_active) { /* Putting in Visual mode: The put text replaces the selected @@ -7916,10 +7953,14 @@ static void nv_open(cmdarg_T *cap) clearop(cap->oap); assert(cap->opcount >= 0); nv_diffgetput(false, (size_t)cap->opcount); - } else if (VIsual_active) /* switch start and end of visual */ + } else if (VIsual_active) { + // switch start and end of visual/ v_swap_corners(cap->cmdchar); - else + } else if (bt_prompt(curbuf)) { + clearopbeep(cap->oap); + } else { n_opencmd(cap); + } } // Calculate start/end virtual columns for operating in block mode. -- cgit From d50c1123d5616c9757bb5707416696cda1a43716 Mon Sep 17 00:00:00 2001 From: Jakub Łuczyński Date: Mon, 10 Feb 2020 18:34:18 +0100 Subject: fix: includes --- 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 c69b10f99a..4a9186f7f6 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -24,7 +24,7 @@ #include "nvim/diff.h" #include "nvim/digraph.h" #include "nvim/edit.h" -#include "nvim/eval.h" +#include "nvim/eval/user_funcs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" -- cgit From 5e815edece308a91296720cd6cb8d988af6c90c8 Mon Sep 17 00:00:00 2001 From: Jakub Łuczyński Date: Tue, 11 Feb 2020 16:19:14 +0100 Subject: rename: user_funcs -> userfunc Lets stick with vim for now --- 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 4a9186f7f6..c53348db0d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -24,7 +24,7 @@ #include "nvim/diff.h" #include "nvim/digraph.h" #include "nvim/edit.h" -#include "nvim/eval/user_funcs.h" +#include "nvim/eval/userfunc.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" -- cgit From 1a2be57da3f7e33af4e4eb3e0d36569feea71253 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 14 Jan 2020 19:50:30 +0100 Subject: foldcolumn: allow auto:X Similar to signcolumn, allow foldcolumn to adapt itself to the number of folds. Regression: vim supports a maximum fdc of 12, this limits it to 9. --- 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 c69b10f99a..6434bd00d8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4458,16 +4458,16 @@ dozet: case 'r': curwin->w_p_fdl += cap->count1; { - int d = getDeepestNesting(); + int d = getDeepestNesting(curwin); if (curwin->w_p_fdl >= d) { curwin->w_p_fdl = d; } } break; - /* "zR": open all folds */ - case 'R': curwin->w_p_fdl = getDeepestNesting(); - old_fdl = -1; /* force an update */ + case 'R': // "zR": open all folds + curwin->w_p_fdl = getDeepestNesting(curwin); + old_fdl = -1; // force an update break; case 'j': /* "zj" move to next fold downwards */ -- cgit From 87d892afa0475644e91d9c8a57b7c35491c4dc32 Mon Sep 17 00:00:00 2001 From: Will Eccles Date: Tue, 17 Mar 2020 15:05:34 -0400 Subject: vim-patch:8.1.0864 Make 'scrolloff' and 'sidescrolloff' options window local (#11854) Problem: cannot have a local value for 'scrolloff' and 'sidescrolloff' Author: Bram Moolenar https://github.com/vim/vim/commit/375e3390078e740d3c83b0c118c50d9a920036c7 --- src/nvim/normal.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 6434bd00d8..6c92b136da 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2584,12 +2584,13 @@ do_mouse ( /* Set global flag that we are extending the Visual area with mouse * dragging; temporarily minimize 'scrolloff'. */ - if (VIsual_active && is_drag && p_so) { - /* In the very first line, allow scrolling one line */ - if (mouse_row == 0) + if (VIsual_active && is_drag && get_scrolloff_value()) { + // In the very first line, allow scrolling one line + if (mouse_row == 0) { mouse_dragging = 2; - else + } else { mouse_dragging = 1; + } } /* When dragging the mouse above the window, scroll down. */ @@ -4089,9 +4090,9 @@ void scroll_redraw(int up, long count) scrollup(count, true); else scrolldown(count, true); - if (p_so) { - /* Adjust the cursor position for 'scrolloff'. Mark w_topline as - * valid, otherwise the screen jumps back at the end of the file. */ + if (get_scrolloff_value()) { + // Adjust the cursor position for 'scrolloff'. Mark w_topline as + // valid, otherwise the screen jumps back at the end of the file. cursor_correct(); check_cursor_moved(curwin); curwin->w_valid |= VALID_TOPLINE; @@ -4135,8 +4136,8 @@ static void nv_zet(cmdarg_T *cap) int old_fen = curwin->w_p_fen; bool undo = false; - assert(p_siso <= INT_MAX); - int l_p_siso = (int)p_siso; + int l_p_siso = (int)get_sidescrolloff_value(); + assert(l_p_siso <= INT_MAX); if (ascii_isdigit(nchar)) { /* -- cgit From 1fe0b329fe1d40e5837a43f53da0e0fff38477bc Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 23 Jan 2020 18:05:04 +0100 Subject: api/ui: win_viewport event for visible range and cursor position in window --- 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 6c92b136da..be131f7e00 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4121,6 +4121,7 @@ void scroll_redraw(int up, long count) } if (curwin->w_cursor.lnum != prev_lnum) coladvance(curwin->w_curswant); + curwin->w_viewport_invalid = true; redraw_later(VALID); } -- cgit From a15750321b07cc1dbd6af6de8a09cf79da859062 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 16 Mar 2020 18:08:13 -0400 Subject: vim-patch:8.2.0397: delayed screen update when using undo from Insert mode Problem: Delayed screen update when using undo from Insert mode. Solution: Update w_topline and cursor shape before sleeping. (closes vim/vim#5790) https://github.com/vim/vim/commit/5715b3147bfc8ddfe905339f6fd224fd3a5a3ba1 --- src/nvim/normal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index be131f7e00..aca27e0208 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -615,7 +615,9 @@ static void normal_redraw_mode_message(NormalState *s) kmsg = keep_msg; keep_msg = NULL; - // showmode() will clear keep_msg, but we want to use it anyway + // Showmode() will clear keep_msg, but we want to use it anyway. + // First update w_topline. + setcursor(); update_screen(0); // now reset it, otherwise it's put in the history again keep_msg = kmsg; @@ -623,6 +625,7 @@ static void normal_redraw_mode_message(NormalState *s) xfree(kmsg); } setcursor(); + ui_cursor_shape(); // show different cursor shape ui_flush(); if (msg_scroll || emsg_on_display) { os_delay(1000L, true); // wait at least one second -- cgit From fb4c7a53cfe4d4c8a786c8a5dc3c4b999c2df815 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Apr 2020 21:29:04 +0200 Subject: folds: decrease reliance on global "curwin" (#12132) Pass the window in which to create/delete folds instead of using the global "curwin" (current window). Preliminary work for a fold API. TODO: I kept changed_lines prototype unchanged. This should be updated when a fold API sees the light. --- src/nvim/normal.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index aca27e0208..58993426dd 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1967,8 +1967,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) break; case OP_FOLD: - VIsual_reselect = false; /* don't reselect now */ - foldCreate(oap->start.lnum, oap->end.lnum); + VIsual_reselect = false; // don't reselect now + foldCreate(curwin, oap->start.lnum, oap->end.lnum); break; case OP_FOLDOPEN: @@ -1986,9 +1986,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_FOLDDEL: case OP_FOLDDELREC: - VIsual_reselect = false; /* don't reselect now */ - deleteFold(oap->start.lnum, oap->end.lnum, - oap->op_type == OP_FOLDDELREC, oap->is_VIsual); + VIsual_reselect = false; // don't reselect now + deleteFold(curwin, oap->start.lnum, oap->end.lnum, + oap->op_type == OP_FOLDDELREC, oap->is_VIsual); break; case OP_NR_ADD: @@ -4345,11 +4345,12 @@ dozet: /* "zD": delete fold at cursor recursively */ case 'd': case 'D': if (foldManualAllowed(false)) { - if (VIsual_active) + if (VIsual_active) { nv_operator(cap); - else - deleteFold(curwin->w_cursor.lnum, - curwin->w_cursor.lnum, nchar == 'D', false); + } else { + deleteFold(curwin, curwin->w_cursor.lnum, + curwin->w_cursor.lnum, nchar == 'D', false); + } } break; @@ -4357,11 +4358,11 @@ dozet: case 'E': if (foldmethodIsManual(curwin)) { clearFolding(curwin); changed_window_setting(); - } else if (foldmethodIsMarker(curwin)) - deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, - true, false); - else + } else if (foldmethodIsMarker(curwin)) { + deleteFold(curwin, (linenr_T)1, curbuf->b_ml.ml_line_count, true, false); + } else { EMSG(_("E352: Cannot erase folds with current 'foldmethod'")); + } break; /* "zn": fold none: reset 'foldenable' */ -- cgit From ec2d45a8515399e3f23e0a552bcb222ae4836f7a Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 19 Apr 2020 19:24:41 +0100 Subject: vim-patch:7.4.1988 Problem: When updating viminfo with file marks there is no time order. Solution: Remember the time when a buffer was last used, store marks for the most recently used buffers. https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd As this is a viminfo fix, most of this is irrelevant - the patch has just been brought across for the creation and updating of buffer's `b_last_used` properties. --- 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 58993426dd..76de60cf4f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1260,6 +1260,8 @@ static void normal_redraw(NormalState *s) maketitle(); } + curbuf->b_last_used = time(NULL); + // Display message after redraw. If an external message is still visible, // it contains the kept message already. if (keep_msg != NULL && !msg_ext_is_visible()) { -- cgit From 355dffdd769ffb12ad3e54528fb6910b08facb6c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 14 Mar 2020 09:13:17 -0400 Subject: vim-patch:8.0.1138: click in window toolbar starts Visual mode Problem: Click in window toolbar starts Visual mode. Solution: Add the MOUSE_WINBAR flag. https://github.com/vim/vim/commit/eb163d73b11c10b461a2839530173a33d7915a33 --- 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 58993426dd..ea8155f6b8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2559,7 +2559,14 @@ do_mouse ( * JUMP! */ jump_flags = jump_to_mouse(jump_flags, - oap == NULL ? NULL : &(oap->inclusive), which_button); + oap == NULL ? NULL : &(oap->inclusive), + which_button); + + // A click in the window toolbar has no side effects. + if (jump_flags & MOUSE_WINBAR) { + return false; + } + moved = (jump_flags & CURSOR_MOVED); in_status_line = (jump_flags & IN_STATUS_LINE); in_sep_line = (jump_flags & IN_SEP_LINE); -- cgit From 44531928b3512b143f6e3c958e49f99e827eb7de Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 31 May 2020 17:01:28 -0400 Subject: vim-patch:8.1.2018: using freed memory when out of memory and displaying message Problem: Using freed memory when out of memory and displaying message. Solution: Make a copy of the message first. https://github.com/vim/vim/commit/e5fbd7393067c279860598ac8359d1617b1082b9 --- src/nvim/normal.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 87d687198d..968cfde388 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -621,6 +621,8 @@ static void normal_redraw_mode_message(NormalState *s) update_screen(0); // now reset it, otherwise it's put in the history again keep_msg = kmsg; + + kmsg = vim_strsave(keep_msg); msg_attr((const char *)kmsg, keep_msg_attr); xfree(kmsg); } @@ -1265,10 +1267,15 @@ static void normal_redraw(NormalState *s) // Display message after redraw. If an external message is still visible, // it contains the kept message already. if (keep_msg != NULL && !msg_ext_is_visible()) { - // msg_attr_keep() will set keep_msg to NULL, must free the string here. - // Don't reset keep_msg, msg_attr_keep() uses it to check for duplicates. - char *p = (char *)keep_msg; - msg_attr(p, keep_msg_attr); + char_u *const p = vim_strsave(keep_msg); + + // msg_start() will set keep_msg to NULL, make a copy + // first. Don't reset keep_msg, msg_attr_keep() uses it to + // check for duplicates. Never put this message in + // history. + msg_hist_off = true; + msg_attr((const char *)p, keep_msg_attr); + msg_hist_off = false; xfree(p); } -- cgit