diff options
-rw-r--r-- | .github/workflows/labeler_issue.yml | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 13 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | src/nvim/generators/gen_options.lua | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 14 | ||||
-rw-r--r-- | src/nvim/option_vars.h | 6 | ||||
-rw-r--r-- | src/nvim/options.lua | 26 | ||||
-rw-r--r-- | test/functional/editor/mode_normal_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/lua/luaeval_spec.lua | 2 | ||||
-rw-r--r-- | test/old/testdir/test_goto.vim | 13 |
10 files changed, 72 insertions, 30 deletions
diff --git a/.github/workflows/labeler_issue.yml b/.github/workflows/labeler_issue.yml index 0da4c0f707..deba3cd5a5 100644 --- a/.github/workflows/labeler_issue.yml +++ b/.github/workflows/labeler_issue.yml @@ -13,7 +13,7 @@ jobs: with: script: | const title = context.payload.issue.title; - const titleSplit = title.split(/\s+/).map(e => e.toLowerCase()); + const titleSplit = title.split(/\b/).map(e => e.toLowerCase()); const keywords = ['api', 'treesitter', 'ui', 'lsp']; var match = new Set(); for (const keyword of keywords) { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4734e46362..3d224bfa0f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3238,6 +3238,13 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan } else { // skip the name check_vars(s, (size_t)len); + // If evaluate is false rettv->v_type was not set, but it's needed + // in handle_subscript() to parse v:lua, so set it here. + if (rettv->v_type == VAR_UNKNOWN && !evaluate && strnequal(s, "v:lua.", 6)) { + rettv->v_type = VAR_PARTIAL; + rettv->vval.v_partial = vvlua_partial; + rettv->vval.v_partial->pt_refcount++; + } ret = OK; } } @@ -3442,7 +3449,7 @@ static int eval_method(char **const arg, typval_T *const rettv, evalarg_T *const int len; char *name = *arg; char *lua_funcname = NULL; - if (strncmp(name, "v:lua.", 6) == 0) { + if (strnequal(name, "v:lua.", 6)) { lua_funcname = name + 6; *arg = (char *)skip_luafunc_name(lua_funcname); *arg = skipwhite(*arg); // to detect trailing whitespace later @@ -7614,6 +7621,10 @@ int handle_subscript(const char **const arg, typval_T *rettv, evalarg_T *const e const char *lua_funcname = NULL; if (tv_is_luafunc(rettv)) { + if (!evaluate) { + tv_clear(rettv); + } + if (**arg != '.') { tv_clear(rettv); ret = FAIL; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index f4253df63e..e5af50c8f8 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1726,7 +1726,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) n = false; // Trailing garbage. } } else if (*p == '*') { // Internal or user defined function. - n = strncmp(p, "*v:lua.", 7) == 0 ? nlua_func_exists(p + 7) : function_exists(p + 1, false); + n = strnequal(p, "*v:lua.", 7) ? nlua_func_exists(p + 7) : function_exists(p + 1, false); } else if (*p == ':') { n = cmd_exists(p + 1); } else if (*p == '#') { diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index cdb77c4a0c..749844e658 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -20,10 +20,10 @@ local redraw_flags = { tabline = 'P_RTABL', statuslines = 'P_RSTAT', current_window = 'P_RWIN', - current_window_only = 'P_RWINONLY', current_buffer = 'P_RBUF', all_windows = 'P_RALL', curswant = 'P_CURSWANT', + highlight_only = 'P_HLONLY', } local list_flags = { diff --git a/src/nvim/option.c b/src/nvim/option.c index 42ccc1fbd4..0ac65ed95d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3029,14 +3029,15 @@ void check_redraw_for(buf_T *buf, win_T *win, uint32_t flags) } if ((flags & P_RBUF) || (flags & P_RWIN) || all) { - changed_window_setting_win(win); + if (flags & P_HLONLY) { + redraw_later(win, UPD_NOT_VALID); + } else { + changed_window_setting_win(win); + } } if (flags & P_RBUF) { redraw_buf_later(buf, UPD_NOT_VALID); } - if (flags & P_RWINONLY) { - redraw_later(win, UPD_NOT_VALID); - } if (all) { redraw_all_later(UPD_NOT_VALID); } @@ -3554,7 +3555,7 @@ static const char *did_set_option(OptIndex opt_idx, void *varp, OptVal old_value do_spelllang_source(curwin); } - // In case 'columns' or 'ls' changed. + // In case 'ruler' or 'showcmd' or 'columns' or 'ls' changed. comp_col(); if (varp == &p_mouse) { @@ -3568,7 +3569,8 @@ static const char *did_set_option(OptIndex opt_idx, void *varp, OptVal old_value set_winbar(true); } - if (curwin->w_curswant != MAXCOL && (opt->flags & (P_CURSWANT | P_RALL)) != 0) { + if (curwin->w_curswant != MAXCOL + && (opt->flags & (P_CURSWANT | P_RALL)) != 0 && (opt->flags & P_HLONLY) == 0) { curwin->w_set_curswant = true; } diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h index a389516bd3..175f2af896 100644 --- a/src/nvim/option_vars.h +++ b/src/nvim/option_vars.h @@ -27,8 +27,8 @@ #define P_RSTAT 0x200U ///< redraw status lines #define P_RWIN 0x400U ///< redraw current window and recompute text #define P_RBUF 0x800U ///< redraw current buffer and recompute text -#define P_RALL 0xC00U ///< redraw all windows -#define P_RCLR 0xE00U ///< clear and redraw all +#define P_RALL 0xC00U ///< redraw all windows and recompute text +#define P_RCLR 0xE00U ///< clear and redraw all and recompute text #define P_COMMA 0x1000U ///< comma separated list #define P_ONECOMMA 0x3000U ///< P_COMMA and cannot have two consecutive @@ -47,7 +47,7 @@ #define P_CURSWANT 0x800000U ///< update curswant required; not needed ///< when there is a redraw flag #define P_NDNAME 0x1000000U ///< only normal dir name chars allowed -#define P_RWINONLY 0x2000000U ///< only redraw current window +#define P_HLONLY 0x2000000U ///< option only changes highlight, not text #define P_MLE 0x4000000U ///< under control of 'modelineexpr' #define P_FUNC 0x8000000U ///< accept a function reference or a lambda #define P_COLON 0x10000000U ///< values use colons to create sublists diff --git a/src/nvim/options.lua b/src/nvim/options.lua index b993a50b18..6e2b015228 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -45,10 +45,10 @@ --- |'statuslines' --- |'tabline' --- |'current_window' ---- |'current_window_only' --- |'current_buffer' --- |'all_windows' --- |'curswant' +--- |'highlight_only' --- |'ui_option' --- @param s string @@ -1262,7 +1262,7 @@ return { ]=], full_name = 'colorcolumn', list = 'onecomma', - redraw = { 'current_window' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('columns to highlight'), type = 'string', @@ -1859,7 +1859,7 @@ return { < ]=], full_name = 'cursorcolumn', - redraw = { 'current_window_only' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('highlight the screen column of the cursor'), type = 'boolean', @@ -1874,7 +1874,7 @@ return { easier to see the selected text. ]=], full_name = 'cursorline', - redraw = { 'current_window_only' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('highlight the screen line of the cursor'), type = 'boolean', @@ -1902,7 +1902,7 @@ return { expand_cb = 'expand_set_cursorlineopt', full_name = 'cursorlineopt', list = 'onecomma', - redraw = { 'current_window_only' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_("settings for 'cursorline'"), type = 'string', @@ -3926,7 +3926,7 @@ return { with the 'h' flag in 'shada' |shada-h|. ]=], full_name = 'hlsearch', - redraw = { 'all_windows' }, + redraw = { 'all_windows', 'highlight_only' }, scope = { 'global' }, short_desc = N_('highlight matches with last search pattern'), type = 'boolean', @@ -7708,7 +7708,7 @@ return { The languages are specified with 'spelllang'. ]=], full_name = 'spell', - redraw = { 'current_window' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('spell checking'), type = 'boolean', @@ -7730,7 +7730,7 @@ return { |set-spc-auto|. ]=], full_name = 'spellcapcheck', - redraw = { 'current_buffer' }, + redraw = { 'current_buffer', 'highlight_only' }, scope = { 'buffer' }, short_desc = N_('pattern to locate end of a sentence'), type = 'string', @@ -7821,7 +7821,7 @@ return { expand = true, full_name = 'spelllang', list = 'onecomma', - redraw = { 'current_buffer' }, + redraw = { 'current_buffer', 'highlight_only' }, scope = { 'buffer' }, short_desc = N_('language(s) to do spell checking for'), type = 'string', @@ -7846,7 +7846,7 @@ return { expand_cb = 'expand_set_spelloptions', full_name = 'spelloptions', list = 'onecomma', - redraw = { 'current_buffer' }, + redraw = { 'current_buffer', 'highlight_only' }, scope = { 'buffer' }, secure = true, type = 'string', @@ -8858,7 +8858,7 @@ return { When 'formatexpr' is set it will be used to break the line. ]=], full_name = 'textwidth', - redraw = { 'current_buffer' }, + redraw = { 'current_buffer', 'highlight_only' }, scope = { 'buffer' }, short_desc = N_('maximum width of text that is being inserted'), type = 'number', @@ -9785,7 +9785,7 @@ return { UI-dependent. Works best with RGB colors. 'termguicolors' ]=], full_name = 'winblend', - redraw = { 'current_window' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('Controls transparency level for floating windows'), type = 'number', @@ -9900,7 +9900,7 @@ return { expand_cb = 'expand_set_winhighlight', full_name = 'winhighlight', list = 'onecommacolon', - redraw = { 'current_window' }, + redraw = { 'current_window', 'highlight_only' }, scope = { 'window' }, short_desc = N_('Setup window-local highlights'), type = 'string', diff --git a/test/functional/editor/mode_normal_spec.lua b/test/functional/editor/mode_normal_spec.lua new file mode 100644 index 0000000000..89bab3f6c9 --- /dev/null +++ b/test/functional/editor/mode_normal_spec.lua @@ -0,0 +1,22 @@ +-- Normal mode tests. + +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local feed = helpers.feed +local fn = helpers.fn +local command = helpers.command +local eq = helpers.eq + +describe('Normal mode', function() + before_each(clear) + + it('setting &winhighlight or &winblend does not change curswant #27470', function() + fn.setline(1, { 'long long lone line', 'short line' }) + feed('ggfi') + local pos = fn.getcurpos() + feed('j') + command('setlocal winblend=10 winhighlight=Visual:Search') + feed('k') + eq(pos, fn.getcurpos()) + end) +end) diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua index 171d37ba55..b28cfa4dd2 100644 --- a/test/functional/lua/luaeval_spec.lua +++ b/test/functional/lua/luaeval_spec.lua @@ -538,6 +538,8 @@ describe('v:lua', function() eq('\tbadval', eval("v:lua.require'leftpad'('badval')")) eq(9003, eval("v:lua.require'bar'.doit()")) eq(9004, eval("v:lua.require'baz-quux'.doit()")) + eq(9003, eval("1 ? v:lua.require'bar'.doit() : v:lua.require'baz-quux'.doit()")) + eq(9004, eval("0 ? v:lua.require'bar'.doit() : v:lua.require'baz-quux'.doit()")) end) it('throw errors for invalid use', function() diff --git a/test/old/testdir/test_goto.vim b/test/old/testdir/test_goto.vim index 6d029ffda2..c5492ff97b 100644 --- a/test/old/testdir/test_goto.vim +++ b/test/old/testdir/test_goto.vim @@ -313,18 +313,23 @@ func Test_gd_string_only() call XTest_goto_decl('gd', lines, 5, 10) endfunc -" Check that setting 'cursorline' does not change curswant -func Test_cursorline_keep_col() +" Check that setting some options does not change curswant +func Test_set_options_keep_col() new call setline(1, ['long long long line', 'short line']) normal ggfi let pos = getcurpos() normal j - set cursorline + set invhlsearch spell spelllang=en,cjk spelloptions=camel textwidth=80 + set cursorline cursorcolumn cursorlineopt=line colorcolumn=+1 + set background=dark + set background=light normal k call assert_equal(pos, getcurpos()) bwipe! - set nocursorline + set hlsearch& spell& spelllang& spelloptions& textwidth& + set cursorline& cursorcolumn& cursorlineopt& colorcolumn& + set background& endfunc func Test_gd_local_block() |