aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/notes.md14
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua10
-rw-r--r--src/klib/klist.h8
-rw-r--r--src/nvim/api/command.c10
-rw-r--r--src/nvim/api/options.c4
-rw-r--r--src/nvim/api/private/validate.h9
-rw-r--r--src/nvim/autocmd.c12
-rw-r--r--src/nvim/change.c6
-rw-r--r--src/nvim/channel.c7
-rw-r--r--src/nvim/channel.h2
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/event/multiqueue.c78
-rw-r--r--src/nvim/file_search.c22
-rw-r--r--src/nvim/fileio.c7
-rw-r--r--src/nvim/generators/gen_eval.lua4
-rw-r--r--src/nvim/grid.c30
-rw-r--r--src/nvim/highlight.c2
-rw-r--r--src/nvim/highlight_group.c35
-rw-r--r--src/nvim/insexpand.c54
-rw-r--r--src/nvim/mbyte.c4
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/os/fs.c8
-rw-r--r--src/nvim/regexp_nfa.c6
-rw-r--r--src/nvim/terminal.c10
-rw-r--r--src/nvim/textformat.c14
-rw-r--r--src/nvim/types.h2
-rw-r--r--src/nvim/usercmd.c12
-rw-r--r--test/busted/outputHandlers/nvim.lua4
-rw-r--r--test/functional/editor/fold_spec.lua112
-rw-r--r--test/functional/editor/put_spec.lua39
-rw-r--r--test/functional/lua/diagnostic_spec.lua4
-rw-r--r--test/functional/treesitter/parser_spec.lua44
-rw-r--r--test/functional/ui/float_spec.lua47
-rw-r--r--test/functional/ui/fold_spec.lua26
-rw-r--r--test/functional/ui/highlight_spec.lua17
-rw-r--r--test/unit/fixtures/multiqueue.c8
36 files changed, 421 insertions, 256 deletions
diff --git a/.github/workflows/notes.md b/.github/workflows/notes.md
index 0f8c67da48..2b34c72ffa 100644
--- a/.github/workflows/notes.md
+++ b/.github/workflows/notes.md
@@ -27,12 +27,6 @@ ${NVIM_VERSION}
### Linux (x64)
-#### Tarball
-
-1. Download **nvim-linux64.tar.gz**
-2. Extract: `tar xzvf nvim-linux64.tar.gz`
-3. Run `./nvim-linux64/bin/nvim`
-
#### AppImage
1. Download **nvim.appimage**
2. Run `chmod u+x nvim.appimage && ./nvim.appimage`
@@ -42,6 +36,14 @@ ${NVIM_VERSION}
./squashfs-root/usr/bin/nvim
```
+#### Tarball
+
+*(deprecated)*
+
+1. Download **nvim-linux64.tar.gz**
+2. Extract: `tar xzvf nvim-linux64.tar.gz`
+3. Run `./nvim-linux64/bin/nvim`
+
### Other
- Install by [package manager](https://github.com/neovim/neovim/wiki/Installing-Neovim)
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 703d2a1f6d..4aa07d1b96 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -57,6 +57,7 @@ local Range = require('vim.treesitter._range')
---@field private _injection_query Query Queries defining injected languages
---@field private _opts table Options
---@field private _parser TSParser Parser for language
+---@field private _has_regions boolean
---@field private _regions Range6[][]?
---List of regions this tree should manage and parse. If nil then regions are
---taken from _trees. This is mostly a short-lived cache for included_regions()
@@ -440,6 +441,8 @@ end
---@private
---@param new_regions Range6[][] List of regions this tree should manage and parse.
function LanguageTree:set_included_regions(new_regions)
+ self._has_regions = true
+
-- Transform the tables from 4 element long to 6 element long (with byte offset)
for _, region in ipairs(new_regions) do
for i, range in ipairs(region) do
@@ -468,7 +471,8 @@ function LanguageTree:included_regions()
return self._regions
end
- if #self._trees == 0 then
+ if not self._has_regions or #self._trees == 0 then
+ -- treesitter.c will default empty ranges to { -1, -1, -1, -1, -1, -1}
return { {} }
end
@@ -744,6 +748,10 @@ function LanguageTree:_edit(
-- Validate regions after editing the tree
self:_iter_regions(function(_, region)
+ if #region == 0 then
+ -- empty region, use the full source
+ return false
+ end
for _, r in ipairs(region) do
if Range.intercepts(r, changed_range) then
return false
diff --git a/src/klib/klist.h b/src/klib/klist.h
index a9abbc6dc2..4274c53919 100644
--- a/src/klib/klist.h
+++ b/src/klib/klist.h
@@ -38,7 +38,7 @@
kmptype_t **buf; \
} kmp_##name##_t; \
static inline kmp_##name##_t *kmp_init_##name(void) { \
- return xcalloc(1, sizeof(kmp_##name##_t)); \
+ return (kmp_##name##_t *)xcalloc(1, sizeof(kmp_##name##_t)); \
} \
static inline void kmp_destroy_##name(kmp_##name##_t *mp) \
REAL_FATTR_UNUSED; \
@@ -52,7 +52,7 @@
static inline kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \
mp->cnt++; \
if (mp->n == 0) { \
- return xcalloc(1, sizeof(kmptype_t)); \
+ return (kmptype_t *)xcalloc(1, sizeof(kmptype_t)); \
} \
return mp->buf[--mp->n]; \
} \
@@ -60,7 +60,7 @@
mp->cnt--; \
if (mp->n == mp->max) { \
mp->max = mp->max ? (mp->max << 1) : 16; \
- mp->buf = xrealloc(mp->buf, sizeof(kmptype_t *) * mp->max); \
+ mp->buf = (kmptype_t **)xrealloc(mp->buf, sizeof(kmptype_t *) * mp->max); \
} \
mp->buf[mp->n++] = p; \
}
@@ -84,7 +84,7 @@
size_t size; \
} kl_##name##_t; \
static inline kl_##name##_t *kl_init_##name(void) { \
- kl_##name##_t *kl = xcalloc(1, sizeof(kl_##name##_t)); \
+ kl_##name##_t *kl = (kl_##name##_t *)xcalloc(1, sizeof(kl_##name##_t)); \
kl->mp = kmp_init(name); \
kl->head = kl->tail = kmp_alloc(name, kl->mp); \
kl->head->next = 0; \
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 26ee9205b2..7c01dc0e54 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -1015,7 +1015,7 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
uint32_t argt = 0;
int64_t def = -1;
cmd_addr_T addr_type_arg = ADDR_NONE;
- int compl = EXPAND_NOTHING;
+ int context = EXPAND_NOTHING;
char *compl_arg = NULL;
const char *rep = NULL;
LuaRef luaref = LUA_NOREF;
@@ -1161,11 +1161,11 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
}
if (opts->complete.type == kObjectTypeLuaRef) {
- compl = EXPAND_USER_LUA;
+ context = EXPAND_USER_LUA;
compl_luaref = api_new_luaref(opts->complete.data.luaref);
} else if (opts->complete.type == kObjectTypeString) {
VALIDATE_S(OK == parse_compl_arg(opts->complete.data.string.data,
- (int)opts->complete.data.string.size, &compl, &argt,
+ (int)opts->complete.data.string.size, &context, &argt,
&compl_arg),
"complete", opts->complete.data.string.data, {
goto err;
@@ -1204,8 +1204,8 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
}
WITH_SCRIPT_CONTEXT(channel_id, {
- if (uc_add_command(name.data, name.size, rep, argt, def, flags, compl, compl_arg, compl_luaref,
- preview_luaref, addr_type_arg, luaref, force) != OK) {
+ if (uc_add_command(name.data, name.size, rep, argt, def, flags, context, compl_arg,
+ compl_luaref, preview_luaref, addr_type_arg, luaref, force) != OK) {
api_set_error(err, kErrorTypeException, "Failed to create user command");
// Do not goto err, since uc_add_command now owns luaref, compl_luaref, and compl_arg
}
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index 3e7f7e8781..467a4720a6 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -53,7 +53,7 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t
}
if (HAS_KEY(opts->win)) {
- VALIDATE_T("win", kObjectTypeInteger, opts->win.type, {
+ VALIDATE_T_HANDLE("win", kObjectTypeWindow, opts->win.type, {
return FAIL;
});
@@ -65,7 +65,7 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t
}
if (HAS_KEY(opts->buf)) {
- VALIDATE_T("buf", kObjectTypeInteger, opts->buf.type, {
+ VALIDATE_T_HANDLE("buf", kObjectTypeBuffer, opts->buf.type, {
return FAIL;
});
diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h
index 91a92c2762..a3e77ea838 100644
--- a/src/nvim/api/private/validate.h
+++ b/src/nvim/api/private/validate.h
@@ -67,6 +67,15 @@
} \
} while (0)
+/// Checks that actual_t is either the correct handle type or a type erased handle (integer)
+#define VALIDATE_T_HANDLE(name, expected_t, actual_t, code) \
+ do { \
+ if (expected_t != actual_t && kObjectTypeInteger != actual_t) { \
+ api_err_exp(err, name, api_typename(expected_t), api_typename(actual_t)); \
+ code; \
+ } \
+ } while (0)
+
#define VALIDATE_RANGE(cond, name, code) \
do { \
if (!(cond)) { \
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 9b4cb336bc..41ba4f506d 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -939,10 +939,10 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit)
xfree(envpat);
}
-void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool delete, int group)
+void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool del, int group)
{
FOR_ALL_AUEVENTS(event) {
- if (do_autocmd_event(event, pat, once, nested, cmd, delete, group)
+ if (do_autocmd_event(event, pat, once, nested, cmd, del, group)
== FAIL) {
return;
}
@@ -956,12 +956,12 @@ void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool del
// If *cmd == NUL: show entries.
// If forceit == true: delete entries.
// If group is not AUGROUP_ALL: only use this group.
-int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd, bool delete,
+int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd, bool del,
int group)
FUNC_ATTR_NONNULL_ALL
{
// Cannot be used to show all patterns. See au_show_for_event or au_show_for_all_events
- assert(*pat != NUL || delete);
+ assert(*pat != NUL || del);
AutoPat *ap;
AutoPat **prev_ap;
@@ -978,7 +978,7 @@ int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd,
}
// Delete all aupat for an event.
- if (*pat == NUL && delete) {
+ if (*pat == NUL && del) {
aupat_del_for_event_and_group(event, findgroup);
return OK;
}
@@ -999,7 +999,7 @@ int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd,
patlen = (int)strlen(buflocal_pat);
}
- if (delete) {
+ if (del) {
assert(*pat != NUL);
// Find AutoPat entries with this pattern.
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 1500aded0c..34121473ca 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -399,13 +399,13 @@ void changed_bytes(linenr_T lnum, colnr_T col)
/// insert/delete bytes at column
///
/// Like changed_bytes() but also adjust extmark for "new" bytes.
-void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new)
+void inserted_bytes(linenr_T lnum, colnr_T start_col, int old_col, int new_col)
{
if (curbuf_splice_pending == 0) {
- extmark_splice_cols(curbuf, (int)lnum - 1, col, old, new, kExtmarkUndo);
+ extmark_splice_cols(curbuf, (int)lnum - 1, start_col, old_col, new_col, kExtmarkUndo);
}
- changed_bytes(lnum, col);
+ changed_bytes(lnum, start_col);
}
/// Appended "count" lines below line "lnum" in the current buffer.
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index a0fe3cc734..a7ec303a6c 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -831,13 +831,12 @@ static void term_close(void *data)
multiqueue_put(chan->events, term_delayed_free, 1, data);
}
-void channel_info_changed(Channel *chan, bool new)
+void channel_info_changed(Channel *chan, bool new_chan)
{
- event_T event = new ? EVENT_CHANOPEN : EVENT_CHANINFO;
+ event_T event = new_chan ? EVENT_CHANOPEN : EVENT_CHANINFO;
if (has_event(event)) {
channel_incref(chan);
- multiqueue_put(main_loop.events, set_info_event,
- 2, chan, event);
+ multiqueue_put(main_loop.events, set_info_event, 2, chan, event);
}
}
diff --git a/src/nvim/channel.h b/src/nvim/channel.h
index 5743eaead5..ca6c75b411 100644
--- a/src/nvim/channel.h
+++ b/src/nvim/channel.h
@@ -121,7 +121,7 @@ EXTERN Callback on_print INIT(= CALLBACK_INIT);
/// @returns Channel with the id or NULL if not found
static inline Channel *find_channel(uint64_t id)
{
- return pmap_get(uint64_t)(&channels, id);
+ return (Channel *)pmap_get(uint64_t)(&channels, id);
}
static inline Stream *channel_instream(Channel *chan)
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 4225e164e4..03df0661c5 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3996,7 +3996,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
if (!clear_env) {
typval_T temp_env = TV_INITIAL_VALUE;
- f_environ(NULL, &temp_env, (EvalFuncData){ .nullptr = NULL });
+ f_environ(NULL, &temp_env, (EvalFuncData){ .null = NULL });
tv_dict_extend(env, temp_env.vval.v_dict, "force");
tv_dict_free(temp_env.vval.v_dict);
diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c
index 8f8a36eff9..0096d0e11e 100644
--- a/src/nvim/event/multiqueue.c
+++ b/src/nvim/event/multiqueue.c
@@ -112,13 +112,13 @@ static MultiQueue *multiqueue_new(MultiQueue *parent, PutCallback put_cb, void *
return rv;
}
-void multiqueue_free(MultiQueue *this)
+void multiqueue_free(MultiQueue *self)
{
- assert(this);
+ assert(self);
QUEUE *q;
- QUEUE_FOREACH(q, &this->headtail, {
+ QUEUE_FOREACH(q, &self->headtail, {
MultiQueueItem *item = multiqueue_node_data(q);
- if (this->parent) {
+ if (self->parent) {
QUEUE_REMOVE(&item->data.item.parent_item->node);
xfree(item->data.item.parent_item);
}
@@ -126,29 +126,29 @@ void multiqueue_free(MultiQueue *this)
xfree(item);
})
- xfree(this);
+ xfree(self);
}
/// Removes the next item and returns its Event.
-Event multiqueue_get(MultiQueue *this)
+Event multiqueue_get(MultiQueue *self)
{
- return multiqueue_empty(this) ? NILEVENT : multiqueue_remove(this);
+ return multiqueue_empty(self) ? NILEVENT : multiqueue_remove(self);
}
-void multiqueue_put_event(MultiQueue *this, Event event)
+void multiqueue_put_event(MultiQueue *self, Event event)
{
- assert(this);
- multiqueue_push(this, event);
- if (this->parent && this->parent->put_cb) {
- this->parent->put_cb(this->parent, this->parent->data);
+ assert(self);
+ multiqueue_push(self, event);
+ if (self->parent && self->parent->put_cb) {
+ self->parent->put_cb(self->parent, self->parent->data);
}
}
-void multiqueue_process_events(MultiQueue *this)
+void multiqueue_process_events(MultiQueue *self)
{
- assert(this);
- while (!multiqueue_empty(this)) {
- Event event = multiqueue_remove(this);
+ assert(self);
+ while (!multiqueue_empty(self)) {
+ Event event = multiqueue_remove(self);
if (event.handler) {
event.handler(event.argv);
}
@@ -156,30 +156,30 @@ void multiqueue_process_events(MultiQueue *this)
}
/// Removes all events without processing them.
-void multiqueue_purge_events(MultiQueue *this)
+void multiqueue_purge_events(MultiQueue *self)
{
- assert(this);
- while (!multiqueue_empty(this)) {
- (void)multiqueue_remove(this);
+ assert(self);
+ while (!multiqueue_empty(self)) {
+ (void)multiqueue_remove(self);
}
}
-bool multiqueue_empty(MultiQueue *this)
+bool multiqueue_empty(MultiQueue *self)
{
- assert(this);
- return QUEUE_EMPTY(&this->headtail);
+ assert(self);
+ return QUEUE_EMPTY(&self->headtail);
}
-void multiqueue_replace_parent(MultiQueue *this, MultiQueue *new_parent)
+void multiqueue_replace_parent(MultiQueue *self, MultiQueue *new_parent)
{
- assert(multiqueue_empty(this));
- this->parent = new_parent;
+ assert(multiqueue_empty(self));
+ self->parent = new_parent;
}
/// Gets the count of all events currently in the queue.
-size_t multiqueue_size(MultiQueue *this)
+size_t multiqueue_size(MultiQueue *self)
{
- return this->size;
+ return self->size;
}
/// Gets an Event from an item.
@@ -213,35 +213,35 @@ static Event multiqueueitem_get_event(MultiQueueItem *item, bool remove)
return ev;
}
-static Event multiqueue_remove(MultiQueue *this)
+static Event multiqueue_remove(MultiQueue *self)
{
- assert(!multiqueue_empty(this));
- QUEUE *h = QUEUE_HEAD(&this->headtail);
+ assert(!multiqueue_empty(self));
+ QUEUE *h = QUEUE_HEAD(&self->headtail);
QUEUE_REMOVE(h);
MultiQueueItem *item = multiqueue_node_data(h);
- assert(!item->link || !this->parent); // Only a parent queue has link-nodes
+ assert(!item->link || !self->parent); // Only a parent queue has link-nodes
Event ev = multiqueueitem_get_event(item, true);
- this->size--;
+ self->size--;
xfree(item);
return ev;
}
-static void multiqueue_push(MultiQueue *this, Event event)
+static void multiqueue_push(MultiQueue *self, Event event)
{
MultiQueueItem *item = xmalloc(sizeof(MultiQueueItem));
item->link = false;
item->data.item.event = event;
item->data.item.parent_item = NULL;
- QUEUE_INSERT_TAIL(&this->headtail, &item->node);
- if (this->parent) {
+ QUEUE_INSERT_TAIL(&self->headtail, &item->node);
+ if (self->parent) {
// push link node to the parent queue
item->data.item.parent_item = xmalloc(sizeof(MultiQueueItem));
item->data.item.parent_item->link = true;
- item->data.item.parent_item->data.queue = this;
- QUEUE_INSERT_TAIL(&this->parent->headtail,
+ item->data.item.parent_item->data.queue = self;
+ QUEUE_INSERT_TAIL(&self->parent->headtail,
&item->data.item.parent_item->node);
}
- this->size++;
+ self->size++;
}
static MultiQueueItem *multiqueue_node_data(QUEUE *q)
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index d341cb20c4..2e9442e704 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -1117,28 +1117,28 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p
static ff_stack_T *ff_create_stack_element(char *fix_part, char *wc_part, int level,
int star_star_empty)
{
- ff_stack_T *new = xmalloc(sizeof(ff_stack_T));
+ ff_stack_T *stack = xmalloc(sizeof(ff_stack_T));
- new->ffs_prev = NULL;
- new->ffs_filearray = NULL;
- new->ffs_filearray_size = 0;
- new->ffs_filearray_cur = 0;
- new->ffs_stage = 0;
- new->ffs_level = level;
- new->ffs_star_star_empty = star_star_empty;
+ stack->ffs_prev = NULL;
+ stack->ffs_filearray = NULL;
+ stack->ffs_filearray_size = 0;
+ stack->ffs_filearray_cur = 0;
+ stack->ffs_stage = 0;
+ stack->ffs_level = level;
+ stack->ffs_star_star_empty = star_star_empty;
// the following saves NULL pointer checks in vim_findfile
if (fix_part == NULL) {
fix_part = "";
}
- new->ffs_fix_path = xstrdup(fix_part);
+ stack->ffs_fix_path = xstrdup(fix_part);
if (wc_part == NULL) {
wc_part = "";
}
- new->ffs_wc_path = xstrdup(wc_part);
+ stack->ffs_wc_path = xstrdup(wc_part);
- return new;
+ return stack;
}
/// Push a dir on the directory stack.
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index cbb378b4b6..d76b22f65c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5428,10 +5428,9 @@ char *vim_tempname(void)
// There is no need to check if the file exists, because we own the directory
// and nobody else creates a file in it.
- char template[TEMP_FILE_PATH_MAXLEN];
- snprintf(template, TEMP_FILE_PATH_MAXLEN,
- "%s%" PRIu64, tempdir, temp_count++);
- return xstrdup(template);
+ char templ[TEMP_FILE_PATH_MAXLEN];
+ snprintf(templ, TEMP_FILE_PATH_MAXLEN, "%s%" PRIu64, tempdir, temp_count++);
+ return xstrdup(templ);
}
/// Tries matching a filename with a "pattern" ("prog" is NULL), or use the
diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua
index fb1dd82a26..a86dc4233e 100644
--- a/src/nvim/generators/gen_eval.lua
+++ b/src/nvim/generators/gen_eval.lua
@@ -94,12 +94,12 @@ for _, name in ipairs(neworder) do
end
local base = def.base or "BASE_NONE"
local func = def.func or ('f_' .. name)
- local data = def.data or "{ .nullptr = NULL }"
+ local data = def.data or "{ .null = NULL }"
local fast = def.fast and 'true' or 'false'
hashpipe:write((' { "%s", %s, %s, %s, %s, &%s, %s },\n')
:format(name, args[1], args[2], base, fast, func, data))
end
-hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .nullptr = NULL } },\n')
+hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .null = NULL } },\n')
hashpipe:write("};\n\n")
hashpipe:write(hashfun)
hashpipe:close()
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index 3c4b1e9d70..7745daf69a 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -657,22 +657,22 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
{
int new_row;
- ScreenGrid new = *grid;
+ ScreenGrid ngrid = *grid;
assert(rows >= 0 && columns >= 0);
size_t ncells = (size_t)rows * (size_t)columns;
- new.chars = xmalloc(ncells * sizeof(schar_T));
- new.attrs = xmalloc(ncells * sizeof(sattr_T));
- new.line_offset = xmalloc((size_t)rows * sizeof(*new.line_offset));
- new.line_wraps = xmalloc((size_t)rows * sizeof(*new.line_wraps));
+ ngrid.chars = xmalloc(ncells * sizeof(schar_T));
+ ngrid.attrs = xmalloc(ncells * sizeof(sattr_T));
+ ngrid.line_offset = xmalloc((size_t)rows * sizeof(*ngrid.line_offset));
+ ngrid.line_wraps = xmalloc((size_t)rows * sizeof(*ngrid.line_wraps));
- new.rows = rows;
- new.cols = columns;
+ ngrid.rows = rows;
+ ngrid.cols = columns;
- for (new_row = 0; new_row < new.rows; new_row++) {
- new.line_offset[new_row] = (size_t)new_row * (size_t)new.cols;
- new.line_wraps[new_row] = false;
+ for (new_row = 0; new_row < ngrid.rows; new_row++) {
+ ngrid.line_offset[new_row] = (size_t)new_row * (size_t)ngrid.cols;
+ ngrid.line_wraps[new_row] = false;
- grid_clear_line(&new, new.line_offset[new_row], columns, valid);
+ grid_clear_line(&ngrid, ngrid.line_offset[new_row], columns, valid);
if (copy) {
// If the screen is not going to be cleared, copy as much as
@@ -680,18 +680,18 @@ void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
// (used when resizing the window at the "--more--" prompt or when
// executing an external command, for the GUI).
if (new_row < grid->rows && grid->chars != NULL) {
- int len = MIN(grid->cols, new.cols);
- memmove(new.chars + new.line_offset[new_row],
+ int len = MIN(grid->cols, ngrid.cols);
+ memmove(ngrid.chars + ngrid.line_offset[new_row],
grid->chars + grid->line_offset[new_row],
(size_t)len * sizeof(schar_T));
- memmove(new.attrs + new.line_offset[new_row],
+ memmove(ngrid.attrs + ngrid.line_offset[new_row],
grid->attrs + grid->line_offset[new_row],
(size_t)len * sizeof(sattr_T));
}
}
}
grid_free(grid);
- *grid = new;
+ *grid = ngrid;
// Share a single scratch buffer for all grids, by
// ensuring it is as wide as the widest grid.
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 36da057ddc..f4d851cfec 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -303,7 +303,7 @@ int hl_get_ui_attr(int ns_id, int idx, int final_id, bool optional)
bool available = false;
if (final_id > 0) {
- int syn_attr = syn_ns_id2attr(ns_id, final_id, optional);
+ int syn_attr = syn_ns_id2attr(ns_id, final_id, &optional);
if (syn_attr > 0) {
attrs = syn_attr2entry(syn_attr);
available = true;
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index a954c14924..5d9148e992 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -1988,18 +1988,23 @@ static int syn_add_group(const char *name, size_t len)
/// @see syn_attr2entry
int syn_id2attr(int hl_id)
{
- return syn_ns_id2attr(-1, hl_id, false);
+ bool optional = false;
+ return syn_ns_id2attr(-1, hl_id, &optional);
}
-int syn_ns_id2attr(int ns_id, int hl_id, bool optional)
+int syn_ns_id2attr(int ns_id, int hl_id, bool *optional)
+ FUNC_ATTR_NONNULL_ALL
{
- hl_id = syn_ns_get_final_id(&ns_id, hl_id);
+ if (syn_ns_get_final_id(&ns_id, &hl_id)) {
+ // If the namespace explicitly defines a group to be empty, it is not optional
+ *optional = false;
+ }
HlGroup *sgp = &hl_table[hl_id - 1]; // index is ID minus one
int attr = ns_get_hl(&ns_id, hl_id, false, sgp->sg_set);
// if a highlight group is optional, don't use the global value
- if (attr >= 0 || (optional && ns_id > 0)) {
+ if (attr >= 0 || (*optional && ns_id > 0)) {
return attr;
}
return sgp->sg_attr;
@@ -2008,16 +2013,20 @@ int syn_ns_id2attr(int ns_id, int hl_id, bool optional)
/// Translate a group ID to the final group ID (following links).
int syn_get_final_id(int hl_id)
{
- int id = curwin->w_ns_hl_active;
- return syn_ns_get_final_id(&id, hl_id);
+ int ns_id = curwin->w_ns_hl_active;
+ syn_ns_get_final_id(&ns_id, &hl_id);
+ return hl_id;
}
-int syn_ns_get_final_id(int *ns_id, int hl_id)
+bool syn_ns_get_final_id(int *ns_id, int *hl_idp)
{
int count;
+ int hl_id = *hl_idp;
+ bool used = false;
if (hl_id > highlight_ga.ga_len || hl_id < 1) {
- return 0; // Can be called from eval!!
+ *hl_idp = 0;
+ return false; // Can be called from eval!!
}
// Follow links until there is no more.
@@ -2030,8 +2039,10 @@ int syn_ns_get_final_id(int *ns_id, int hl_id)
// syn_id2attr time
int check = ns_get_hl(ns_id, hl_id, true, sgp->sg_set);
if (check == 0) {
- return hl_id; // how dare! it broke the link!
+ *hl_idp = hl_id;
+ return true; // how dare! it broke the link!
} else if (check > 0) {
+ used = true;
hl_id = check;
continue;
}
@@ -2045,7 +2056,8 @@ int syn_ns_get_final_id(int *ns_id, int hl_id)
}
}
- return hl_id;
+ *hl_idp = hl_id;
+ return used;
}
/// Refresh the color attributes of all highlight groups.
@@ -2128,7 +2140,8 @@ void highlight_changed(void)
abort();
}
int ns_id = -1;
- int final_id = syn_ns_get_final_id(&ns_id, id);
+ int final_id = id;
+ syn_ns_get_final_id(&ns_id, &final_id);
if (hlf == HLF_SNC) {
id_SNC = final_id;
} else if (hlf == HLF_S) {
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 50107cdfea..78f400b39d 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -1067,14 +1067,14 @@ static bool pum_enough_matches(void)
{
// Don't display the popup menu if there are no matches or there is only
// one (ignoring the original text).
- compl_T *compl = compl_first_match;
+ compl_T *comp = compl_first_match;
int i = 0;
do {
- if (compl == NULL || (!match_at_original_text(compl) && ++i == 2)) {
+ if (comp == NULL || (!match_at_original_text(comp) && ++i == 2)) {
break;
}
- compl = compl->cp_next;
- } while (!is_first_match(compl));
+ comp = comp->cp_next;
+ } while (!is_first_match(comp));
if (strstr(p_cot, "menuone") != NULL) {
return i >= 1;
@@ -1138,7 +1138,7 @@ static int ins_compl_build_pum(void)
{
// Need to build the popup menu list.
compl_match_arraysize = 0;
- compl_T *compl = compl_first_match;
+ compl_T *comp = compl_first_match;
// If it's user complete function and refresh_always,
// do not use "compl_leader" as prefix filter.
@@ -1149,13 +1149,13 @@ static int ins_compl_build_pum(void)
const int lead_len = compl_leader != NULL ? (int)strlen(compl_leader) : 0;
do {
- if (!match_at_original_text(compl)
+ if (!match_at_original_text(comp)
&& (compl_leader == NULL
- || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
+ || ins_compl_equal(comp, compl_leader, (size_t)lead_len))) {
compl_match_arraysize++;
}
- compl = compl->cp_next;
- } while (compl != NULL && !is_first_match(compl));
+ comp = comp->cp_next;
+ } while (comp != NULL && !is_first_match(comp));
if (compl_match_arraysize == 0) {
return -1;
@@ -1172,46 +1172,46 @@ static int ins_compl_build_pum(void)
bool did_find_shown_match = false;
int cur = -1;
int i = 0;
- compl = compl_first_match;
+ comp = compl_first_match;
do {
- if (!match_at_original_text(compl)
+ if (!match_at_original_text(comp)
&& (compl_leader == NULL
- || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
+ || ins_compl_equal(comp, compl_leader, (size_t)lead_len))) {
if (!shown_match_ok) {
- if (compl == compl_shown_match || did_find_shown_match) {
+ if (comp == compl_shown_match || did_find_shown_match) {
// This item is the shown match or this is the
// first displayed item after the shown match.
- compl_shown_match = compl;
+ compl_shown_match = comp;
did_find_shown_match = true;
shown_match_ok = true;
} else {
// Remember this displayed match for when the
// shown match is just below it.
- shown_compl = compl;
+ shown_compl = comp;
}
cur = i;
}
- if (compl->cp_text[CPT_ABBR] != NULL) {
- compl_match_array[i].pum_text = compl->cp_text[CPT_ABBR];
+ if (comp->cp_text[CPT_ABBR] != NULL) {
+ compl_match_array[i].pum_text = comp->cp_text[CPT_ABBR];
} else {
- compl_match_array[i].pum_text = compl->cp_str;
+ compl_match_array[i].pum_text = comp->cp_str;
}
- compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND];
- compl_match_array[i].pum_info = compl->cp_text[CPT_INFO];
- if (compl->cp_text[CPT_MENU] != NULL) {
- compl_match_array[i++].pum_extra = compl->cp_text[CPT_MENU];
+ compl_match_array[i].pum_kind = comp->cp_text[CPT_KIND];
+ compl_match_array[i].pum_info = comp->cp_text[CPT_INFO];
+ if (comp->cp_text[CPT_MENU] != NULL) {
+ compl_match_array[i++].pum_extra = comp->cp_text[CPT_MENU];
} else {
- compl_match_array[i++].pum_extra = compl->cp_fname;
+ compl_match_array[i++].pum_extra = comp->cp_fname;
}
}
- if (compl == compl_shown_match) {
+ if (comp == compl_shown_match) {
did_find_shown_match = true;
// When the original text is the shown match don't set
// compl_shown_match.
- if (match_at_original_text(compl)) {
+ if (match_at_original_text(comp)) {
shown_match_ok = true;
}
@@ -1222,8 +1222,8 @@ static int ins_compl_build_pum(void)
shown_match_ok = true;
}
}
- compl = compl->cp_next;
- } while (compl != NULL && !is_first_match(compl));
+ comp = comp->cp_next;
+ } while (comp != NULL && !is_first_match(comp));
if (!shown_match_ok) { // no displayed match at all
cur = -1;
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 340a05f29d..6ab7aee29d 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1053,7 +1053,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
static struct clinterval {
unsigned int first;
unsigned int last;
- unsigned int class;
+ unsigned int cls;
} classes[] = {
{ 0x037e, 0x037e, 1 }, // Greek question mark
{ 0x0387, 0x0387, 1 }, // Greek ano teleia
@@ -1154,7 +1154,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
} else if (classes[mid].first > (unsigned int)c) {
top = mid - 1;
} else {
- return (int)classes[mid].class;
+ return (int)classes[mid].cls;
}
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d2e9fda7d9..c6564e427e 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -623,9 +623,9 @@ static void block_insert(oparg_T *oap, char *s, int b_insert, struct block_def *
}
} // for all lnum
- changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L, true);
-
State = oldstate;
+
+ changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L, true);
}
/// Handle reindenting a block of lines.
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 7eba5ca54c..cb51e81005 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -1014,17 +1014,17 @@ int os_file_mkdir(char *fname, int32_t mode)
/// Create a unique temporary directory.
///
-/// @param[in] template Template of the path to the directory with XXXXXX
-/// which would be replaced by random chars.
+/// @param[in] templ Template of the path to the directory with XXXXXX
+/// which would be replaced by random chars.
/// @param[out] path Path to created directory for success, undefined for
/// failure.
/// @return `0` for success, non-zero for failure.
-int os_mkdtemp(const char *template, char *path)
+int os_mkdtemp(const char *templ, char *path)
FUNC_ATTR_NONNULL_ALL
{
uv_fs_t request;
fs_loop_lock();
- int result = uv_fs_mkdtemp(&fs_loop, &request, template, NULL);
+ int result = uv_fs_mkdtemp(&fs_loop, &request, templ, NULL);
fs_loop_unlock();
if (result == kLibuvSuccess) {
xstrlcpy(path, request.path, TEMP_FILE_PATH_MAXLEN);
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index b02c38fb6c..260d40a202 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5252,9 +5252,9 @@ static regsubs_T *addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *su
}
// Check character class "class" against current character c.
-static int check_char_class(int class, int c)
+static int check_char_class(int cls, int c)
{
- switch (class) {
+ switch (cls) {
case NFA_CLASS_ALNUM:
if (c >= 1 && c < 128 && isalnum(c)) {
return OK;
@@ -5353,7 +5353,7 @@ static int check_char_class(int class, int c)
default:
// should not be here :P
- siemsg(_(e_ill_char_class), (int64_t)class);
+ siemsg(_(e_ill_char_class), (int64_t)cls);
return FAIL;
}
return FAIL;
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 76fa3049f6..c774dbe384 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -896,13 +896,13 @@ static int term_moverect(VTermRect dest, VTermRect src, void *data)
return 1;
}
-static int term_movecursor(VTermPos new, VTermPos old, int visible, void *data)
+static int term_movecursor(VTermPos new_pos, VTermPos old_pos, int visible, void *data)
{
Terminal *term = data;
- term->cursor.row = new.row;
- term->cursor.col = new.col;
- invalidate_terminal(term, old.row, old.row + 1);
- invalidate_terminal(term, new.row, new.row + 1);
+ term->cursor.row = new_pos.row;
+ term->cursor.col = new_pos.col;
+ invalidate_terminal(term, old_pos.row, old_pos.row + 1);
+ invalidate_terminal(term, new_pos.row, new_pos.row + 1);
return 1;
}
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index 05e57e4b8f..c406f0c302 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -634,7 +634,7 @@ static bool paragraph_start(linenr_T lnum)
void auto_format(bool trailblank, bool prev_line)
{
colnr_T len;
- char *new, *pnew;
+ char *linep, *plinep;
int cc;
if (!has_format_option(FO_AUTO)) {
@@ -705,13 +705,13 @@ void auto_format(bool trailblank, bool prev_line)
// need to add a space when 'w' is in 'formatoptions' to keep a paragraph
// formatted.
if (!wasatend && has_format_option(FO_WHITE_PAR)) {
- new = get_cursor_line_ptr();
- len = (colnr_T)strlen(new);
+ linep = get_cursor_line_ptr();
+ len = (colnr_T)strlen(linep);
if (curwin->w_cursor.col == len) {
- pnew = xstrnsave(new, (size_t)len + 2);
- pnew[len] = ' ';
- pnew[len + 1] = NUL;
- ml_replace(curwin->w_cursor.lnum, pnew, false);
+ plinep = xstrnsave(linep, (size_t)len + 2);
+ plinep[len] = ' ';
+ plinep[len + 1] = NUL;
+ ml_replace(curwin->w_cursor.lnum, plinep, false);
// remove the space later
did_add_space = true;
} else {
diff --git a/src/nvim/types.h b/src/nvim/types.h
index 0bc2f76078..ca0ae16a66 100644
--- a/src/nvim/types.h
+++ b/src/nvim/types.h
@@ -26,7 +26,7 @@ typedef struct MsgpackRpcRequestHandler MsgpackRpcRequestHandler;
typedef union {
float_T (*float_func)(float_T);
const MsgpackRpcRequestHandler *api_handler;
- void *nullptr;
+ void *null;
} EvalFuncData;
typedef handle_T NS;
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index b58ccc809b..8c2f8533d8 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -861,7 +861,7 @@ char *uc_validate_name(char *name)
///
/// @return OK if the command is created, FAIL otherwise.
int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt, int64_t def,
- int flags, int compl, char *compl_arg, LuaRef compl_luaref,
+ int flags, int context, char *compl_arg, LuaRef compl_luaref,
LuaRef preview_luaref, cmd_addr_T addr_type, LuaRef luaref, bool force)
FUNC_ATTR_NONNULL_ARG(1, 3)
{
@@ -944,7 +944,7 @@ int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt,
cmd->uc_rep = rep_buf;
cmd->uc_argt = argt;
cmd->uc_def = def;
- cmd->uc_compl = compl;
+ cmd->uc_compl = context;
cmd->uc_script_ctx = current_sctx;
cmd->uc_script_ctx.sc_lnum += SOURCING_LNUM;
nlua_set_sctx(&cmd->uc_script_ctx);
@@ -974,7 +974,7 @@ void ex_command(exarg_T *eap)
uint32_t argt = 0;
long def = -1;
int flags = 0;
- int compl = EXPAND_NOTHING;
+ int context = EXPAND_NOTHING;
char *compl_arg = NULL;
cmd_addr_T addr_type_arg = ADDR_NONE;
int has_attr = (eap->arg[0] == '-');
@@ -986,7 +986,7 @@ void ex_command(exarg_T *eap)
while (*p == '-') {
p++;
end = skiptowhite(p);
- if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, &compl_arg,
+ if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &context, &compl_arg,
&addr_type_arg) == FAIL) {
goto theend;
}
@@ -1011,10 +1011,10 @@ void ex_command(exarg_T *eap)
emsg(_("E183: User defined commands must start with an uppercase letter"));
} else if (name_len <= 4 && strncmp(name, "Next", name_len) == 0) {
emsg(_("E841: Reserved name, cannot be used for user defined command"));
- } else if (compl > 0 && (argt & EX_EXTRA) == 0) {
+ } else if (context > 0 && (argt & EX_EXTRA) == 0) {
emsg(_(e_complete_used_without_allowing_arguments));
} else {
- uc_add_command(name, name_len, p, argt, def, flags, compl, compl_arg, LUA_NOREF, LUA_NOREF,
+ uc_add_command(name, name_len, p, argt, def, flags, context, compl_arg, LUA_NOREF, LUA_NOREF,
addr_type_arg, LUA_NOREF, eap->forceit);
return; // success
diff --git a/test/busted/outputHandlers/nvim.lua b/test/busted/outputHandlers/nvim.lua
index 2ce32c3b7a..e17536e0f8 100644
--- a/test/busted/outputHandlers/nvim.lua
+++ b/test/busted/outputHandlers/nvim.lua
@@ -204,7 +204,7 @@ return function(options)
handler.fileStart = function(file)
fileTestCount = 0
- io.write(fileStartString:format(file.name))
+ io.write(fileStartString:format(vim.fs.normalize(file.name)))
io.flush()
return nil, true
end
@@ -213,7 +213,7 @@ return function(options)
local elapsedTime_ms = getElapsedTime(file)
local tests = (fileTestCount == 1 and 'test' or 'tests')
fileCount = fileCount + 1
- io.write(fileEndString:format(fileTestCount, tests, file.name, elapsedTime_ms))
+ io.write(fileEndString:format(fileTestCount, tests, vim.fs.normalize(file.name), elapsedTime_ms))
io.flush()
return nil, true
end
diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua
index 00e83bedc8..3115c20410 100644
--- a/test/functional/editor/fold_spec.lua
+++ b/test/functional/editor/fold_spec.lua
@@ -4,17 +4,17 @@ local clear = helpers.clear
local insert = helpers.insert
local feed = helpers.feed
local expect = helpers.expect
-local feed_command = helpers.feed_command
+local command = helpers.command
local funcs = helpers.funcs
-local foldlevel = funcs.foldlevel
-local foldclosedend = funcs.foldclosedend
local eq = helpers.eq
describe('Folds', function()
local tempfname = 'Xtest-fold.txt'
- clear()
- before_each(function() feed_command('enew!') end)
+
+ setup(clear)
+ before_each(function() command('bwipe! | new') end)
after_each(function() os.remove(tempfname) end)
+
it('manual folding adjusts with filter', function()
insert([[
1
@@ -37,8 +37,11 @@ describe('Folds', function()
18
19
20]])
- feed_command('4,$fold', '%foldopen', '10,$fold', '%foldopen')
- feed_command('1,8! cat')
+ command('4,$fold')
+ command('%foldopen')
+ command('10,$fold')
+ command('%foldopen')
+ command('1,8! cat')
feed('5ggzdzMGdd')
expect([[
1
@@ -51,22 +54,24 @@ describe('Folds', function()
8
9]])
end)
+
describe('adjusting folds after :move', function()
local function manually_fold_indent()
-- setting foldmethod twice is a trick to get vim to set the folds for me
- feed_command('set foldmethod=indent', 'set foldmethod=manual')
+ command('set foldmethod=indent')
+ command('set foldmethod=manual')
-- Ensure that all folds will get closed (makes it easier to test the
-- length of folds).
- feed_command('set foldminlines=0')
+ command('set foldminlines=0')
-- Start with all folds open (so :move ranges aren't affected by closed
-- folds).
- feed_command('%foldopen!')
+ command('%foldopen!')
end
local function get_folds()
local rettab = {}
for i = 1, funcs.line('$') do
- table.insert(rettab, foldlevel(i))
+ table.insert(rettab, funcs.foldlevel(i))
end
return rettab
end
@@ -75,16 +80,16 @@ describe('Folds', function()
-- This test is easy because we just need to ensure that the resulting
-- fold is the same as calculated when creating folds from scratch.
insert(insert_string)
- feed_command(move_command)
+ command(move_command)
local after_move_folds = get_folds()
-- Doesn't change anything, but does call foldUpdateAll()
- feed_command('set foldminlines=0')
+ command('set foldminlines=0')
eq(after_move_folds, get_folds())
-- Set up the buffer with insert_string for the manual fold testing.
- feed_command('enew!')
+ command('enew!')
insert(insert_string)
manually_fold_indent()
- feed_command(move_command)
+ command(move_command)
end
it('neither closes nor corrupts folds', function()
@@ -130,19 +135,20 @@ a
for i = 1,funcs.line('$') do
eq(-1, funcs.foldclosed(i))
if i == 1 or i == 7 or i == 13 then
- eq(0, foldlevel(i))
+ eq(0, funcs.foldlevel(i))
elseif i == 4 then
- eq(2, foldlevel(i))
+ eq(2, funcs.foldlevel(i))
else
- eq(1, foldlevel(i))
+ eq(1, funcs.foldlevel(i))
end
end
-- folds are not corrupted
feed('zM')
- eq(6, foldclosedend(2))
- eq(12, foldclosedend(8))
- eq(18, foldclosedend(14))
+ eq(6, funcs.foldclosedend(2))
+ eq(12, funcs.foldclosedend(8))
+ eq(18, funcs.foldclosedend(14))
end)
+
it("doesn't split a fold when the move is within it", function()
test_move_indent([[
a
@@ -157,6 +163,7 @@ a
a]], '5m6')
eq({0, 1, 1, 2, 2, 2, 2, 1, 1, 0}, get_folds())
end)
+
it('truncates folds that end in the moved range', function()
test_move_indent([[
a
@@ -168,6 +175,7 @@ a
a]], '4,5m6')
eq({0, 1, 2, 0, 0, 0, 0}, get_folds())
end)
+
it('moves folds that start between moved range and destination', function()
test_move_indent([[
a
@@ -185,6 +193,7 @@ a
a]], '3,4m$')
eq({0, 1, 1, 0, 0, 1, 2, 1, 0, 0, 1, 0, 0}, get_folds())
end)
+
it('does not affect folds outside changed lines', function()
test_move_indent([[
a
@@ -198,6 +207,7 @@ a
a]], '4m5')
eq({1, 1, 1, 0, 0, 0, 1, 1, 1}, get_folds())
end)
+
it('moves and truncates folds that start in moved range', function()
test_move_indent([[
a
@@ -212,6 +222,7 @@ a
a]], '1,3m7')
eq({0, 0, 0, 0, 0, 1, 2, 0, 0, 0}, get_folds())
end)
+
it('breaks a fold when moving text into it', function()
test_move_indent([[
a
@@ -223,6 +234,7 @@ a
a]], '$m4')
eq({0, 1, 2, 2, 0, 0, 0}, get_folds())
end)
+
it('adjusts correctly when moving a range backwards', function()
test_move_indent([[
a
@@ -232,6 +244,7 @@ a
a]], '2,3m0')
eq({1, 2, 0, 0, 0}, get_folds())
end)
+
it('handles shifting all remaining folds', function()
test_move_indent([[
a
@@ -252,6 +265,7 @@ a]], '13m7')
eq({1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0}, get_folds())
end)
end)
+
it('updates correctly on :read', function()
-- luacheck: ignore 621
helpers.write_file(tempfname, [[
@@ -265,8 +279,10 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=indent', '2', '%foldopen')
- feed_command('read ' .. tempfname)
+ command('set foldmethod=indent')
+ command('2')
+ command('%foldopen')
+ command('read ' .. tempfname)
-- Just to check we have the correct file text.
expect([[
a
@@ -288,6 +304,7 @@ a]], '13m7')
eq(1, funcs.foldlevel(i))
end
end)
+
it('combines folds when removing separating space', function()
-- luacheck: ignore 621
insert([[
@@ -300,9 +317,11 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=indent', '3,5d')
+ command('set foldmethod=indent')
+ command('3,5d')
eq(5, funcs.foldclosedend(1))
end)
+
it("doesn't combine folds that have a specified end", function()
insert([[
{{{
@@ -314,9 +333,12 @@ a]], '13m7')
}}}
]])
- feed_command('set foldmethod=marker', '3,5d', '%foldclose')
+ command('set foldmethod=marker')
+ command('3,5d')
+ command('%foldclose')
eq(2, funcs.foldclosedend(1))
end)
+
it('splits folds according to >N and <N with foldexpr', function()
helpers.source([[
function TestFoldExpr(lnum)
@@ -350,8 +372,11 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=expr', 'set foldexpr=TestFoldExpr(v:lnum)', '2', 'foldopen')
- feed_command('read ' .. tempfname, '%foldclose')
+ command('set foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
+ command('2')
+ command('foldopen')
+ command('read ' .. tempfname)
+ command('%foldclose')
eq(2, funcs.foldclosedend(1))
eq(0, funcs.foldlevel(3))
eq(0, funcs.foldlevel(4))
@@ -359,4 +384,37 @@ a]], '13m7')
eq(10, funcs.foldclosedend(7))
eq(14, funcs.foldclosedend(11))
end)
+
+ it('no folds remain if :delete makes buffer empty #19671', function()
+ command('set foldmethod=manual')
+ funcs.setline(1, {'foo', 'bar', 'baz'})
+ command('2,3fold')
+ command('%delete')
+ eq(0, funcs.foldlevel(1))
+ end)
+
+ it('multibyte fold markers work #20438', function()
+ command('set foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
+ insert([[
+ bbbbb
+ bbbbb
+ bbbbb]])
+ feed('zfgg')
+ expect([[
+ bbbbb/*«*/
+ bbbbb
+ bbbbb/*»*/]])
+ eq(1, funcs.foldlevel(1))
+ end)
+
+ it('updates correctly with indent method and visual blockwise insertion #22898', function()
+ insert([[
+ a
+ b
+ ]])
+ command('set foldmethod=indent shiftwidth=2')
+ feed('gg0<C-v>jI <Esc>') -- indent both lines using visual blockwise mode
+ eq(1, funcs.foldlevel(1))
+ eq(1, funcs.foldlevel(2))
+ end)
end)
diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua
index 5050edff5c..fb55b71e43 100644
--- a/test/functional/editor/put_spec.lua
+++ b/test/functional/editor/put_spec.lua
@@ -9,22 +9,21 @@ local eq = helpers.eq
local map = helpers.tbl_map
local filter = helpers.tbl_filter
local feed_command = helpers.feed_command
+local command = helpers.command
local curbuf_contents = helpers.curbuf_contents
local funcs = helpers.funcs
local dedent = helpers.dedent
-local getreg = funcs.getreg
local function reset()
- feed_command('enew!')
+ command('bwipe! | new')
insert([[
Line of words 1
Line of words 2]])
- feed_command('goto 1')
+ command('goto 1')
feed('itest_string.<esc>u')
funcs.setreg('a', 'test_stringa', 'V')
funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b')
funcs.setreg('"', 'test_string"', 'v')
- feed_command('set virtualedit=')
end
-- We check the last inserted register ". in each of these tests because it is
@@ -508,10 +507,10 @@ describe('put command', function()
test_expect(exception_table, after_redo)
if selection_string then
if not conversion_table.put_backwards then
- eq(selection_string, getreg('"'))
+ eq(selection_string, funcs.getreg('"'))
end
else
- eq('test_string"', getreg('"'))
+ eq('test_string"', funcs.getreg('"'))
end
end
end
@@ -644,7 +643,7 @@ describe('put command', function()
-- Set curswant to '8' to be at the end of the tab character
-- This is where the cursor is put back after the 'u' command.
funcs.setpos('.', {0, 2, 1, 0, 8})
- feed_command('set autoindent')
+ command('set autoindent')
end
)
end)
@@ -655,7 +654,7 @@ describe('put command', function()
test_stringx" Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 2, 1, 2, 3})
end)
end)
@@ -667,7 +666,7 @@ describe('put command', function()
Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 1, 16, 1, 17})
end, true)
end)
@@ -717,7 +716,7 @@ describe('put command', function()
return function(exception_table, after_redo)
test_expect(exception_table, after_redo)
if not conversion_table.put_backwards then
- eq('Line of words 1\n', getreg('"'))
+ eq('Line of words 1\n', funcs.getreg('"'))
end
end
end
@@ -753,7 +752,7 @@ describe('put command', function()
return function(e,c)
test_expect(e,c)
if not conversion_table.put_backwards then
- eq('Lin\nLin', getreg('"'))
+ eq('Lin\nLin', funcs.getreg('"'))
end
end
end
@@ -836,7 +835,7 @@ describe('put command', function()
'vp',
function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 2, 1, 2, 3})
end,
nil,
@@ -851,7 +850,7 @@ describe('put command', function()
base_expect_string,
'vp',
function()
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 1, 16, 2, 18})
end,
true,
@@ -920,12 +919,12 @@ describe('put command', function()
end)
it('should ring the bell when deleting if not appropriate', function()
- feed_command('goto 2')
- feed('i<bs><esc>')
- expect([[
- ine of words 1
- Line of words 2]])
- bell_test(function() feed('".P') end, true)
+ command('goto 2')
+ feed('i<bs><esc>')
+ expect([[
+ ine of words 1
+ Line of words 2]])
+ bell_test(function() feed('".P') end, true)
end)
it('should restore cursor position after undo of ".p', function()
@@ -935,7 +934,7 @@ describe('put command', function()
end)
it("should be unaffected by 'autoindent' with V\".2p", function()
- feed_command('set autoindent')
+ command('set autoindent')
feed('i test_string.<esc>u')
feed('V".2p')
expect([[
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 7b4d68c9cd..6b4ca5ac73 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -79,10 +79,6 @@ describe('vim.diagnostic', function()
]])
end)
- after_each(function()
- clear()
- end)
-
it('creates highlight groups', function()
command('runtime plugin/diagnostic.vim')
eq({
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index ea9958b12a..9afce0b3a0 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -948,4 +948,48 @@ int x = INT_MAX;
[16] = '1',
[17] = '0' }, get_fold_levels())
end)
+
+ it('tracks the root range properly (#22911)', function()
+ insert([[
+ int main() {
+ int x = 3;
+ }]])
+
+ local query0 = [[
+ (declaration) @declaration
+ (function_definition) @function
+ ]]
+
+ exec_lua([[
+ vim.treesitter.start(0, 'c')
+ ]])
+
+ local function run_query()
+ return exec_lua([[
+ local query = vim.treesitter.query.parse("c", ...)
+ parser = vim.treesitter.get_parser()
+ tree = parser:parse()[1]
+ res = {}
+ for id, node in query:iter_captures(tree:root()) do
+ table.insert(res, {query.captures[id], node:range()})
+ end
+ return res
+ ]], query0)
+ end
+
+ eq({
+ { 'function', 0, 0, 2, 1 },
+ { 'declaration', 1, 2, 1, 12 }
+ }, run_query())
+
+ helpers.command'normal ggO'
+ insert('int a;')
+
+ eq({
+ { 'declaration', 0, 0, 0, 6 },
+ { 'function', 1, 0, 3, 1 },
+ { 'declaration', 2, 2, 2, 12 }
+ }, run_query())
+
+ end)
end)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 4612ffe56f..f88954c16b 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -4935,6 +4935,53 @@ describe('float window', function()
end)
end)
+ it("can use Normal as background", function()
+ local buf = meths.create_buf(false,false)
+ meths.buf_set_lines(buf,0,-1,true,{"here", "float"})
+ local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ meths.set_option_value('winhl', 'Normal:Normal', {win=win})
+
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+ ## grid 5
+ here |
+ float |
+ ]], float_pos={
+ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }here {0: }|
+ {0:~ }float {0: }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end
+ end)
+
describe("handles :wincmd", function()
local win
local expected_pos
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 96e28c1978..a99b77f707 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -4,7 +4,6 @@ local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
local command = helpers.command
local feed_command = helpers.feed_command
local insert = helpers.insert
-local expect = helpers.expect
local funcs = helpers.funcs
local meths = helpers.meths
local exec = helpers.exec
@@ -2023,29 +2022,4 @@ describe("folded lines", function()
describe('without ext_multigrid', function()
with_ext_multigrid(false)
end)
-
- it('no folds remains if :delete makes buffer empty #19671', function()
- funcs.setline(1, {'foo', 'bar', 'baz'})
- command('2,3fold')
- command('%delete')
- eq(0, funcs.foldlevel(1))
- end)
-
- it('multibyte fold markers work #20438', function()
- exec([[
- setlocal foldmethod=marker
- setlocal foldmarker=«,»
- setlocal commentstring=/*%s*/
- ]])
- insert([[
- bbbbb
- bbbbb
- bbbbb]])
- feed('zfgg')
- expect([[
- bbbbb/*«*/
- bbbbb
- bbbbb/*»*/]])
- eq(1, funcs.foldlevel(1))
- end)
end)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index dce886ac91..fedfaca7ba 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -2432,6 +2432,23 @@ describe("'winhighlight' highlight", function()
|
]]}
end)
+
+ it('can link to empty highlight group', function()
+ command 'hi NormalNC guibg=Red' -- czerwone time
+ command 'set winhl=NormalNC:Normal'
+ command 'split'
+
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {3:[No Name] }|
+ |
+ {0:~ }|
+ {4:[No Name] }|
+ |
+ ]]}
+ end)
end)
describe('highlight namespaces', function()
diff --git a/test/unit/fixtures/multiqueue.c b/test/unit/fixtures/multiqueue.c
index a8dca0a844..4f4f5989d9 100644
--- a/test/unit/fixtures/multiqueue.c
+++ b/test/unit/fixtures/multiqueue.c
@@ -7,13 +7,13 @@
#include "multiqueue.h"
-void ut_multiqueue_put(MultiQueue *this, const char *str)
+void ut_multiqueue_put(MultiQueue *self, const char *str)
{
- multiqueue_put(this, NULL, 1, str);
+ multiqueue_put(self, NULL, 1, str);
}
-const char *ut_multiqueue_get(MultiQueue *this)
+const char *ut_multiqueue_get(MultiQueue *self)
{
- Event event = multiqueue_get(this);
+ Event event = multiqueue_get(self);
return event.argv[0];
}