aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake.deps/cmake/TreesitterCMakeLists.txt1
-rw-r--r--cmake.deps/deps.txt4
-rw-r--r--runtime/doc/news.txt2
-rw-r--r--runtime/lua/vim/_meta/api.lua4
-rw-r--r--runtime/lua/vim/_meta/api_keysets.lua48
-rw-r--r--runtime/queries/bash/highlights.scm8
-rwxr-xr-xsrc/clint.py7
-rw-r--r--src/nvim/api/command.c127
-rw-r--r--src/nvim/api/deprecated.c4
-rw-r--r--src/nvim/api/keysets_defs.h4
-rw-r--r--src/nvim/api/options.c8
-rw-r--r--src/nvim/api/private/helpers.c4
-rw-r--r--src/nvim/api/private/helpers.h3
-rw-r--r--src/nvim/api/ui.c15
-rw-r--r--src/nvim/api/vim.c10
-rw-r--r--src/nvim/api/win_config.c40
-rw-r--r--src/nvim/arglist.c11
-rw-r--r--src/nvim/autocmd.c4
-rw-r--r--src/nvim/buffer_defs.h28
-rw-r--r--src/nvim/channel.c7
-rw-r--r--src/nvim/decoration.c22
-rw-r--r--src/nvim/edit.c8
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/ex_cmds.c10
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/highlight.c64
-rw-r--r--src/nvim/highlight_group.c2
-rw-r--r--src/nvim/main.c13
-rw-r--r--src/nvim/mbyte.c4
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/msgpack_rpc/channel.c6
-rw-r--r--src/nvim/normal.c6
-rw-r--r--src/nvim/option.c43
-rw-r--r--src/nvim/os/fs.c2
-rw-r--r--src/nvim/popupmenu.c4
-rw-r--r--src/nvim/profile.c47
-rw-r--r--src/nvim/search.c18
-rw-r--r--src/nvim/shada.c4
-rw-r--r--src/nvim/sign.c26
-rw-r--r--src/nvim/spellsuggest.c4
-rw-r--r--src/nvim/ui.c36
-rw-r--r--src/nvim/usercmd.c14
-rw-r--r--src/nvim/window.c24
-rw-r--r--src/nvim/winfloat.c8
-rw-r--r--test/functional/autocmd/textchanged_spec.lua11
-rw-r--r--test/functional/core/startup_spec.lua1
-rw-r--r--test/functional/legacy/listlbr_utf8_spec.lua29
-rw-r--r--test/functional/terminal/tui_spec.lua28
-rw-r--r--test/functional/ui/mouse_spec.lua6
-rw-r--r--test/functional/ui/popupmenu_spec.lua70
-rw-r--r--test/old/testdir/test_autocmd.vim20
-rw-r--r--test/old/testdir/test_listlbr_utf8.vim21
-rw-r--r--test/old/testdir/test_tabpage.vim7
53 files changed, 607 insertions, 300 deletions
diff --git a/cmake.deps/cmake/TreesitterCMakeLists.txt b/cmake.deps/cmake/TreesitterCMakeLists.txt
index 9f96430ac2..f1e0d4e575 100644
--- a/cmake.deps/cmake/TreesitterCMakeLists.txt
+++ b/cmake.deps/cmake/TreesitterCMakeLists.txt
@@ -13,7 +13,6 @@ target_include_directories(tree-sitter
install(FILES
lib/include/tree_sitter/api.h
- lib/include/tree_sitter/parser.h
DESTINATION include/tree_sitter)
include(GNUInstallDirs)
diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt
index ff494dd275..1230fd9030 100644
--- a/cmake.deps/deps.txt
+++ b/cmake.deps/deps.txt
@@ -53,8 +53,8 @@ TREESITTER_QUERY_URL https://github.com/nvim-treesitter/tree-sitter-query/archiv
TREESITTER_QUERY_SHA256 e2b806f80e8bf1c4f4e5a96248393fe6622fc1fc6189d6896d269658f67f914c
TREESITTER_PYTHON_URL https://github.com/tree-sitter/tree-sitter-python/archive/v0.20.4.tar.gz
TREESITTER_PYTHON_SHA256 1e38c991832f461c0da8ca222fbe5be3b82b868fe34025f0295206b5e5789d7a
-TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.20.4.tar.gz
-TREESITTER_BASH_SHA256 8a86182b9dd66acdce27c1e272247882b5cf910dd8725fbb68a8bf9d808fecba
+TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.20.5.tar.gz
+TREESITTER_BASH_SHA256 7bba80ac64a18ec1b3f47e738e6a168f065c3cb4244234eff1b773816008f5a7
TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.1.7.tar.gz
TREESITTER_MARKDOWN_SHA256 7d0e7f7ed4516ed0816f9c304e2e7fa93b2c16f9280416c2fb64dc4efd9c5f83
TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.20.9.tar.gz
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 89e295c230..ad4a7a475d 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -419,6 +419,8 @@ The following changes to existing APIs or features add new behavior.
• 'errorfile' (|-q|) accepts `-` as an alias for stdin.
+• |--startuptime| reports the startup times for both processes (TUI + server) as separate sections.
+
==============================================================================
REMOVED FEATURES *news-removed*
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index 8b29727196..f46ab8023f 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -1535,7 +1535,7 @@ function vim.api.nvim_open_term(buffer, opts) end
---
--- @param buffer integer Buffer to display, or 0 for current buffer
--- @param enter boolean Enter the window (make it the current window)
---- @param config vim.api.keyset.float_config Map defining the window configuration. Keys:
+--- @param config vim.api.keyset.win_config Map defining the window configuration. Keys:
--- • relative: Sets the window layout to "floating", placed at
--- (row,col) coordinates relative to:
--- • "editor" The global editor grid
@@ -2093,7 +2093,7 @@ function vim.api.nvim_win_set_buf(window, buffer) end
--- changed. `row`/`col` and `relative` must be reconfigured together.
---
--- @param window integer Window handle, or 0 for current window
---- @param config vim.api.keyset.float_config Map defining the window configuration, see `nvim_open_win()`
+--- @param config vim.api.keyset.win_config Map defining the window configuration, see `nvim_open_win()`
function vim.api.nvim_win_set_config(window, config) end
--- Sets the (1,0)-indexed cursor position in the window. `api-indexing` This
diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua
index 1b6c6811a2..0442a89e3f 100644
--- a/runtime/lua/vim/_meta/api_keysets.lua
+++ b/runtime/lua/vim/_meta/api_keysets.lua
@@ -111,30 +111,6 @@ error('Cannot require a meta file')
--- @class vim.api.keyset.exec_opts
--- @field output? boolean
---- @class vim.api.keyset.float_config
---- @field row? number
---- @field col? number
---- @field width? integer
---- @field height? integer
---- @field anchor? string
---- @field relative? string
---- @field split? string
---- @field win? integer
---- @field bufpos? any[]
---- @field external? boolean
---- @field focusable? boolean
---- @field vertical? boolean
---- @field zindex? integer
---- @field border? any
---- @field title? any
---- @field title_pos? string
---- @field footer? any
---- @field footer_pos? string
---- @field style? string
---- @field noautocmd? boolean
---- @field fixed? boolean
---- @field hide? boolean
-
--- @class vim.api.keyset.get_autocmds
--- @field event? any
--- @field group? any
@@ -292,6 +268,30 @@ error('Cannot require a meta file')
--- @field range? any
--- @field register? boolean
+--- @class vim.api.keyset.win_config
+--- @field row? number
+--- @field col? number
+--- @field width? integer
+--- @field height? integer
+--- @field anchor? string
+--- @field relative? string
+--- @field split? string
+--- @field win? integer
+--- @field bufpos? any[]
+--- @field external? boolean
+--- @field focusable? boolean
+--- @field vertical? boolean
+--- @field zindex? integer
+--- @field border? any
+--- @field title? any
+--- @field title_pos? string
+--- @field footer? any
+--- @field footer_pos? string
+--- @field style? string
+--- @field noautocmd? boolean
+--- @field fixed? boolean
+--- @field hide? boolean
+
--- @class vim.api.keyset.win_text_height
--- @field start_row? integer
--- @field end_row? integer
diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm
index 21346ded8f..b4360ce7e1 100644
--- a/runtime/queries/bash/highlights.scm
+++ b/runtime/queries/bash/highlights.scm
@@ -43,6 +43,7 @@
"<<-"
"<<<"
".."
+ "!"
] @operator
; Do *not* spell check strings since they typically have some sort of
@@ -66,6 +67,13 @@
(command
argument: "$" @string) ; bare dollar
+(concatenation
+ [
+ (simple_expansion)
+ (expansion)
+ ]
+ (word) @string)
+
[
"if"
"then"
diff --git a/src/clint.py b/src/clint.py
index 78eabb698f..062901b43a 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -152,8 +152,10 @@ _ERROR_CATEGORIES = [
'build/endif_comment',
'build/header_guard',
'build/include_defs',
+ 'build/defs_header',
'build/printf_format',
'build/storage_class',
+ 'build/init_macro',
'readability/bool',
'readability/multiline_comment',
'readability/multiline_string',
@@ -2086,6 +2088,11 @@ def CheckLanguage(filename, clean_lines, linenum, error):
" named ('k' followed by CamelCase) compile-time constant for"
" the size.")
+ # INIT() macro should only be used in header files.
+ if not filename.endswith('.h') and Search(r' INIT\(', line):
+ error(filename, linenum, 'build/init_macro', 4,
+ 'INIT() macro should only be used in header files.')
+
# Detect TRUE and FALSE.
match = Search(r'\b(TRUE|FALSE)\b', line)
if match:
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index db0a918f5c..bafc45e543 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -96,15 +96,15 @@
/// - "belowright": |:belowright|.
/// - "topleft": |:topleft|.
/// - "botright": |:botright|.
-Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
+Dict(cmd) nvim_parse_cmd(String str, Dict(empty) *opts, Arena *arena, Error *err)
FUNC_API_SINCE(10) FUNC_API_FAST
{
- Dictionary result = ARRAY_DICT_INIT;
+ Dict(cmd) result = { 0 };
// Parse command line
exarg_T ea;
CmdParseInfo cmdinfo;
- char *cmdline = string_to_cstr(str);
+ char *cmdline = arena_memdupz(arena, str.data, str.size);
const char *errormsg = NULL;
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
@@ -124,22 +124,23 @@ Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
// otherwise split arguments by whitespace.
if (ea.argt & EX_NOSPC) {
if (*ea.arg != NUL) {
- ADD(args, STRING_OBJ(cstrn_to_string(ea.arg, length)));
+ args = arena_array(arena, 1);
+ ADD_C(args, STRING_OBJ(cstrn_as_string(ea.arg, length)));
}
} else {
size_t end = 0;
size_t len = 0;
- char *buf = xcalloc(length, sizeof(char));
+ char *buf = arena_alloc(arena, length + 1, false);
bool done = false;
+ args = arena_array(arena, uc_nargs_upper_bound(ea.arg, length));
while (!done) {
done = uc_split_args_iter(ea.arg, length, &end, buf, &len);
if (len > 0) {
- ADD(args, STRING_OBJ(cstrn_to_string(buf, len)));
+ ADD_C(args, STRING_OBJ(cstrn_as_string(buf, len)));
+ buf += len + 1;
}
}
-
- xfree(buf);
}
ucmd_T *cmd = NULL;
@@ -149,40 +150,32 @@ Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
cmd = USER_CMD_GA(&curbuf->b_ucmds, ea.useridx);
}
- if (cmd != NULL) {
- PUT(result, "cmd", CSTR_TO_OBJ(cmd->uc_name));
- } else {
- PUT(result, "cmd", CSTR_TO_OBJ(get_command_name(NULL, ea.cmdidx)));
- }
+ char *name = (cmd != NULL ? cmd->uc_name : get_command_name(NULL, ea.cmdidx));
+ PUT_KEY(result, cmd, cmd, cstr_as_string(name));
if (ea.argt & EX_RANGE) {
- Array range = ARRAY_DICT_INIT;
+ Array range = arena_array(arena, 2);
if (ea.addr_count > 0) {
if (ea.addr_count > 1) {
- ADD(range, INTEGER_OBJ(ea.line1));
+ ADD_C(range, INTEGER_OBJ(ea.line1));
}
- ADD(range, INTEGER_OBJ(ea.line2));
+ ADD_C(range, INTEGER_OBJ(ea.line2));
}
- PUT(result, "range", ARRAY_OBJ(range));
+ PUT_KEY(result, cmd, range, range);
}
if (ea.argt & EX_COUNT) {
- if (ea.addr_count > 0) {
- PUT(result, "count", INTEGER_OBJ(ea.line2));
- } else if (cmd != NULL) {
- PUT(result, "count", INTEGER_OBJ(cmd->uc_def));
- } else {
- PUT(result, "count", INTEGER_OBJ(0));
- }
+ Integer count = ea.addr_count > 0 ? ea.line2 : (cmd != NULL ? cmd->uc_def : 0);
+ PUT_KEY(result, cmd, count, count);
}
if (ea.argt & EX_REGSTR) {
char reg[2] = { (char)ea.regname, NUL };
- PUT(result, "reg", CSTR_TO_OBJ(reg));
+ PUT_KEY(result, cmd, reg, CSTR_TO_ARENA_STR(arena, reg));
}
- PUT(result, "bang", BOOLEAN_OBJ(ea.forceit));
- PUT(result, "args", ARRAY_OBJ(args));
+ PUT_KEY(result, cmd, bang, ea.forceit);
+ PUT_KEY(result, cmd, args, args);
char nargs[2];
if (ea.argt & EX_EXTRA) {
@@ -201,9 +194,9 @@ Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
nargs[0] = '0';
}
nargs[1] = '\0';
- PUT(result, "nargs", CSTR_TO_OBJ(nargs));
+ PUT_KEY(result, cmd, nargs, CSTR_TO_ARENA_OBJ(arena, nargs));
- const char *addr;
+ char *addr;
switch (ea.addr_type) {
case ADDR_LINES:
addr = "line";
@@ -233,38 +226,37 @@ Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
addr = "?";
break;
}
- PUT(result, "addr", CSTR_TO_OBJ(addr));
- PUT(result, "nextcmd", CSTR_TO_OBJ(ea.nextcmd));
-
- Dictionary mods = ARRAY_DICT_INIT;
-
- Dictionary filter = ARRAY_DICT_INIT;
- PUT(filter, "pattern", cmdinfo.cmdmod.cmod_filter_pat
- ? CSTR_TO_OBJ(cmdinfo.cmdmod.cmod_filter_pat)
- : STATIC_CSTR_TO_OBJ(""));
- PUT(filter, "force", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_filter_force));
- PUT(mods, "filter", DICTIONARY_OBJ(filter));
-
- PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SILENT));
- PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
- PUT(mods, "unsilent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_UNSILENT));
- PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX));
- PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
- PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.cmod_tab - 1));
- PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.cmdmod.cmod_verbose - 1));
- PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_BROWSE));
- PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_CONFIRM));
- PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_HIDE));
- PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPALT));
- PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPJUMPS));
- PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPMARKS));
- PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPPATTERNS));
- PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_LOCKMARKS));
- PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOSWAPFILE));
- PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_VERT));
- PUT(mods, "horizontal", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_HOR));
-
- const char *split;
+ PUT_KEY(result, cmd, addr, CSTR_AS_OBJ(addr));
+ PUT_KEY(result, cmd, nextcmd, CSTR_AS_OBJ(ea.nextcmd));
+
+ // TODO(bfredl): nested keydict would be nice..
+ Dictionary mods = arena_dict(arena, 20);
+
+ Dictionary filter = arena_dict(arena, 2);
+ PUT_C(filter, "pattern", CSTR_TO_ARENA_OBJ(arena, cmdinfo.cmdmod.cmod_filter_pat));
+ PUT_C(filter, "force", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_filter_force));
+ PUT_C(mods, "filter", DICTIONARY_OBJ(filter));
+
+ PUT_C(mods, "silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SILENT));
+ PUT_C(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
+ PUT_C(mods, "unsilent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_UNSILENT));
+ PUT_C(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX));
+ PUT_C(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
+ PUT_C(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.cmod_tab - 1));
+ PUT_C(mods, "verbose", INTEGER_OBJ(cmdinfo.cmdmod.cmod_verbose - 1));
+ PUT_C(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_BROWSE));
+ PUT_C(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_CONFIRM));
+ PUT_C(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_HIDE));
+ PUT_C(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPALT));
+ PUT_C(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPJUMPS));
+ PUT_C(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPMARKS));
+ PUT_C(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPPATTERNS));
+ PUT_C(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_LOCKMARKS));
+ PUT_C(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOSWAPFILE));
+ PUT_C(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_VERT));
+ PUT_C(mods, "horizontal", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_HOR));
+
+ char *split;
if (cmdinfo.cmdmod.cmod_split & WSP_BOT) {
split = "botright";
} else if (cmdinfo.cmdmod.cmod_split & WSP_TOP) {
@@ -276,18 +268,17 @@ Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
} else {
split = "";
}
- PUT(mods, "split", CSTR_TO_OBJ(split));
+ PUT_C(mods, "split", CSTR_AS_OBJ(split));
- PUT(result, "mods", DICTIONARY_OBJ(mods));
+ PUT_KEY(result, cmd, mods, mods);
- Dictionary magic = ARRAY_DICT_INIT;
- PUT(magic, "file", BOOLEAN_OBJ(cmdinfo.magic.file));
- PUT(magic, "bar", BOOLEAN_OBJ(cmdinfo.magic.bar));
- PUT(result, "magic", DICTIONARY_OBJ(magic));
+ Dictionary magic = arena_dict(arena, 2);
+ PUT_C(magic, "file", BOOLEAN_OBJ(cmdinfo.magic.file));
+ PUT_C(magic, "bar", BOOLEAN_OBJ(cmdinfo.magic.bar));
+ PUT_KEY(result, cmd, magic, magic);
undo_cmdmod(&cmdinfo.cmdmod);
end:
- xfree(cmdline);
return result;
}
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index b09645a819..27f0589e53 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -514,11 +514,11 @@ static int64_t convert_index(int64_t index)
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option Information
-Dictionary nvim_get_option_info(String name, Error *err)
+Dictionary nvim_get_option_info(String name, Arena *arena, Error *err)
FUNC_API_SINCE(7)
FUNC_API_DEPRECATED_SINCE(11)
{
- return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, err);
+ return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, arena, err);
}
/// Sets the global value of an option.
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h
index 2f1b38d1e5..0ba33ca9a7 100644
--- a/src/nvim/api/keysets_defs.h
+++ b/src/nvim/api/keysets_defs.h
@@ -108,7 +108,7 @@ typedef struct {
} Dict(user_command);
typedef struct {
- OptionalKeys is_set__float_config_;
+ OptionalKeys is_set__win_config_;
Float row;
Float col;
Integer width;
@@ -131,7 +131,7 @@ typedef struct {
Boolean noautocmd;
Boolean fixed;
Boolean hide;
-} Dict(float_config);
+} Dict(win_config);
typedef struct {
Boolean is_lua;
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index fce4a85804..8128fdf67b 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -263,10 +263,10 @@ void nvim_set_option_value(uint64_t channel_id, String name, Object value, Dict(
/// @see |nvim_get_commands()|
///
/// @return dictionary of all options
-Dictionary nvim_get_all_options_info(Error *err)
+Dictionary nvim_get_all_options_info(Arena *arena, Error *err)
FUNC_API_SINCE(7)
{
- return get_all_vimoptions();
+ return get_all_vimoptions(arena);
}
/// Gets the option information for one option from arbitrary buffer or window
@@ -302,7 +302,7 @@ Dictionary nvim_get_all_options_info(Error *err)
/// Implies {scope} is "local".
/// @param[out] err Error details, if any
/// @return Option Information
-Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
+Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Arena *arena, Error *err)
FUNC_API_SINCE(11)
{
OptIndex opt_idx = 0;
@@ -317,5 +317,5 @@ Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
buf_T *buf = (req_scope == kOptReqBuf) ? (buf_T *)from : curbuf;
win_T *win = (req_scope == kOptReqWin) ? (win_T *)from : curwin;
- return get_vimoption(name, scope, buf, win, err);
+ return get_vimoption(name, scope, buf, win, arena, err);
}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index cc95f46baf..8b45af7c71 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -425,12 +425,12 @@ String cstrn_as_string(char *str, size_t maxsize)
/// @param str the C string to use
/// @return The resulting String, or an empty String if
/// str was NULL
-String cstr_as_string(char *str) FUNC_ATTR_PURE
+String cstr_as_string(const char *str) FUNC_ATTR_PURE
{
if (str == NULL) {
return (String)STRING_INIT;
}
- return (String){ .data = str, .size = strlen(str) };
+ return (String){ .data = (char *)str, .size = strlen(str) };
}
/// Return the owned memory of a ga as a String
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 0dbe3d2fb6..9ee812f45c 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -32,7 +32,8 @@
#define CSTR_AS_OBJ(s) STRING_OBJ(cstr_as_string(s))
#define CSTR_TO_OBJ(s) STRING_OBJ(cstr_to_string(s))
-#define CSTR_TO_ARENA_OBJ(arena, s) STRING_OBJ(arena_string(arena, cstr_as_string(s)))
+#define CSTR_TO_ARENA_STR(arena, s) arena_string(arena, cstr_as_string(s))
+#define CSTR_TO_ARENA_OBJ(arena, s) STRING_OBJ(CSTR_TO_ARENA_STR(arena, s))
#define BUFFER_OBJ(s) ((Object) { \
.type = kObjectTypeBuffer, \
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index f955b315a8..5c8ebfb861 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -247,10 +247,9 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona
void ui_attach(uint64_t channel_id, Integer width, Integer height, Boolean enable_rgb, Error *err)
FUNC_API_DEPRECATED_SINCE(1)
{
- Dictionary opts = ARRAY_DICT_INIT;
- PUT(opts, "rgb", BOOLEAN_OBJ(enable_rgb));
+ MAXSIZE_TEMP_DICT(opts, 1);
+ PUT_C(opts, "rgb", BOOLEAN_OBJ(enable_rgb));
nvim_ui_attach(channel_id, width, height, opts, err);
- api_free_dictionary(opts);
}
/// Tells the nvim server if focus was gained or lost by the GUI
@@ -789,7 +788,7 @@ void remote_ui_hl_attr_define(UI *ui, Integer id, HlAttrs rgb_attrs, HlAttrs cte
// system. So we add them here.
if (rgb_attrs.url >= 0) {
const char *url = hl_get_url((uint32_t)rgb_attrs.url);
- PUT_C(rgb, "url", STRING_OBJ(cstr_as_string((char *)url)));
+ PUT_C(rgb, "url", CSTR_AS_OBJ(url));
}
ADD_C(args, DICTIONARY_OBJ(rgb));
@@ -857,7 +856,7 @@ void remote_ui_put(UI *ui, const char *cell)
UIData *data = ui->data;
data->client_col++;
Array args = data->call_buf;
- ADD_C(args, CSTR_AS_OBJ((char *)cell));
+ ADD_C(args, CSTR_AS_OBJ(cell));
push_call(ui, "put", args);
}
@@ -1113,9 +1112,3 @@ void remote_ui_event(UI *ui, char *name, Array args)
free_ret:
arena_mem_free(arena_finish(&arena));
}
-
-void remote_ui_inspect(UI *ui, Dictionary *info)
-{
- UIData *data = ui->data;
- PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id));
-}
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 1453de30d4..a47694a0cf 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1866,10 +1866,10 @@ Dictionary nvim__stats(Arena *arena)
/// - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
/// - "ext_..." Requested UI extensions, see |ui-option|
/// - "chan" |channel-id| of remote UI
-Array nvim_list_uis(void)
+Array nvim_list_uis(Arena *arena)
FUNC_API_SINCE(4)
{
- return ui_array();
+ return ui_array(arena);
}
/// Gets the immediate children of process `pid`.
@@ -2005,7 +2005,7 @@ Array nvim__inspect_cell(Integer grid, Integer row, Integer col, Arena *arena, E
ADD_C(ret, DICTIONARY_OBJ(hl_get_attr_by_id(attr, true, arena, err)));
// will not work first time
if (!highlight_use_hlstate()) {
- ADD_C(ret, ARRAY_OBJ(hl_inspect(attr)));
+ ADD_C(ret, ARRAY_OBJ(hl_inspect(attr, arena)));
}
return ret;
}
@@ -2289,7 +2289,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *
opts->use_winbar, stc_hl_id);
PUT_C(hl_info, "start", INTEGER_OBJ(0));
- PUT_C(hl_info, "group", CSTR_AS_OBJ((char *)grpname));
+ PUT_C(hl_info, "group", CSTR_AS_OBJ(grpname));
ADD_C(hl_values, DICTIONARY_OBJ(hl_info));
}
@@ -2308,7 +2308,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *
snprintf(user_group, sizeof(user_group), "User%d", sp->userhl);
grpname = arena_memdupz(arena, user_group, strlen(user_group));
}
- PUT_C(hl_info, "group", CSTR_AS_OBJ((char *)grpname));
+ PUT_C(hl_info, "group", CSTR_AS_OBJ(grpname));
ADD_C(hl_values, DICTIONARY_OBJ(hl_info));
}
PUT_C(result, "highlights", ARRAY_OBJ(hl_values));
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index a9d7a8d05c..8841bd225b 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -200,10 +200,10 @@
/// @param[out] err Error details, if any
///
/// @return Window handle, or 0 on error
-Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, Error *err)
+Window nvim_open_win(Buffer buffer, Boolean enter, Dict(win_config) *config, Error *err)
FUNC_API_SINCE(6) FUNC_API_TEXTLOCK_ALLOW_CMDWIN
{
-#define HAS_KEY_X(d, key) HAS_KEY(d, float_config, key)
+#define HAS_KEY_X(d, key) HAS_KEY(d, win_config, key)
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
return 0;
@@ -213,7 +213,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E
return 0;
}
- FloatConfig fconfig = FLOAT_CONFIG_INIT;
+ WinConfig fconfig = WIN_CONFIG_INIT;
if (!parse_float_config(config, &fconfig, false, true, err)) {
return 0;
}
@@ -332,10 +332,10 @@ static int win_split_flags(WinSplit split, bool toplevel)
/// @param config Map defining the window configuration,
/// see |nvim_open_win()|
/// @param[out] err Error details, if any
-void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err)
+void nvim_win_set_config(Window window, Dict(win_config) *config, Error *err)
FUNC_API_SINCE(6)
{
-#define HAS_KEY_X(d, key) HAS_KEY(d, float_config, key)
+#define HAS_KEY_X(d, key) HAS_KEY(d, win_config, key)
win_T *win = find_window_by_handle(window, err);
if (!win) {
return;
@@ -345,7 +345,7 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err)
bool has_split = HAS_KEY_X(config, split);
bool has_vertical = HAS_KEY_X(config, vertical);
// reuse old values, if not overridden
- FloatConfig fconfig = win->w_float_config;
+ WinConfig fconfig = win->w_float_config;
bool to_split = config->relative.size == 0
&& !(HAS_KEY_X(config, external) ? config->external : fconfig.external)
@@ -539,8 +539,8 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err)
#undef HAS_KEY_X
}
-#define PUT_KEY_X(d, key, value) PUT_KEY(d, float_config, key, value)
-static void config_put_bordertext(Dict(float_config) *config, FloatConfig *fconfig,
+#define PUT_KEY_X(d, key, value) PUT_KEY(d, win_config, key, value)
+static void config_put_bordertext(Dict(win_config) *config, WinConfig *fconfig,
BorderTextType bordertext_type, Arena *arena)
{
VirtText vt;
@@ -591,7 +591,7 @@ static void config_put_bordertext(Dict(float_config) *config, FloatConfig *fconf
/// @param window Window handle, or 0 for current window
/// @param[out] err Error details, if any
/// @return Map defining the window configuration, see |nvim_open_win()|
-Dict(float_config) nvim_win_get_config(Window window, Arena *arena, Error *err)
+Dict(win_config) nvim_win_get_config(Window window, Arena *arena, Error *err)
FUNC_API_SINCE(6)
{
/// Keep in sync with FloatRelative in buffer_defs.h
@@ -600,14 +600,14 @@ Dict(float_config) nvim_win_get_config(Window window, Arena *arena, Error *err)
/// Keep in sync with WinSplit in buffer_defs.h
static const char *const win_split_str[] = { "left", "right", "above", "below" };
- Dict(float_config) rv = { 0 };
+ Dict(win_config) rv = { 0 };
win_T *wp = find_window_by_handle(window, err);
if (!wp) {
return rv;
}
- FloatConfig *config = &wp->w_float_config;
+ WinConfig *config = &wp->w_float_config;
PUT_KEY_X(rv, focusable, config->focusable);
PUT_KEY_X(rv, external, config->external);
@@ -626,7 +626,7 @@ Dict(float_config) nvim_win_get_config(Window window, Arena *arena, Error *err)
PUT_KEY_X(rv, bufpos, pos);
}
}
- PUT_KEY_X(rv, anchor, cstr_as_string((char *)float_anchor_str[config->anchor]));
+ PUT_KEY_X(rv, anchor, cstr_as_string(float_anchor_str[config->anchor]));
PUT_KEY_X(rv, row, config->row);
PUT_KEY_X(rv, col, config->col);
PUT_KEY_X(rv, zindex, config->zindex);
@@ -659,12 +659,12 @@ Dict(float_config) nvim_win_get_config(Window window, Arena *arena, Error *err)
PUT_KEY_X(rv, width, wp->w_width);
PUT_KEY_X(rv, height, wp->w_height);
WinSplit split = win_split_dir(wp);
- PUT_KEY_X(rv, split, cstr_as_string((char *)win_split_str[split]));
+ PUT_KEY_X(rv, split, cstr_as_string(win_split_str[split]));
}
const char *rel = (wp->w_floating && !config->external
? float_relative_str[config->relative] : "");
- PUT_KEY_X(rv, relative, cstr_as_string((char *)rel));
+ PUT_KEY_X(rv, relative, cstr_as_string(rel));
return rv;
}
@@ -734,8 +734,8 @@ static bool parse_float_bufpos(Array bufpos, lpos_T *out)
return true;
}
-static void parse_bordertext(Object bordertext, BorderTextType bordertext_type,
- FloatConfig *fconfig, Error *err)
+static void parse_bordertext(Object bordertext, BorderTextType bordertext_type, WinConfig *fconfig,
+ Error *err)
{
if (bordertext.type != kObjectTypeString && bordertext.type != kObjectTypeArray) {
api_set_error(err, kErrorTypeValidation, "title/footer must be string or array");
@@ -793,7 +793,7 @@ static void parse_bordertext(Object bordertext, BorderTextType bordertext_type,
}
static bool parse_bordertext_pos(String bordertext_pos, BorderTextType bordertext_type,
- FloatConfig *fconfig, Error *err)
+ WinConfig *fconfig, Error *err)
{
AlignTextPos *align;
switch (bordertext_type) {
@@ -832,7 +832,7 @@ static bool parse_bordertext_pos(String bordertext_pos, BorderTextType bordertex
return true;
}
-static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
+static void parse_border_style(Object style, WinConfig *fconfig, Error *err)
{
struct {
const char *name;
@@ -937,10 +937,10 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
}
}
-static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig, bool reconf,
+static bool parse_float_config(Dict(win_config) *config, WinConfig *fconfig, bool reconf,
bool new_win, Error *err)
{
-#define HAS_KEY_X(d, key) HAS_KEY(d, float_config, key)
+#define HAS_KEY_X(d, key) HAS_KEY(d, win_config, key)
bool has_relative = false, relative_is_win = false, is_split = false;
if (config->relative.size > 0) {
if (!parse_float_relative(config->relative, &fconfig->relative)) {
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c
index e9108f72cc..a02c22deae 100644
--- a/src/nvim/arglist.c
+++ b/src/nvim/arglist.c
@@ -1093,11 +1093,6 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
// When the ":tab" modifier was used do this for all tab pages.
arg_all_close_unused_windows(&aall);
- // Now set the last used tabpage to where we started.
- if (valid_tabpage(new_lu_tp)) {
- lastused_tabpage = new_lu_tp;
- }
-
// Open a window for files in the argument list that don't have one.
// ARGCOUNT may change while doing this, because of autocommands.
if (count > aall.opened_len || count <= 0) {
@@ -1134,6 +1129,12 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
if (valid_tabpage(aall.new_curtab)) {
goto_tabpage_tp(aall.new_curtab, true, true);
}
+
+ // Now set the last used tabpage to where we started.
+ if (valid_tabpage(new_lu_tp)) {
+ lastused_tabpage = new_lu_tp;
+ }
+
if (win_valid(aall.new_curwin)) {
win_enter(aall.new_curwin, false);
}
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index a385161beb..8c7831688f 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -121,7 +121,7 @@ static void augroup_map_del(int id, const char *name)
{
if (name != NULL) {
String key;
- map_del(String, int)(&map_augroup_name_to_id, cstr_as_string((char *)name), &key);
+ map_del(String, int)(&map_augroup_name_to_id, cstr_as_string(name), &key);
api_free_string(key);
}
if (id > 0) {
@@ -476,7 +476,7 @@ void augroup_del(char *name, bool stupid_legacy_mode)
int augroup_find(const char *name)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- int existing_id = map_get(String, int)(&map_augroup_name_to_id, cstr_as_string((char *)name));
+ int existing_id = map_get(String, int)(&map_augroup_name_to_id, cstr_as_string(name));
if (existing_id == AUGROUP_DELETED) {
return existing_id;
}
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index ea014c3918..adbece20f2 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -941,19 +941,19 @@ typedef struct {
bool noautocmd;
bool fixed;
bool hide;
-} FloatConfig;
-
-#define FLOAT_CONFIG_INIT ((FloatConfig){ .height = 0, .width = 0, \
- .bufpos = { -1, 0 }, \
- .row = 0, .col = 0, .anchor = 0, \
- .relative = 0, .external = false, \
- .focusable = true, \
- .split = 0, \
- .zindex = kZIndexFloatDefault, \
- .style = kWinStyleUnused, \
- .noautocmd = false, \
- .hide = false, \
- .fixed = false })
+} WinConfig;
+
+#define WIN_CONFIG_INIT ((WinConfig){ .height = 0, .width = 0, \
+ .bufpos = { -1, 0 }, \
+ .row = 0, .col = 0, .anchor = 0, \
+ .relative = 0, .external = false, \
+ .focusable = true, \
+ .split = 0, \
+ .zindex = kZIndexFloatDefault, \
+ .style = kWinStyleUnused, \
+ .noautocmd = false, \
+ .hide = false, \
+ .fixed = false })
// Structure to store last cursor position and topline. Used by check_lnums()
// and reset_lnums().
@@ -1278,7 +1278,7 @@ struct window_S {
bool w_pos_changed; // true if window position changed
bool w_floating; ///< whether the window is floating
bool w_float_is_info; // the floating window is info float
- FloatConfig w_float_config;
+ WinConfig w_float_config;
// w_fraction is the fractional row of the cursor within the window, from
// 0 at the top row to FRACTION_MULT at the last row.
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 05148801f4..1dc1208696 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -962,10 +962,11 @@ Dictionary channel_info(uint64_t id)
}
/// Simple int64_t comparison function for use with qsort()
-static int int64_t_cmp(const void *a, const void *b)
+static int int64_t_cmp(const void *pa, const void *pb)
{
- int64_t diff = *(int64_t *)a - *(int64_t *)b;
- return (diff < 0) ? -1 : (diff > 0);
+ const int64_t a = *(const int64_t *)pa;
+ const int64_t b = *(const int64_t *)pb;
+ return a == b ? 0 : a > b ? 1 : -1;
}
Array channel_all_info(void)
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index a593b8eda1..9767c44897 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -673,10 +673,20 @@ int sign_item_cmp(const void *p1, const void *p2)
{
const SignItem *s1 = (SignItem *)p1;
const SignItem *s2 = (SignItem *)p2;
- int n = s2->sh->priority - s1->sh->priority;
- return n ? n : (n = (int)(s2->id - s1->id))
- ? n : (s2->sh->sign_add_id - s1->sh->sign_add_id);
+ if (s1->sh->priority != s2->sh->priority) {
+ return s1->sh->priority < s2->sh->priority ? 1 : -1;
+ }
+
+ if (s1->id != s2->id) {
+ return s1->id < s2->id ? 1 : -1;
+ }
+
+ if (s1->sh->sign_add_id != s2->sh->sign_add_id) {
+ return s1->sh->sign_add_id > s2->sh->sign_add_id ? 1 : -1;
+ }
+
+ return 0;
}
static const uint32_t sign_filter[4] = {[kMTMetaSignText] = kMTFilterSelect,
@@ -977,12 +987,12 @@ void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name, Are
}
if (sh_hl.url != NULL) {
- PUT_C(*dict, "url", STRING_OBJ(cstr_as_string((char *)sh_hl.url)));
+ PUT_C(*dict, "url", STRING_OBJ(cstr_as_string(sh_hl.url)));
}
if (virt_text) {
if (virt_text->hl_mode) {
- PUT_C(*dict, "hl_mode", CSTR_AS_OBJ((char *)hl_mode_str[virt_text->hl_mode]));
+ PUT_C(*dict, "hl_mode", CSTR_AS_OBJ(hl_mode_str[virt_text->hl_mode]));
}
Array chunks = virt_text_to_array(virt_text->data.virt_text, hl_name, arena);
@@ -992,7 +1002,7 @@ void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name, Are
if (virt_text->pos == kVPosWinCol) {
PUT_C(*dict, "virt_text_win_col", INTEGER_OBJ(virt_text->col));
}
- PUT_C(*dict, "virt_text_pos", CSTR_AS_OBJ((char *)virt_text_pos_str[virt_text->pos]));
+ PUT_C(*dict, "virt_text_pos", CSTR_AS_OBJ(virt_text_pos_str[virt_text->pos]));
priority = virt_text->priority;
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 41df039b85..b7b32883c2 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -363,7 +363,13 @@ static void insert_enter(InsertState *s)
ins_apply_autocmds(EVENT_INSERTLEAVE);
}
did_cursorhold = false;
- curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
+
+ // ins_redraw() triggers TextChangedI only when no characters
+ // are in the typeahead buffer, so only reset curbuf->b_last_changedtick
+ // if the TextChangedI was not blocked by char_avail() (e.g. using :norm!)
+ if (!char_avail()) {
+ curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
+ }
}
static int insert_check(VimState *state)
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 655d6c9ab3..e4d2a219d9 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2093,8 +2093,8 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
flags = tv_get_string_buf(&argvars[1], nbuf);
}
- nvim_feedkeys(cstr_as_string((char *)keys),
- cstr_as_string((char *)flags), true);
+ nvim_feedkeys(cstr_as_string(keys),
+ cstr_as_string(flags), true);
}
/// "filereadable()" function
@@ -4528,7 +4528,7 @@ static void f_luaeval(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
- nlua_typval_eval(cstr_as_string((char *)str), &argvars[1], rettv);
+ nlua_typval_eval(cstr_as_string(str), &argvars[1], rettv);
}
static void find_some_match(typval_T *const argvars, typval_T *const rettv,
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index e265dc139a..70146a8602 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -406,18 +406,16 @@ static int sort_compare(const void *s1, const void *s2)
// number.
if (sort_nr) {
if (l1.st_u.num.is_number != l2.st_u.num.is_number) {
- result = l1.st_u.num.is_number - l2.st_u.num.is_number;
+ result = l1.st_u.num.is_number > l2.st_u.num.is_number ? 1 : -1;
} else {
result = l1.st_u.num.value == l2.st_u.num.value
? 0
- : l1.st_u.num.value > l2.st_u.num.value
- ? 1
- : -1;
+ : l1.st_u.num.value > l2.st_u.num.value ? 1 : -1;
}
} else if (sort_flt) {
result = l1.st_u.value_flt == l2.st_u.value_flt
- ? 0 : l1.st_u.value_flt > l2.st_u.value_flt
- ? 1 : -1;
+ ? 0
+ : l1.st_u.value_flt > l2.st_u.value_flt ? 1 : -1;
} else {
// We need to copy one line into "sortbuf1", because there is no
// guarantee that the first pointer becomes invalid when obtaining the
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index a06e9fe542..22f7daa823 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -978,7 +978,7 @@ EXTERN const char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"
EXTERN const char line_msg[] INIT(= N_(" line "));
-EXTERN FILE *time_fd INIT(= NULL); // where to write startup timing
+EXTERN FILE *time_fd INIT(= NULL); // Where to write --startuptime report.
// Some compilers warn for not using a return value, but in some situations we
// can't do anything useful with the value. Assign to this variable to avoid
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 17d743784f..1dc06ec988 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -116,12 +116,13 @@ retry: {}
// new attr id, send event to remote ui:s
int id = (int)k;
- Array inspect = hl_inspect(id);
+ Arena arena = ARENA_EMPTY;
+ Array inspect = hl_inspect(id, &arena);
// Note: internally we don't distinguish between cterm and rgb attributes,
// remote_ui_hl_attr_define will however.
ui_call_hl_attr_define(id, entry.attr, entry.attr, inspect);
- api_free_array(inspect);
+ arena_mem_free(arena_finish(&arena));
return id;
}
@@ -129,13 +130,14 @@ retry: {}
void ui_send_all_hls(UI *ui)
{
for (size_t i = 1; i < set_size(&attr_entries); i++) {
- Array inspect = hl_inspect((int)i);
+ Arena arena = ARENA_EMPTY;
+ Array inspect = hl_inspect((int)i, &arena);
HlAttrs attr = attr_entry(i).attr;
remote_ui_hl_attr_define(ui, (Integer)i, attr, attr, inspect);
- api_free_array(inspect);
+ arena_mem_free(arena_finish(&arena));
}
for (size_t hlf = 0; hlf < HLF_COUNT; hlf++) {
- remote_ui_hl_group_set(ui, cstr_as_string((char *)hlf_names[hlf]),
+ remote_ui_hl_group_set(ui, cstr_as_string(hlf_names[hlf]),
highlight_attr[hlf]);
}
}
@@ -204,7 +206,7 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
if (!valid_item && p->hl_def != LUA_NOREF && !recursive) {
MAXSIZE_TEMP_ARRAY(args, 3);
ADD_C(args, INTEGER_OBJ((Integer)ns_id));
- ADD_C(args, CSTR_TO_OBJ(syn_id2name(hl_id)));
+ ADD_C(args, CSTR_AS_OBJ(syn_id2name(hl_id)));
ADD_C(args, BOOLEAN_OBJ(link));
// TODO(bfredl): preload the "global" attr dict?
@@ -1176,17 +1178,30 @@ int object_to_color(Object val, char *key, bool rgb, Error *err)
}
}
-Array hl_inspect(int attr)
+Array hl_inspect(int attr, Arena *arena)
{
- // TODO(bfredl): use arena allocation
- Array ret = ARRAY_DICT_INIT;
- if (hlstate_active) {
- hl_inspect_impl(&ret, attr);
+ if (!hlstate_active) {
+ return (Array)ARRAY_DICT_INIT;
}
+ Array ret = arena_array(arena, hl_inspect_size(attr));
+ hl_inspect_impl(&ret, attr, arena);
return ret;
}
-static void hl_inspect_impl(Array *arr, int attr)
+static size_t hl_inspect_size(int attr)
+{
+ if (attr <= 0 || attr >= (int)set_size(&attr_entries)) {
+ return 0;
+ }
+
+ HlEntry e = attr_entry(attr);
+ if (e.kind == kHlCombine || e.kind == kHlBlend || e.kind == kHlBlendThrough) {
+ return hl_inspect_size(e.id1) + hl_inspect_size(e.id2);
+ }
+ return 1;
+}
+
+static void hl_inspect_impl(Array *arr, int attr, Arena *arena)
{
Dictionary item = ARRAY_DICT_INIT;
if (attr <= 0 || attr >= (int)set_size(&attr_entries)) {
@@ -1196,35 +1211,36 @@ static void hl_inspect_impl(Array *arr, int attr)
HlEntry e = attr_entry(attr);
switch (e.kind) {
case kHlSyntax:
- PUT(item, "kind", CSTR_TO_OBJ("syntax"));
- PUT(item, "hi_name",
- CSTR_TO_OBJ(syn_id2name(e.id1)));
+ item = arena_dict(arena, 3);
+ PUT_C(item, "kind", CSTR_AS_OBJ("syntax"));
+ PUT_C(item, "hi_name", CSTR_AS_OBJ(syn_id2name(e.id1)));
break;
case kHlUI:
- PUT(item, "kind", CSTR_TO_OBJ("ui"));
+ item = arena_dict(arena, 4);
+ PUT_C(item, "kind", CSTR_AS_OBJ("ui"));
const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
- PUT(item, "ui_name", CSTR_TO_OBJ(ui_name));
- PUT(item, "hi_name",
- CSTR_TO_OBJ(syn_id2name(e.id2)));
+ PUT_C(item, "ui_name", CSTR_AS_OBJ(ui_name));
+ PUT_C(item, "hi_name", CSTR_AS_OBJ(syn_id2name(e.id2)));
break;
case kHlTerminal:
- PUT(item, "kind", CSTR_TO_OBJ("term"));
+ item = arena_dict(arena, 2);
+ PUT_C(item, "kind", CSTR_AS_OBJ("term"));
break;
case kHlCombine:
case kHlBlend:
case kHlBlendThrough:
// attribute combination is associative, so flatten to an array
- hl_inspect_impl(arr, e.id1);
- hl_inspect_impl(arr, e.id2);
+ hl_inspect_impl(arr, e.id1, arena);
+ hl_inspect_impl(arr, e.id2, arena);
return;
case kHlUnknown:
case kHlInvalid:
return;
}
- PUT(item, "id", INTEGER_OBJ(attr));
- ADD(*arr, DICTIONARY_OBJ(item));
+ PUT_C(item, "id", INTEGER_OBJ(attr));
+ ADD_C(*arr, DICTIONARY_OBJ(item));
}
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 67b33e6ef7..a1ce206a2b 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -2241,7 +2241,7 @@ void highlight_changed(void)
HlAttrs attrs = syn_attr2entry(highlight_attr[hlf]);
msg_grid.blending = attrs.hl_blend > -1;
}
- ui_call_hl_group_set(cstr_as_string((char *)hlf_names[hlf]),
+ ui_call_hl_group_set(cstr_as_string(hlf_names[hlf]),
highlight_attr[hlf]);
highlight_attr_last[hlf] = highlight_attr[hlf];
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index f858313682..f2893dc9e3 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -399,6 +399,7 @@ int main(int argc, char **argv)
}
if (ui_client_channel_id) {
+ time_finish();
ui_client_run(remote_ui); // NORETURN
}
assert(!ui_client_channel_id && !use_builtin_ui);
@@ -695,6 +696,9 @@ void getout(int exitval)
assert(!ui_client_channel_id);
exiting = true;
+ // make sure startuptimes have been flushed
+ time_finish();
+
// On error during Ex mode, exit with a non-zero code.
// POSIX requires this, although it's not 100% clear from the standard.
if (exmode_active) {
@@ -1495,9 +1499,16 @@ static void init_params(mparm_T *paramp, int argc, char **argv)
/// Initialize global startuptime file if "--startuptime" passed as an argument.
static void init_startuptime(mparm_T *paramp)
{
+ bool is_embed = false;
+ for (int i = 1; i < paramp->argc - 1; i++) {
+ if (STRICMP(paramp->argv[i], "--embed") == 0) {
+ is_embed = true;
+ break;
+ }
+ }
for (int i = 1; i < paramp->argc - 1; i++) {
if (STRICMP(paramp->argv[i], "--startuptime") == 0) {
- time_fd = fopen(paramp->argv[i + 1], "a");
+ time_init(paramp->argv[i + 1], is_embed ? "Embedded" : "Primary/TUI");
time_start("--- NVIM STARTING ---");
break;
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 8583b236c7..fd353d8a67 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -2792,8 +2792,10 @@ static int tv_nr_compare(const void *a1, const void *a2)
{
const listitem_T *const li1 = tv_list_first(*(const list_T **)a1);
const listitem_T *const li2 = tv_list_first(*(const list_T **)a2);
+ const varnumber_T n1 = TV_LIST_ITEM_TV(li1)->vval.v_number;
+ const varnumber_T n2 = TV_LIST_ITEM_TV(li2)->vval.v_number;
- return (int)(TV_LIST_ITEM_TV(li1)->vval.v_number - TV_LIST_ITEM_TV(li2)->vval.v_number);
+ return n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
}
/// "setcellwidths()" function
diff --git a/src/nvim/message.c b/src/nvim/message.c
index cb89d34e23..991ed65ffe 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3017,7 +3017,7 @@ void msg_ext_ui_flush(void)
msg_ext_emit_chunk();
if (msg_ext_chunks.size > 0) {
- ui_call_msg_show(cstr_as_string((char *)msg_ext_kind),
+ ui_call_msg_show(cstr_as_string(msg_ext_kind),
msg_ext_chunks, msg_ext_overwrite);
if (!msg_ext_overwrite) {
msg_ext_visible++;
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 0178ef622b..36fa7e77fc 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -547,7 +547,7 @@ static void send_error(Channel *chan, MsgpackRpcRequestHandler handler, MessageT
static void send_request(Channel *channel, uint32_t id, const char *name, Array args)
{
- const String method = cstr_as_string((char *)name);
+ const String method = cstr_as_string(name);
channel_write(channel, serialize_request(channel->id,
id,
method,
@@ -558,7 +558,7 @@ static void send_request(Channel *channel, uint32_t id, const char *name, Array
static void send_event(Channel *channel, const char *name, Array args)
{
- const String method = cstr_as_string((char *)name);
+ const String method = cstr_as_string(name);
channel_write(channel, serialize_request(channel->id,
0,
method,
@@ -583,7 +583,7 @@ static void broadcast_event(const char *name, Array args)
goto end;
}
- const String method = cstr_as_string((char *)name);
+ const String method = cstr_as_string(name);
WBuffer *buffer = serialize_request(0,
0,
method,
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 9966e6129c..d69e43e6b3 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -375,7 +375,7 @@ static int nv_compare(const void *s1, const void *s2)
if (c2 < 0) {
c2 = -c2;
}
- return c1 - c2;
+ return c1 == c2 ? 0 : c1 > c2 ? 1 : -1;
}
/// Initialize the nv_cmd_idx[] table.
@@ -1451,9 +1451,7 @@ static int normal_check(VimState *state)
// has been done, close any file for startup messages.
if (time_fd != NULL) {
TIME_MSG("first screen update");
- TIME_MSG("--- NVIM STARTED ---");
- fclose(time_fd);
- time_fd = NULL;
+ time_finish();
}
// After the first screen update may start triggering WinScrolled
// autocmd events. Store all the scroll positions and sizes now.
diff --git a/src/nvim/option.c b/src/nvim/option.c
index db013b460e..cdb27fcd1c 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -6314,32 +6314,33 @@ int get_sidescrolloff_value(win_T *wp)
return (int)(wp->w_p_siso < 0 ? p_siso : wp->w_p_siso);
}
-Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Error *err)
+Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Arena *arena, Error *err)
{
OptIndex opt_idx = find_option_len(name.data, name.size);
VALIDATE_S(opt_idx != kOptInvalid, "option (not found)", name.data, {
return (Dictionary)ARRAY_DICT_INIT;
});
- return vimoption2dict(&options[opt_idx], scope, buf, win);
+ return vimoption2dict(&options[opt_idx], scope, buf, win, arena);
}
-Dictionary get_all_vimoptions(void)
+Dictionary get_all_vimoptions(Arena *arena)
{
- Dictionary retval = ARRAY_DICT_INIT;
+ Dictionary retval = arena_dict(arena, kOptIndexCount);
for (OptIndex opt_idx = 0; opt_idx < kOptIndexCount; opt_idx++) {
- Dictionary opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin);
- PUT(retval, options[opt_idx].fullname, DICTIONARY_OBJ(opt_dict));
+ Dictionary opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin, arena);
+ PUT_C(retval, options[opt_idx].fullname, DICTIONARY_OBJ(opt_dict));
}
return retval;
}
-static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win)
+static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win,
+ Arena *arena)
{
- Dictionary dict = ARRAY_DICT_INIT;
+ Dictionary dict = arena_dict(arena, 13);
- PUT(dict, "name", CSTR_TO_OBJ(opt->fullname));
- PUT(dict, "shortname", CSTR_TO_OBJ(opt->shortname));
+ PUT_C(dict, "name", CSTR_AS_OBJ(opt->fullname));
+ PUT_C(dict, "shortname", CSTR_AS_OBJ(opt->shortname));
const char *scope;
if (opt->indir & PV_BUF) {
@@ -6350,14 +6351,14 @@ static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, wi
scope = "global";
}
- PUT(dict, "scope", CSTR_TO_OBJ(scope));
+ PUT_C(dict, "scope", CSTR_AS_OBJ(scope));
// welcome to the jungle
- PUT(dict, "global_local", BOOLEAN_OBJ(opt->indir & PV_BOTH));
- PUT(dict, "commalist", BOOLEAN_OBJ(opt->flags & P_COMMA));
- PUT(dict, "flaglist", BOOLEAN_OBJ(opt->flags & P_FLAGLIST));
+ PUT_C(dict, "global_local", BOOLEAN_OBJ(opt->indir & PV_BOTH));
+ PUT_C(dict, "commalist", BOOLEAN_OBJ(opt->flags & P_COMMA));
+ PUT_C(dict, "flaglist", BOOLEAN_OBJ(opt->flags & P_FLAGLIST));
- PUT(dict, "was_set", BOOLEAN_OBJ(opt->flags & P_WAS_SET));
+ PUT_C(dict, "was_set", BOOLEAN_OBJ(opt->flags & P_WAS_SET));
LastSet last_set = { .channel_id = 0 };
if (req_scope == OPT_GLOBAL) {
@@ -6375,16 +6376,16 @@ static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, wi
}
}
- PUT(dict, "last_set_sid", INTEGER_OBJ(last_set.script_ctx.sc_sid));
- PUT(dict, "last_set_linenr", INTEGER_OBJ(last_set.script_ctx.sc_lnum));
- PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)last_set.channel_id));
+ PUT_C(dict, "last_set_sid", INTEGER_OBJ(last_set.script_ctx.sc_sid));
+ PUT_C(dict, "last_set_linenr", INTEGER_OBJ(last_set.script_ctx.sc_lnum));
+ PUT_C(dict, "last_set_chan", INTEGER_OBJ((int64_t)last_set.channel_id));
// TODO(bfredl): do you even nocp?
OptVal def = optval_from_varp(get_opt_idx(opt), &opt->def_val);
- PUT(dict, "type", CSTR_TO_OBJ(optval_type_get_name(def.type)));
- PUT(dict, "default", optval_as_object(optval_copy(def)));
- PUT(dict, "allows_duplicates", BOOLEAN_OBJ(!(opt->flags & P_NODUP)));
+ PUT_C(dict, "type", CSTR_AS_OBJ(optval_type_get_name(def.type)));
+ PUT_C(dict, "default", optval_as_object(def));
+ PUT_C(dict, "allows_duplicates", BOOLEAN_OBJ(!(opt->flags & P_NODUP)));
return dict;
}
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 566d51f30a..ade745df2c 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -95,7 +95,7 @@ int os_chdir(const char *path)
}
int err = uv_chdir(path);
if (err == 0) {
- ui_call_chdir(cstr_as_string((char *)path));
+ ui_call_chdir(cstr_as_string(path));
}
return err;
}
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 0350ff6928..d116b46d88 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -488,7 +488,7 @@ void pum_redraw(void)
if (ui_has(kUIMultigrid)) {
const char *anchor = pum_above ? "SW" : "NW";
int row_off = pum_above ? -pum_height : 0;
- ui_call_win_float_pos(pum_grid.handle, -1, cstr_as_string((char *)anchor), pum_anchor_grid,
+ ui_call_win_float_pos(pum_grid.handle, -1, cstr_as_string(anchor), pum_anchor_grid,
pum_row - row_off, pum_left_col, false, pum_grid.zindex);
}
@@ -669,7 +669,7 @@ void pum_redraw(void)
/// @return NULL when no enough room to show
static win_T *pum_create_float_preview(bool enter)
{
- FloatConfig config = FLOAT_CONFIG_INIT;
+ WinConfig config = WIN_CONFIG_INIT;
config.relative = kFloatRelativeEditor;
// when pum_above is SW otherwise is NW
config.anchor = pum_above ? kFloatAnchorSouth : 0;
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index f7776ef74f..b88b08d3f0 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -45,6 +45,7 @@ typedef struct {
#define PRL_ITEM(si, idx) (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
static proftime_T prof_wait_time;
+static char *startuptime_buf = NULL; // --startuptime buffer
/// Gets the current time.
///
@@ -907,7 +908,7 @@ void time_start(const char *message)
// initialize the global variables
g_prev_time = g_start_time = profile_start();
- fprintf(time_fd, "\n\ntimes in msec\n");
+ fprintf(time_fd, "\ntimes in msec\n");
fprintf(time_fd, " clock self+sourced self: sourced script\n");
fprintf(time_fd, " clock elapsed: other lines\n\n");
@@ -944,3 +945,47 @@ void time_msg(const char *mesg, const proftime_T *start)
g_prev_time = now;
fprintf(time_fd, ": %s\n", mesg);
}
+
+/// Initializes the `time_fd` stream for the --startuptime report.
+///
+/// @param fname startuptime report file path
+/// @param process_name name of the current Nvim process to write in the report.
+void time_init(const char *fname, const char *process_name)
+{
+ const size_t bufsize = 8192; // Big enough for the entire --startuptime report.
+ time_fd = fopen(fname, "a");
+ if (time_fd == NULL) {
+ semsg(_(e_notopen), fname);
+ return;
+ }
+ startuptime_buf = xmalloc(sizeof(char) * (bufsize + 1));
+ // The startuptime file is (potentially) written by multiple Nvim processes concurrently. So each
+ // report is buffered, and flushed to disk (`time_finish`) once after startup. `_IOFBF` mode
+ // ensures the buffer is not auto-flushed ("controlled buffering").
+ int r = setvbuf(time_fd, startuptime_buf, _IOFBF, bufsize + 1);
+ if (r != 0) {
+ XFREE_CLEAR(startuptime_buf);
+ fclose(time_fd);
+ time_fd = NULL;
+ ELOG("time_init: setvbuf failed: %d %s", r, uv_err_name(r));
+ semsg("time_init: setvbuf failed: %d %s", r, uv_err_name(r));
+ return;
+ }
+ fprintf(time_fd, "--- Startup times for process: %s ---\n", process_name);
+}
+
+/// Flushes the startuptimes to disk for the current process
+void time_finish(void)
+{
+ if (time_fd == NULL) {
+ return;
+ }
+ assert(startuptime_buf != NULL);
+ TIME_MSG("--- NVIM STARTED ---\n");
+
+ // flush buffer to disk
+ fclose(time_fd);
+ time_fd = NULL;
+
+ XFREE_CLEAR(startuptime_buf);
+}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 273a924876..48e41c290d 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -3197,7 +3197,11 @@ static int fuzzy_match_item_compare(const void *const s1, const void *const s2)
const int idx1 = ((const fuzzyItem_T *)s1)->idx;
const int idx2 = ((const fuzzyItem_T *)s2)->idx;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2) {
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ } else {
+ return v1 > v2 ? -1 : 1;
+ }
}
/// Fuzzy search the string "str" in a list of "items" and return the matching
@@ -3436,7 +3440,11 @@ static int fuzzy_match_str_compare(const void *const s1, const void *const s2)
const int idx1 = ((fuzmatch_str_T *)s1)->idx;
const int idx2 = ((fuzmatch_str_T *)s2)->idx;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2) {
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ } else {
+ return v1 > v2 ? -1 : 1;
+ }
}
/// Sort fuzzy matches by score
@@ -3465,7 +3473,11 @@ static int fuzzy_match_func_compare(const void *const s1, const void *const s2)
if (*str1 == '<' && *str2 != '<') {
return 1;
}
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2) {
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ } else {
+ return v1 > v2 ? -1 : 1;
+ }
}
/// Sort fuzzy matches of function names by score.
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 61c43e271b..2c8685adc7 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1875,9 +1875,7 @@ static int compare_file_marks(const void *a, const void *b)
const FileMarks *const *const b_fms = b;
return ((*a_fms)->greatest_timestamp == (*b_fms)->greatest_timestamp
? 0
- : ((*a_fms)->greatest_timestamp > (*b_fms)->greatest_timestamp
- ? -1
- : 1));
+ : ((*a_fms)->greatest_timestamp > (*b_fms)->greatest_timestamp ? -1 : 1));
}
/// Parse msgpack object that has given length
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index dc09bcc5a0..bd7979153e 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -55,8 +55,8 @@
# include "sign.c.generated.h"
#endif
-static PMap(cstr_t) sign_map INIT( = MAP_INIT);
-static kvec_t(Integer) sign_ns INIT( = MAP_INIT);
+static PMap(cstr_t) sign_map = MAP_INIT;
+static kvec_t(Integer) sign_ns = KV_INITIAL_VALUE;
static char *cmds[] = {
"define",
@@ -84,7 +84,7 @@ static int64_t group_get_ns(const char *group)
return UINT32_MAX; // All namespaces
}
// Specific or non-existing namespace
- int ns = map_get(String, int)(&namespace_ids, cstr_as_string((char *)group));
+ int ns = map_get(String, int)(&namespace_ids, cstr_as_string(group));
return ns ? ns : -1;
}
@@ -172,20 +172,28 @@ int sign_cmp(const void *p1, const void *p2)
{
const MTKey *s1 = (MTKey *)p1;
const MTKey *s2 = (MTKey *)p2;
- int n = s1->pos.row - s2->pos.row;
- if (n) {
- return n;
+ if (s1->pos.row != s2->pos.row) {
+ return s1->pos.row > s2->pos.row ? 1 : -1;
}
DecorSignHighlight *sh1 = decor_find_sign(mt_decor(*s1));
DecorSignHighlight *sh2 = decor_find_sign(mt_decor(*s2));
assert(sh1 && sh2);
- n = sh2->priority - sh1->priority;
+ if (sh1->priority != sh2->priority) {
+ return sh1->priority < sh2->priority ? 1 : -1;
+ }
+
+ if (s1->id != s2->id) {
+ return s1->id < s2->id ? 1 : -1;
+ }
+
+ if (sh1->sign_add_id != sh2->sign_add_id) {
+ return sh1->sign_add_id < sh2->sign_add_id ? 1 : -1;
+ }
- return n ? n : (n = (int)(s2->id - s1->id))
- ? n : (sh2->sign_add_id - sh1->sign_add_id);
+ return 0;
}
/// Delete the specified sign(s)
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 887ad3a62a..5c0e295f88 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -3221,10 +3221,10 @@ static int sug_compare(const void *s1, const void *s2)
{
suggest_T *p1 = (suggest_T *)s1;
suggest_T *p2 = (suggest_T *)s2;
- int n = p1->st_score - p2->st_score;
+ int n = p1->st_score == p2->st_score ? 0 : p1->st_score > p2->st_score ? 1 : -1;
if (n == 0) {
- n = p1->st_altscore - p2->st_altscore;
+ n = p1->st_altscore == p2->st_altscore ? 0 : p1->st_altscore > p2->st_altscore ? 1 : -1;
if (n == 0) {
n = STRICMP(p1->st_word, p2->st_word);
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 2744f68951..6420f44640 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -229,7 +229,7 @@ void ui_refresh(void)
}
ui_ext[i] = ext_widgets[i];
if (i < kUIGlobalCount) {
- ui_call_option_set(cstr_as_string((char *)ui_ext_names[i]),
+ ui_call_option_set(cstr_as_string(ui_ext_names[i]),
BOOLEAN_OBJ(ext_widgets[i]));
}
}
@@ -451,8 +451,7 @@ void ui_set_ext_option(UI *ui, UIExtension ext, bool active)
return;
}
if (ui_ext_names[ext][0] != '_' || active) {
- remote_ui_option_set(ui, cstr_as_string((char *)ui_ext_names[ext]),
- BOOLEAN_OBJ(active));
+ remote_ui_option_set(ui, cstr_as_string(ui_ext_names[ext]), BOOLEAN_OBJ(active));
}
if (ext == kUITermColors) {
ui_default_colors_set();
@@ -646,34 +645,35 @@ bool ui_has(UIExtension ext)
return ui_ext[ext];
}
-Array ui_array(void)
+Array ui_array(Arena *arena)
{
- Array all_uis = ARRAY_DICT_INIT;
+ Array all_uis = arena_array(arena, ui_count);
for (size_t i = 0; i < ui_count; i++) {
UI *ui = uis[i];
- Dictionary info = ARRAY_DICT_INIT;
- PUT(info, "width", INTEGER_OBJ(ui->width));
- PUT(info, "height", INTEGER_OBJ(ui->height));
- PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb));
- PUT(info, "override", BOOLEAN_OBJ(ui->override));
+ Dictionary info = arena_dict(arena, 10 + kUIExtCount);
+ PUT_C(info, "width", INTEGER_OBJ(ui->width));
+ PUT_C(info, "height", INTEGER_OBJ(ui->height));
+ PUT_C(info, "rgb", BOOLEAN_OBJ(ui->rgb));
+ PUT_C(info, "override", BOOLEAN_OBJ(ui->override));
// TUI fields. (`stdin_fd` is intentionally omitted.)
- PUT(info, "term_name", CSTR_TO_OBJ(ui->term_name));
+ PUT_C(info, "term_name", CSTR_AS_OBJ(ui->term_name));
// term_background is deprecated. Populate with an empty string
- PUT(info, "term_background", CSTR_TO_OBJ(""));
+ PUT_C(info, "term_background", STATIC_CSTR_AS_OBJ(""));
- PUT(info, "term_colors", INTEGER_OBJ(ui->term_colors));
- PUT(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty));
- PUT(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty));
+ PUT_C(info, "term_colors", INTEGER_OBJ(ui->term_colors));
+ PUT_C(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty));
+ PUT_C(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty));
for (UIExtension j = 0; j < kUIExtCount; j++) {
if (ui_ext_names[j][0] != '_' || ui->ui_ext[j]) {
- PUT(info, ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j]));
+ PUT_C(info, (char *)ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j]));
}
}
- remote_ui_inspect(ui, &info);
- ADD(all_uis, DICTIONARY_OBJ(info));
+ PUT_C(info, "chan", INTEGER_OBJ((Integer)ui->data->channel_id));
+
+ ADD_C(all_uis, DICTIONARY_OBJ(info));
}
return all_uis;
}
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index e20c3f6044..729e57cb2b 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -1136,6 +1136,20 @@ bool uc_split_args_iter(const char *arg, size_t arglen, size_t *end, char *buf,
return true;
}
+size_t uc_nargs_upper_bound(const char *arg, size_t arglen)
+{
+ bool was_white = true; // space before first arg
+ size_t nargs = 0;
+ for (size_t i = 0; i < arglen; i++) {
+ bool is_white = ascii_iswhite(arg[i]);
+ if (was_white && !is_white) {
+ nargs++;
+ }
+ was_white = is_white;
+ }
+ return nargs;
+}
+
/// split and quote args for <f-args>
static char *uc_split_args(const char *arg, char **args, const size_t *arglens, size_t argc,
size_t *lenp)
diff --git a/src/nvim/window.c b/src/nvim/window.c
index d07ae22c31..15bd1212ad 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -669,7 +669,7 @@ wingotofile:
beep_flush();
break;
}
- FloatConfig config = FLOAT_CONFIG_INIT;
+ WinConfig config = WIN_CONFIG_INIT;
config.width = curwin->w_width;
config.height = curwin->w_height;
config.external = true;
@@ -763,7 +763,7 @@ void ui_ext_win_position(win_T *wp, bool validate)
return;
}
- FloatConfig c = wp->w_float_config;
+ WinConfig c = wp->w_float_config;
if (!c.external) {
ScreenGrid *grid = &default_grid;
Float row = c.row;
@@ -796,7 +796,7 @@ void ui_ext_win_position(win_T *wp, bool validate)
wp->w_grid_alloc.zindex = wp->w_float_config.zindex;
if (ui_has(kUIMultigrid)) {
- String anchor = cstr_as_string((char *)float_anchor_str[c.anchor]);
+ String anchor = cstr_as_string(float_anchor_str[c.anchor]);
if (!c.hide) {
ui_call_win_float_pos(wp->w_grid_alloc.handle, wp->handle, anchor,
grid->handle, row, col, c.focusable,
@@ -1213,7 +1213,7 @@ win_T *win_split_ins(int size, int flags, win_T *new_wp, int dir)
new_frame(wp);
wp->w_floating = false;
// non-floating window doesn't store float config or have a border.
- wp->w_float_config = FLOAT_CONFIG_INIT;
+ wp->w_float_config = WIN_CONFIG_INIT;
CLEAR_FIELD(wp->w_border_adj);
}
@@ -3879,7 +3879,7 @@ void win_alloc_first(void)
void win_alloc_aucmd_win(int idx)
{
Error err = ERROR_INIT;
- FloatConfig fconfig = FLOAT_CONFIG_INIT;
+ WinConfig fconfig = WIN_CONFIG_INIT;
fconfig.width = Columns;
fconfig.height = 5;
fconfig.focusable = false;
@@ -4983,7 +4983,7 @@ win_T *win_alloc(win_T *after, bool hidden)
new_wp->w_cursor.lnum = 1;
new_wp->w_scbind_pos = 1;
new_wp->w_floating = 0;
- new_wp->w_float_config = FLOAT_CONFIG_INIT;
+ new_wp->w_float_config = WIN_CONFIG_INIT;
new_wp->w_viewport_invalid = true;
new_wp->w_viewport_last_topline = 1;
@@ -7359,9 +7359,17 @@ static bool frame_check_width(const frame_T *topfrp, int width)
}
/// Simple int comparison function for use with qsort()
-static int int_cmp(const void *a, const void *b)
+static int int_cmp(const void *pa, const void *pb)
{
- return *(const int *)a - *(const int *)b;
+ const int a = *(const int *)pa;
+ const int b = *(const int *)pb;
+ if (a > b) {
+ return 1;
+ }
+ if (a < b) {
+ return -1;
+ }
+ return 0;
}
/// Handle setting 'colorcolumn' or 'textwidth' in window "wp".
diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c
index 1d22590ac0..1c9eb4ec5c 100644
--- a/src/nvim/winfloat.c
+++ b/src/nvim/winfloat.c
@@ -38,7 +38,7 @@
/// @param last make the window the last one in the window list.
/// Only used when allocating the autocommand window.
/// @param config must already have been validated!
-win_T *win_new_float(win_T *wp, bool last, FloatConfig fconfig, Error *err)
+win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
{
if (wp == NULL) {
wp = win_alloc(last ? lastwin : lastwin_nofloating(), false);
@@ -138,7 +138,7 @@ int win_border_width(win_T *wp)
return wp->w_border_adj[1] + wp->w_border_adj[3];
}
-void win_config_float(win_T *wp, FloatConfig fconfig)
+void win_config_float(win_T *wp, WinConfig fconfig)
{
wp->w_width = MAX(fconfig.width, 1);
wp->w_height = MAX(fconfig.height, 1);
@@ -233,7 +233,9 @@ void win_config_float(win_T *wp, FloatConfig fconfig)
static int float_zindex_cmp(const void *a, const void *b)
{
- return (*(win_T **)b)->w_float_config.zindex - (*(win_T **)a)->w_float_config.zindex;
+ int za = (*(win_T **)a)->w_float_config.zindex;
+ int zb = (*(win_T **)b)->w_float_config.zindex;
+ return za == zb ? 0 : za < zb ? 1 : -1;
}
void win_float_remove(bool bang, int count)
diff --git a/test/functional/autocmd/textchanged_spec.lua b/test/functional/autocmd/textchanged_spec.lua
index 850d67a18d..d501560dc1 100644
--- a/test/functional/autocmd/textchanged_spec.lua
+++ b/test/functional/autocmd/textchanged_spec.lua
@@ -180,3 +180,14 @@ it('TextChangedI and TextChanged', function()
validate_mixed_textchangedi({ 's', '<esc>' })
validate_mixed_textchangedi({ 'S', '<esc>' })
end)
+
+-- oldtest: Test_TextChanged_with_norm()
+it('TextChanged is triggered after :norm that enters Insert mode', function()
+ exec([[
+ let g:a = 0
+ au TextChanged * let g:a += 1
+ ]])
+ eq(0, eval('g:a'))
+ feed(':norm! ia<CR>')
+ eq(1, eval('g:a'))
+end)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index f4a9c0c8d7..cc58226f48 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -73,6 +73,7 @@ describe('startup', function()
os.remove(testfile)
end)
clear({ args = { '--startuptime', testfile } })
+ assert_log('Embedded', testfile, 100)
assert_log('sourcing', testfile, 100)
assert_log("require%('vim%._editor'%)", testfile, 100)
end)
diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua
index d7f4c71af2..2788e7ae9f 100644
--- a/test/functional/legacy/listlbr_utf8_spec.lua
+++ b/test/functional/legacy/listlbr_utf8_spec.lua
@@ -1,12 +1,14 @@
-- Test for linebreak and list option in utf-8 mode
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local source = helpers.source
local feed = helpers.feed
+local exec = helpers.exec
local clear, expect = helpers.clear, helpers.expect
describe('linebreak', function()
- setup(clear)
+ before_each(clear)
-- luacheck: ignore 621 (Indentation)
-- luacheck: ignore 613 (Trailing whitespaces in a string)
@@ -208,4 +210,29 @@ describe('linebreak', function()
a b c¶
Screen attributes are the same!]])
end)
+
+ -- oldtest: Test_visual_ends_before_showbreak()
+ it("Visual area is correct when it ends before multibyte 'showbreak'", function()
+ local screen = Screen.new(60, 8)
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { background = Screen.colors.LightGrey }, -- Visual
+ [2] = { bold = true }, -- ModeMsg
+ })
+ screen:attach()
+ exec([[
+ let &wrap = v:true
+ let &linebreak = v:true
+ let &showbreak = '↪ '
+ eval ['xxxxx ' .. 'y'->repeat(&columns - 6) .. ' zzzz']->setline(1)
+ normal! wvel
+ ]])
+ screen:expect([[
+ xxxxx |
+ {0:↪ }{1:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}^ {1: }|
+ {0:↪ }zzzz |
+ {0:~ }|*4
+ {2:-- VISUAL --} |
+ ]])
+ end)
end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 9dd5b00b83..d63338845a 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -655,6 +655,20 @@ describe('TUI', function()
end
screen:expect_unchanged()
if esc then
+ feed_data('\027[<64;5;1M')
+ else
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 4)
+ end
+ screen:expect([[
+ {1:p}opup menu test |
+ {4:~ }{14: foo }{4: }|
+ {4:~ }{13: bar }{4: }|
+ {4:~ }{13: baz }{4: }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ if esc then
feed_data('\027[<35;7;4M')
else
api.nvim_input_mouse('move', '', '', 0, 3, 6)
@@ -669,6 +683,20 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
if esc then
+ feed_data('\027[<65;7;4M')
+ else
+ api.nvim_input_mouse('wheel', 'down', '', 0, 3, 6)
+ end
+ screen:expect([[
+ {1:p}opup menu test |
+ {4:~ }{13: foo }{4: }|
+ {4:~ }{14: bar }{4: }|
+ {4:~ }{13: baz }{4: }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ if esc then
feed_data('\027[<0;7;3M')
else
api.nvim_input_mouse('left', 'press', '', 0, 2, 6)
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 6a1b3fb0ed..7f551c5ee5 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -188,6 +188,9 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftMouse><11,0>')
+ -- Prevent the case where screen:expect() with "unchanged" returns too early,
+ -- causing the click position to be overwritten by the next drag.
+ poke_eventloop()
screen:expect {
grid = [[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
@@ -282,6 +285,9 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftMouse><11,0>')
+ -- Prevent the case where screen:expect() with "unchanged" returns too early,
+ -- causing the click position to be overwritten by the next drag.
+ poke_eventloop()
screen:expect {
grid = [[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 1f7d187016..1f0d20f66d 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -3784,9 +3784,7 @@ describe('builtin popupmenu', function()
{n: bar }|
{n: baz }|
]],
- float_pos = {
- [4] = { -1, 'NW', 2, 1, 17, false, 250 },
- },
+ float_pos = { [4] = { -1, 'NW', 2, 1, 17, false, 250 } },
}
else
feed('<RightMouse><18,0>')
@@ -3969,7 +3967,38 @@ describe('builtin popupmenu', function()
end
eq(true, screen.options.mousemoveevent)
if multigrid then
- api.nvim_input_mouse('move', '', '', 2, 3, 6)
+ api.nvim_input_mouse('wheel', 'up', '', 2, 0, 4)
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:--------------------------------]|*5
+ [3:--------------------------------]|
+ ## grid 2
+ ^popup menu test |
+ {1:~ }|*4
+ ## grid 3
+ :let g:menustr = 'foo' |
+ ## grid 4
+ {s: foo }|
+ {n: bar }|
+ {n: baz }|
+ ]],
+ float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
+ })
+ else
+ feed('<ScrollWheelUp><4,0>')
+ screen:expect([[
+ ^popup menu test |
+ {1:~ }{s: foo }{1: }|
+ {1:~ }{n: bar }{1: }|
+ {1:~ }{n: baz }{1: }|
+ {1:~ }|
+ :let g:menustr = 'foo' |
+ ]])
+ end
+ eq(true, screen.options.mousemoveevent)
+ if multigrid then
+ api.nvim_input_mouse('move', '', '', 4, 2, 3)
screen:expect({
grid = [[
## grid 1
@@ -4000,7 +4029,38 @@ describe('builtin popupmenu', function()
end
eq(true, screen.options.mousemoveevent)
if multigrid then
- api.nvim_input_mouse('left', 'press', '', 2, 2, 6)
+ api.nvim_input_mouse('wheel', 'down', '', 4, 2, 3)
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:--------------------------------]|*5
+ [3:--------------------------------]|
+ ## grid 2
+ ^popup menu test |
+ {1:~ }|*4
+ ## grid 3
+ :let g:menustr = 'foo' |
+ ## grid 4
+ {n: foo }|
+ {s: bar }|
+ {n: baz }|
+ ]],
+ float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
+ })
+ else
+ feed('<ScrollWheelDown><6,3>')
+ screen:expect([[
+ ^popup menu test |
+ {1:~ }{n: foo }{1: }|
+ {1:~ }{s: bar }{1: }|
+ {1:~ }{n: baz }{1: }|
+ {1:~ }|
+ :let g:menustr = 'foo' |
+ ]])
+ end
+ eq(true, screen.options.mousemoveevent)
+ if multigrid then
+ api.nvim_input_mouse('left', 'press', '', 4, 1, 3)
screen:expect({
grid = [[
## grid 1
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 7926411dcd..0a28ae6147 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -2533,7 +2533,25 @@ func Test_TextChangedI_with_setline()
call assert_equal('', getline(1))
call assert_equal('', getline(2))
- call test_override('starting', 0)
+ call test_override('char_avail', 0)
+ bwipe!
+endfunc
+
+func Test_TextChanged_with_norm()
+ " For unknown reason this fails on MS-Windows
+ CheckNotMSWindows
+ CheckFeature terminal
+ let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
+ call assert_equal('running', term_getstatus(buf))
+ call term_sendkeys(buf, ":let g:a=0\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":au! TextChanged * :let g:a+=1\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":norm! ia\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":echo g:a\<cr>")
+ call term_wait(buf, 50)
+ call WaitForAssert({-> assert_match('^1.*$', term_getline(buf, 3))})
bwipe!
endfunc
diff --git a/test/old/testdir/test_listlbr_utf8.vim b/test/old/testdir/test_listlbr_utf8.vim
index 1bbbd2d2ae..313ff30cc4 100644
--- a/test/old/testdir/test_listlbr_utf8.vim
+++ b/test/old/testdir/test_listlbr_utf8.vim
@@ -9,6 +9,7 @@ CheckFeature conceal
CheckFeature signs
source view_util.vim
+source screendump.vim
func s:screen_lines(lnum, width) abort
return ScreenLines(a:lnum, a:width)
@@ -358,4 +359,24 @@ func Test_unprintable_char_on_wrap_column()
call s:close_windows()
endfunc
+" Test that Visual selection is drawn correctly when 'linebreak' is set and
+" selection ends before multibyte 'showbreak'.
+func Test_visual_ends_before_showbreak()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ &wrap = true
+ &linebreak = true
+ &showbreak = '↪ '
+ ['xxxxx ' .. 'y'->repeat(&columns - 6) .. ' zzzz']->setline(1)
+ normal! wvel
+ END
+ call writefile(lines, 'XvisualEndsBeforeShowbreak', 'D')
+ let buf = RunVimInTerminal('-S XvisualEndsBeforeShowbreak', #{rows: 6})
+ call VerifyScreenDump(buf, 'Test_visual_ends_before_showbreak', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_tabpage.vim b/test/old/testdir/test_tabpage.vim
index d335f3c1ee..adb9e13269 100644
--- a/test/old/testdir/test_tabpage.vim
+++ b/test/old/testdir/test_tabpage.vim
@@ -156,10 +156,13 @@ func Test_tabpage_drop()
tab split f3
normal! gt
call assert_equal(1, tabpagenr())
+ tab drop f4
+ call assert_equal(1, tabpagenr('#'))
tab drop f3
- call assert_equal(3, tabpagenr())
- call assert_equal(1, tabpagenr('#'))
+ call assert_equal(4, tabpagenr())
+ call assert_equal(2, tabpagenr('#'))
+ bwipe!
bwipe!
bwipe!
bwipe!