From ecc40660d1577835245d99f95e14762a30d36054 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Feb 2023 10:53:47 +0800 Subject: fix(rpc): ignore redraw events when not in UI client (#21892) Otherwise it will crash. --- src/nvim/msgpack_rpc/channel.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index d60e18590f..193c88646a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -247,10 +247,12 @@ static void parse_msgpack(Channel *channel) Unpacker *p = channel->rpc.unpacker; while (unpacker_advance(p)) { if (p->type == kMessageTypeRedrawEvent) { - if (p->grid_line_event) { - ui_client_event_raw_line(p->grid_line_event); - } else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) { - p->ui_handler.fn(p->result.data.array); + if (ui_client_channel_id) { + if (p->grid_line_event) { + ui_client_event_raw_line(p->grid_line_event); + } else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) { + p->ui_handler.fn(p->result.data.array); + } } arena_mem_free(arena_finish(&p->arena)); } else if (p->type == kMessageTypeResponse) { -- cgit From b2b82ff14281a4784790af288cde13984d5d5727 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Feb 2023 14:36:17 +0800 Subject: fix(rpc): ignore redraw events when exiting (#22184) When a TUI client has already stopped, handling UI events will cause a heap-use-after-free, so ignore them. --- src/nvim/msgpack_rpc/channel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 193c88646a..34c8f89e3f 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -247,7 +247,8 @@ static void parse_msgpack(Channel *channel) Unpacker *p = channel->rpc.unpacker; while (unpacker_advance(p)) { if (p->type == kMessageTypeRedrawEvent) { - if (ui_client_channel_id) { + // When exiting, ui_client_stop() has already been called, so don't handle UI events. + if (ui_client_channel_id && !exiting) { if (p->grid_line_event) { ui_client_event_raw_line(p->grid_line_event); } else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) { -- cgit From 7d58de11f49c574a8a305e28e96b9ff810493012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 18:25:01 +0800 Subject: fix(rpc)!: preseve files when stdio channel is closed (#22137) BREAKING CHANGE: Unsaved changes are now preserved rather than discarded when stdio channel is closed. --- src/nvim/msgpack_rpc/channel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 34c8f89e3f..f8be0d4c8d 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -550,6 +550,10 @@ void rpc_close(Channel *channel) if (channel->streamtype == kChannelStreamStdio || (channel->id == ui_client_channel_id && channel->streamtype != kChannelStreamProc)) { + if (channel->streamtype == kChannelStreamStdio) { + // Avoid hanging when there are no other UIs and a prompt is triggered on exit. + remote_ui_disconnect(channel->id); + } exit_from_channel(0); } } -- cgit From d34c64e342dfba9248d1055e702d02620a1b31a8 Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Thu, 16 Feb 2023 13:15:02 +0100 Subject: feat: $NVIM_APPNAME #22128 This commit implements the ability to control all of the XDG paths Neovim should use. This is done by setting an environment variable named NVIM_APPNAME. For example, setting $NVIM_APPNAME makes Neovim look for its configuration directory in $XDG_CONFIG_HOME/$NVIM_APPNAME instead of $XDG_CONFIG_HOME/nvim. If NVIM_APPNAME is not set or is an empty string, "nvim" will be used as default. The usecase for this feature is to enable an easy way to switch from configuration to configuration. One might argue that the various $XDG environment variables can already be used for this usecase. However, setting $XDG environment variables also affects tools spawned by Neovim. For example, while setting $XDG_CONFIG_HOME will enable Neovim to use a different configuration directory, it will also prevent Git from finding its "default" configuration. Closes https://github.com/neovim/neovim/issues/21691 --- src/nvim/msgpack_rpc/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index 1d75c208be..c6a0a4d8cc 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -91,13 +91,14 @@ char *server_address_new(const char *name) { static uint32_t count = 0; char fmt[ADDRESS_MAX_SIZE]; + const char *appname = get_appname(); #ifdef MSWIN int r = snprintf(fmt, sizeof(fmt), "\\\\.\\pipe\\%s.%" PRIu64 ".%" PRIu32, - name ? name : "nvim", os_get_pid(), count++); + name ? name : appname, os_get_pid(), count++); #else char *dir = stdpaths_get_xdg_var(kXDGRuntimeDir); int r = snprintf(fmt, sizeof(fmt), "%s/%s.%" PRIu64 ".%" PRIu32, - dir, name ? name : "nvim", os_get_pid(), count++); + dir, name ? name : appname, os_get_pid(), count++); xfree(dir); #endif if ((size_t)r >= sizeof(fmt)) { -- cgit From c9b6db45417ecbd178f0c6106f4033c760cc75df Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 19:46:39 +0100 Subject: refactor(build): graduate msgpack-c FLOAT32 "feature" since forever --- src/nvim/msgpack_rpc/helpers.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 5f0f03dd69..d1fd28f882 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -84,12 +84,8 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg) *cur.aobj = INTEGER_OBJ((Integer)cur.mobj->via.u64); } break; -#ifdef NVIM_MSGPACK_HAS_FLOAT32 case MSGPACK_OBJECT_FLOAT32: case MSGPACK_OBJECT_FLOAT64: -#else - case MSGPACK_OBJECT_FLOAT: -#endif { STATIC_ASSERT(sizeof(Float) == sizeof(cur.mobj->via.f64), "Msgpack floating-point size does not match API integer"); @@ -156,12 +152,8 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg) case MSGPACK_OBJECT_BOOLEAN: case MSGPACK_OBJECT_POSITIVE_INTEGER: case MSGPACK_OBJECT_NEGATIVE_INTEGER: -#ifdef NVIM_MSGPACK_HAS_FLOAT32 case MSGPACK_OBJECT_FLOAT32: case MSGPACK_OBJECT_FLOAT64: -#else - case MSGPACK_OBJECT_FLOAT: -#endif case MSGPACK_OBJECT_EXT: case MSGPACK_OBJECT_MAP: case MSGPACK_OBJECT_ARRAY: -- cgit From 2ba224e1526681c1a0b1b2b095b1ef2b0874db48 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 26 Feb 2023 12:51:03 +0100 Subject: refactor(log): reduce compile time LOG_LEVEL granularity --- src/nvim/msgpack_rpc/channel.c | 137 ++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 69 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index f8be0d4c8d..96b4bf5c3a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -39,7 +39,73 @@ #include "nvim/ui.h" #include "nvim/ui_client.h" -#if MIN_LOG_LEVEL > LOGLVL_DBG +#ifdef NVIM_LOG_DEBUG +# define REQ "[request] " +# define RES "[response] " +# define NOT "[notify] " +# define ERR "[error] " + +// Cannot define array with negative offsets, so this one is needed to be added +// to MSGPACK_UNPACK_\* values. +# define MUR_OFF 2 + +static const char *const msgpack_error_messages[] = { + [MSGPACK_UNPACK_EXTRA_BYTES + MUR_OFF] = "extra bytes found", + [MSGPACK_UNPACK_CONTINUE + MUR_OFF] = "incomplete string", + [MSGPACK_UNPACK_PARSE_ERROR + MUR_OFF] = "parse error", + [MSGPACK_UNPACK_NOMEM_ERROR + MUR_OFF] = "not enough memory", +}; + +static void log_close(FILE *f) +{ + fputc('\n', f); + fflush(f); + fclose(f); + log_unlock(); +} + +static void log_server_msg(uint64_t channel_id, msgpack_sbuffer *packed) +{ + msgpack_unpacked unpacked; + msgpack_unpacked_init(&unpacked); + DLOGN("RPC ->ch %" PRIu64 ": ", channel_id); + const msgpack_unpack_return result = + msgpack_unpack_next(&unpacked, packed->data, packed->size, NULL); + switch (result) { + case MSGPACK_UNPACK_SUCCESS: { + uint64_t type = unpacked.data.via.array.ptr[0].via.u64; + log_lock(); + FILE *f = open_log_file(); + fprintf(f, type ? (type == 1 ? RES : NOT) : REQ); + msgpack_object_print(f, unpacked.data); + log_close(f); + msgpack_unpacked_destroy(&unpacked); + break; + } + case MSGPACK_UNPACK_EXTRA_BYTES: + case MSGPACK_UNPACK_CONTINUE: + case MSGPACK_UNPACK_PARSE_ERROR: + case MSGPACK_UNPACK_NOMEM_ERROR: { + log_lock(); + FILE *f = open_log_file(); + fprintf(f, ERR); + fprintf(f, "%s", msgpack_error_messages[result + MUR_OFF]); + log_close(f); + break; + } + } +} + +static void log_client_msg(uint64_t channel_id, bool is_request, const char *name) +{ + DLOGN("RPC <-ch %" PRIu64 ": ", channel_id); + log_lock(); + FILE *f = open_log_file(); + fprintf(f, "%s: %s", is_request ? REQ : RES, name); + log_close(f); +} + +#else # define log_client_msg(...) # define log_server_msg(...) #endif @@ -71,7 +137,7 @@ void rpc_start(Channel *channel) if (channel->streamtype != kChannelStreamInternal) { Stream *out = channel_outstream(channel); -#if MIN_LOG_LEVEL <= LOGLVL_DBG +#ifdef NVIM_LOG_DEBUG Stream *in = channel_instream(channel); DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, (void *)in, (void *)out); @@ -668,70 +734,3 @@ const char *rpc_client_name(Channel *chan) return NULL; } - -#if MIN_LOG_LEVEL <= LOGLVL_DBG -# define REQ "[request] " -# define RES "[response] " -# define NOT "[notify] " -# define ERR "[error] " - -// Cannot define array with negative offsets, so this one is needed to be added -// to MSGPACK_UNPACK_\* values. -# define MUR_OFF 2 - -static const char *const msgpack_error_messages[] = { - [MSGPACK_UNPACK_EXTRA_BYTES + MUR_OFF] = "extra bytes found", - [MSGPACK_UNPACK_CONTINUE + MUR_OFF] = "incomplete string", - [MSGPACK_UNPACK_PARSE_ERROR + MUR_OFF] = "parse error", - [MSGPACK_UNPACK_NOMEM_ERROR + MUR_OFF] = "not enough memory", -}; - -static void log_server_msg(uint64_t channel_id, msgpack_sbuffer *packed) -{ - msgpack_unpacked unpacked; - msgpack_unpacked_init(&unpacked); - DLOGN("RPC ->ch %" PRIu64 ": ", channel_id); - const msgpack_unpack_return result = - msgpack_unpack_next(&unpacked, packed->data, packed->size, NULL); - switch (result) { - case MSGPACK_UNPACK_SUCCESS: { - uint64_t type = unpacked.data.via.array.ptr[0].via.u64; - log_lock(); - FILE *f = open_log_file(); - fprintf(f, type ? (type == 1 ? RES : NOT) : REQ); - msgpack_object_print(f, unpacked.data); - log_close(f); - msgpack_unpacked_destroy(&unpacked); - break; - } - case MSGPACK_UNPACK_EXTRA_BYTES: - case MSGPACK_UNPACK_CONTINUE: - case MSGPACK_UNPACK_PARSE_ERROR: - case MSGPACK_UNPACK_NOMEM_ERROR: { - log_lock(); - FILE *f = open_log_file(); - fprintf(f, ERR); - fprintf(f, "%s", msgpack_error_messages[result + MUR_OFF]); - log_close(f); - break; - } - } -} - -static void log_client_msg(uint64_t channel_id, bool is_request, const char *name) -{ - DLOGN("RPC <-ch %" PRIu64 ": ", channel_id); - log_lock(); - FILE *f = open_log_file(); - fprintf(f, "%s: %s", is_request ? REQ : RES, name); - log_close(f); -} - -static void log_close(FILE *f) -{ - fputc('\n', f); - fflush(f); - fclose(f); - log_unlock(); -} -#endif -- cgit From efb0896f21e03f64e3a14e7c09994e81956f47b9 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 3 Apr 2023 15:21:24 +0200 Subject: refactor(api): make typed dicts appear as types in the source code problem: can we have Serde? solution: we have Serde at home This by itself is just a change of notation, that could be quickly merged to avoid messy merge conflicts, but upcoming changes are planned: - keysets no longer need to be defined in one single file. `keysets.h` is just the initial automatic conversion of the previous `keysets.lua`. keysets just used in a single api/{scope}.h can be moved to that file, later on. - Typed dicts will have more specific types than Object. this will enable most of the existing manual typechecking boilerplate to be eliminated. We will need some annotation for missing value, i e a boolean will need to be represented as a TriState (none/false/true) in some cases. - Eventually: optional parameters in form of a `Dict opts` final parameter will get added in some form to metadata. this will require a discussion/desicion about type forward compatibility. --- src/nvim/msgpack_rpc/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index d1fd28f882..9afa3ea02a 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -11,6 +11,7 @@ #include "klib/kvec.h" #include "msgpack/pack.h" +#include "nvim/api/keysets.h" #include "nvim/api/private/helpers.h" #include "nvim/assert.h" #include "nvim/event/wstream.h" @@ -19,7 +20,6 @@ #include "nvim/types.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "keysets.generated.h" // IWYU pragma: export # include "msgpack_rpc/helpers.c.generated.h" #endif -- cgit From 706f871014b46300180156590ff269ee38473989 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 19 Apr 2023 17:04:00 +0100 Subject: build: update uncrustify to 0.76 --- src/nvim/msgpack_rpc/unpacker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 44a16beb48..25edf2e21d 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -179,7 +179,8 @@ static void api_parse_enter(mpack_parser_t *parser, mpack_node_t *node) } static void api_parse_exit(mpack_parser_t *parser, mpack_node_t *node) -{} +{ +} void unpacker_init(Unpacker *p) { -- cgit From e2fdd53d8c015913e8be4ff708fc3488558c8906 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 14 May 2023 18:45:56 +0200 Subject: refactor(map): avoid duplicated khash_t types for values This reduces the total number of khash_t instantiations from 22 to 8. Make the khash internal functions take the size of values as a runtime parameter. This is abstracted with typesafe Map containers which are still specialized for both key, value type. Introduce `Set(key)` type for when there is no value. Refactor shada.c to use Map/Set instead of khash directly. This requires `map_ref` operation to be more flexible. Return pointers to both key and value, plus an indicator for new_item. As a bonus, `map_key` is now redundant. Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is humongous. Make `event_strings` actually work like an intern pool instead of wtf it was doing before. --- src/nvim/msgpack_rpc/channel.c | 49 ++++++++++++++----------------------- src/nvim/msgpack_rpc/channel_defs.h | 2 +- 2 files changed, 20 insertions(+), 31 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 96b4bf5c3a..cd5daee915 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -110,7 +110,7 @@ static void log_client_msg(uint64_t channel_id, bool is_request, const char *nam # define log_server_msg(...) #endif -static PMap(cstr_t) event_strings = MAP_INIT; +static Set(cstr_t) event_strings = SET_INIT; static msgpack_sbuffer out_buffer; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -254,14 +254,12 @@ void rpc_subscribe(uint64_t id, char *event) abort(); } - char *event_string = pmap_get(cstr_t)(&event_strings, event); - - if (!event_string) { - event_string = xstrdup(event); - pmap_put(cstr_t)(&event_strings, event_string, event_string); + const char **key_alloc = NULL; + if (set_put_ref(cstr_t, &event_strings, event, &key_alloc)) { + *key_alloc = xstrdup(event); } - pmap_put(cstr_t)(channel->rpc.subscribed_events, event_string, event_string); + set_put(cstr_t, channel->rpc.subscribed_events, *key_alloc); } /// Unsubscribes to event broadcasts @@ -553,9 +551,9 @@ static void broadcast_event(const char *name, Array args) kvec_t(Channel *) subscribed = KV_INITIAL_VALUE; Channel *channel; - map_foreach_value(&channels, channel, { + pmap_foreach_value(&channels, channel, { if (channel->is_rpc - && pmap_has(cstr_t)(channel->rpc.subscribed_events, name)) { + && set_has(cstr_t, channel->rpc.subscribed_events, name)) { kv_push(subscribed, channel); } }); @@ -583,24 +581,12 @@ end: static void unsubscribe(Channel *channel, char *event) { - char *event_string = pmap_get(cstr_t)(&event_strings, event); - if (!event_string) { + if (!set_has(cstr_t, &event_strings, event)) { WLOG("RPC: ch %" PRIu64 ": tried to unsubscribe unknown event '%s'", channel->id, event); return; } - pmap_del(cstr_t)(channel->rpc.subscribed_events, event_string); - - map_foreach_value(&channels, channel, { - if (channel->is_rpc - && pmap_has(cstr_t)(channel->rpc.subscribed_events, event_string)) { - return; - } - }); - - // Since the string is no longer used by other channels, release it's memory - pmap_del(cstr_t)(&event_strings, event_string); - xfree(event_string); + set_del(cstr_t, channel->rpc.subscribed_events, event); } /// Mark rpc state as closed, and release its reference to the channel. @@ -630,13 +616,7 @@ void rpc_free(Channel *channel) unpacker_teardown(channel->rpc.unpacker); xfree(channel->rpc.unpacker); - // Unsubscribe from all events - char *event_string; - map_foreach_value(channel->rpc.subscribed_events, event_string, { - unsubscribe(channel, event_string); - }); - - pmap_destroy(cstr_t)(channel->rpc.subscribed_events); + set_destroy(cstr_t, channel->rpc.subscribed_events); kv_destroy(channel->rpc.call_stack); api_free_dictionary(channel->rpc.info); } @@ -734,3 +714,12 @@ const char *rpc_client_name(Channel *chan) return NULL; } + +void rpc_free_all_mem(void) +{ + cstr_t key; + set_foreach(&event_strings, key, { + xfree((void *)key); + }); + set_destroy(cstr_t, &event_strings); +} diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 404e68329a..1b5f0bb298 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -31,7 +31,7 @@ typedef struct { } RequestEvent; typedef struct { - PMap(cstr_t) subscribed_events[1]; + Set(cstr_t) subscribed_events[1]; bool closed; Unpacker *unpacker; uint32_t next_request_id; -- cgit From cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 23 May 2023 14:25:10 +0600 Subject: refactor(api): new helper macros Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner. --- src/nvim/msgpack_rpc/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index cd5daee915..1772b0497b 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -628,7 +628,7 @@ static void chan_close_with_error(Channel *channel, char *msg, int loglevel) ChannelCallFrame *frame = kv_A(channel->rpc.call_stack, i); frame->returned = true; frame->errored = true; - frame->result = STRING_OBJ(cstr_to_string(msg)); + frame->result = CSTR_TO_OBJ(msg); } channel_close(channel->id, kChannelPartRpc, NULL); @@ -665,7 +665,7 @@ static WBuffer *serialize_response(uint64_t channel_id, MsgpackRpcRequestHandler } else { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(err->type)); - ADD(args, STRING_OBJ(cstr_to_string(err->msg))); + ADD(args, CSTR_TO_OBJ(err->msg)); msgpack_rpc_serialize_request(0, cstr_as_string("nvim_error_event"), args, &pac); api_free_array(args); -- cgit From 981acc2922ce9a5f214ba14acbb1e444748855f2 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Thu, 1 Jun 2023 02:15:14 -0700 Subject: fix(ui): propagate line wrapping state on grid_line events This fixes the TUI's line-wrapping behavior, which was broken with the migration to the msgpack-based UI protocol (see https://github.com/neovim/neovim/issues/7369#issuecomment-1571812273). --- src/nvim/msgpack_rpc/unpacker.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 25edf2e21d..4128f91b6e 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -441,7 +441,7 @@ redo: case 14: NEXT_TYPE(tok, MPACK_TOKEN_ARRAY); int eventarrsize = (int)tok.length; - if (eventarrsize != 4) { + if (eventarrsize != 5) { p->state = -1; return false; } @@ -509,11 +509,16 @@ redo: } g->icell++; - p->read_ptr = data; - p->read_size = size; if (g->icell == g->ncells) { + NEXT_TYPE(tok, MPACK_TOKEN_BOOLEAN); + g->wrap = mpack_unpack_boolean(tok); + p->read_ptr = data; + p->read_size = size; return true; } + + p->read_ptr = data; + p->read_size = size; goto redo; case 12: -- cgit From 175e5c8b96fe0756040fcb31f46d9c97b3957776 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 6 Jun 2023 20:18:55 +0600 Subject: refactor(api): remove `BOOL` macro #23936 Remove redundant `BOOL` macro that does the same thing as `BOOLEAN_OBJ`. --- src/nvim/msgpack_rpc/unpacker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 25edf2e21d..e36463efc1 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -87,7 +87,7 @@ static void api_parse_enter(mpack_parser_t *parser, mpack_node_t *node) *result = NIL; break; case MPACK_TOKEN_BOOLEAN: - *result = BOOL(mpack_unpack_boolean(node->tok)); + *result = BOOLEAN_OBJ(mpack_unpack_boolean(node->tok)); break; case MPACK_TOKEN_SINT: *result = INTEGER_OBJ(mpack_unpack_sint(node->tok)); -- cgit From deb6fd670479b2e00b99481ce59fdc187408d99d Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 6 Aug 2023 23:25:42 +0900 Subject: feat(msgpack-rpc): show actual request id in error message --- src/nvim/msgpack_rpc/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 1772b0497b..a80424d78b 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -326,8 +326,8 @@ static void parse_msgpack(Channel *channel) char buf[256]; snprintf(buf, sizeof(buf), "ch %" PRIu64 " returned a response with an unknown request " - "id. Ensure the client is properly synchronized", - channel->id); + "id %" PRIu32 ". Ensure the client is properly synchronized", + channel->id, p->request_id); chan_close_with_error(channel, buf, LOGLVL_ERR); } frame->returned = true; -- cgit From 01fe6b9e6a84338d4752c93a286262d79120f163 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 6 Aug 2023 23:19:29 +0900 Subject: feat(msgpack_rpc): support out-of-order responses on `msgpack-rpc` Added to support MessagePack-RPC fully compliant clients that do not return responses in request order. Although it is currently not an efficient implementation for full compliance and full compliance cannot be guaranteed, the addition of the new client type `msgpack-rpc` creates a situation where "if the client type is `msgpack-rpc`, then backward compatibility is ignored and full compliance with MessagePack- RPC compliance is justified even if backward compatibility is ignored if the client type is `msgpack-rpc`. --- src/nvim/msgpack_rpc/channel.c | 45 ++++++++++++++++++++++++++++++++----- src/nvim/msgpack_rpc/channel_defs.h | 11 +++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index a80424d78b..095e392092 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -306,6 +306,17 @@ end: channel_decref(channel); } +static ChannelCallFrame *find_call_frame(RpcState *rpc, uint32_t request_id) +{ + for (size_t i = 0; i < kv_size(rpc->call_stack); i++) { + ChannelCallFrame *frame = kv_Z(rpc->call_stack, i); + if (frame->request_id == request_id) { + return frame; + } + } + return NULL; +} + static void parse_msgpack(Channel *channel) { Unpacker *p = channel->rpc.unpacker; @@ -321,13 +332,15 @@ static void parse_msgpack(Channel *channel) } arena_mem_free(arena_finish(&p->arena)); } else if (p->type == kMessageTypeResponse) { - ChannelCallFrame *frame = kv_last(channel->rpc.call_stack); - if (p->request_id != frame->request_id) { + ChannelCallFrame *frame = channel->rpc.client_type == kClientTypeMsgpackRpc + ? find_call_frame(&channel->rpc, p->request_id) + : kv_last(channel->rpc.call_stack); + if (frame == NULL || p->request_id != frame->request_id) { char buf[256]; snprintf(buf, sizeof(buf), - "ch %" PRIu64 " returned a response with an unknown request " + "ch %" PRIu64 " (type=%" PRIu32 ") returned a response with an unknown request " "id %" PRIu32 ". Ensure the client is properly synchronized", - channel->id, p->request_id); + channel->id, (unsigned)channel->rpc.client_type, p->request_id); chan_close_with_error(channel, buf, LOGLVL_ERR); } frame->returned = true; @@ -691,6 +704,25 @@ void rpc_set_client_info(uint64_t id, Dictionary info) api_free_dictionary(chan->rpc.info); chan->rpc.info = info; + + // Parse "type" on "info" and set "client_type" + const char *type = get_client_info(chan, "type"); + if (type == NULL || strequal(type, "remote")) { + chan->rpc.client_type = kClientTypeRemote; + } else if (strequal(type, "msgpack-rpc")) { + chan->rpc.client_type = kClientTypeMsgpackRpc; + } else if (strequal(type, "ui")) { + chan->rpc.client_type = kClientTypeUi; + } else if (strequal(type, "embedder")) { + chan->rpc.client_type = kClientTypeEmbedder; + } else if (strequal(type, "host")) { + chan->rpc.client_type = kClientTypeHost; + } else if (strequal(type, "plugin")) { + chan->rpc.client_type = kClientTypePlugin; + } else { + chan->rpc.client_type = kClientTypeUnknown; + } + channel_info_changed(chan, false); } @@ -699,14 +731,15 @@ Dictionary rpc_client_info(Channel *chan) return copy_dictionary(chan->rpc.info, NULL); } -const char *rpc_client_name(Channel *chan) +const char *get_client_info(Channel *chan, const char *key) + FUNC_ATTR_NONNULL_ALL { if (!chan->is_rpc) { return NULL; } Dictionary info = chan->rpc.info; for (size_t i = 0; i < info.size; i++) { - if (strequal("name", info.items[i].key.data) + if (strequal(key, info.items[i].key.data) && info.items[i].value.type == kObjectTypeString) { return info.items[i].value.data.string.data; } diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1b5f0bb298..79aa8c1b13 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -14,6 +14,16 @@ typedef struct Channel Channel; typedef struct Unpacker Unpacker; +typedef enum { + kClientTypeUnknown = -1, + kClientTypeRemote = 0, + kClientTypeMsgpackRpc = 5, + kClientTypeUi = 1, + kClientTypeEmbedder = 2, + kClientTypeHost = 3, + kClientTypePlugin = 4, +} ClientType; + typedef struct { uint32_t request_id; bool returned, errored; @@ -37,6 +47,7 @@ typedef struct { uint32_t next_request_id; kvec_t(ChannelCallFrame *) call_stack; Dictionary info; + ClientType client_type; } RpcState; #endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H -- cgit From 5970157e1d22fd5e05ae5d3bd949f807fb7a744c Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 17 May 2023 16:08:06 +0200 Subject: refactor(map): enhanced implementation, Clean Codeā„¢, etc etc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This involves two redesigns of the map.c implementations: 1. Change of macro style and code organization The old khash.h and map.c implementation used huge #define blocks with a lot of backslash line continuations. This instead uses the "implementation file" .c.h pattern. Such a file is meant to be included multiple times, with different macros set prior to inclusion as parameters. we already use this pattern e.g. for eval/typval_encode.c.h to implement different typval encoders reusing a similar structure. We can structure this code into two parts. one that only depends on key type and is enough to implement sets, and one which depends on both key and value to implement maps (as a wrapper around sets, with an added value[] array) 2. Separate the main hash buckets from the key / value arrays Change the hack buckets to only contain an index into separate key / value arrays This is a common pattern in modern, state of the art hashmap implementations. Even though this leads to one more allocated array, it is this often is a net reduction of memory consumption. Consider key+value consuming at least 12 bytes per pair. On average, we will have twice as many buckets per item. Thus old implementation: 2*12 = 24 bytes per item New implementation 1*12 + 2*4 = 20 bytes per item And the difference gets bigger with larger items. One might think we have pulled a fast one here, as wouldn't the average size of the new key/value arrays be 1.5 slots per items due to amortized grows? But remember, these arrays are fully dense, and thus the accessed memory, measured in _cache lines_, the unit which actually matters, will be the fully used memory but just rounded up to the nearest cache line boundary. This has some other interesting properties, such as an insert-only set/map will be fully ordered by insert only. Preserving this ordering in face of deletions is more tricky tho. As we currently don't use ordered maps, the "delete" operation maintains compactness of the item arrays in the simplest way by breaking the ordering. It would be possible to implement an order-preserving delete although at some cost, like allowing the items array to become non-dense until the next rehash. Finally, in face of these two major changes, all code used in khash.h has been integrated into map.c and friends. Given the heavy edits it makes no sense to "layer" the code into a vendored and a wrapper part. Rather, the layered cake follows the specialization depth: code shared for all maps, code specialized to a key type (and its equivalence relation), and finally code specialized to value+key type. --- src/nvim/msgpack_rpc/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 095e392092..3a9b36a914 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -564,7 +564,7 @@ static void broadcast_event(const char *name, Array args) kvec_t(Channel *) subscribed = KV_INITIAL_VALUE; Channel *channel; - pmap_foreach_value(&channels, channel, { + map_foreach_value(&channels, channel, { if (channel->is_rpc && set_has(cstr_t, channel->rpc.subscribed_events, name)) { kv_push(subscribed, channel); -- cgit From c422722b2e94b94d7f9374dbae12f17580cd1d41 Mon Sep 17 00:00:00 2001 From: Sergey Slipchenko Date: Sat, 9 Sep 2023 15:40:09 +0400 Subject: fix(rpc): fix hang with channel closed while waiting for response --- src/nvim/msgpack_rpc/channel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 3a9b36a914..b753d46d64 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -207,9 +207,15 @@ Object rpc_send_call(uint64_t id, const char *method_name, Array args, ArenaMem // Push the frame ChannelCallFrame frame = { request_id, false, false, NIL, NULL }; kv_push(rpc->call_stack, &frame); - LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned); + LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned || rpc->closed); (void)kv_pop(rpc->call_stack); + if (rpc->closed) { + api_set_error(err, kErrorTypeException, "Invalid channel: %" PRIu64, id); + channel_decref(channel); + return NIL; + } + if (frame.errored) { if (frame.result.type == kObjectTypeString) { api_set_error(err, kErrorTypeException, "%s", -- cgit From 8da986ea877b07a5eb117446f410f2a7fc8cd9cb Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 13 Sep 2023 13:39:18 +0200 Subject: refactor(grid): change schar_T representation to be more compact Previously, a screen cell would occupy 28+4=32 bytes per cell as we always made space for up to MAX_MCO+1 codepoints in a cell. As an example, even a pretty modest 50*80 screen would consume 50*80*2*32 = 256000, i e a quarter megabyte With the factor of two due to the TUI side buffer, and even more when using msg_grid and/or ext_multigrid. This instead stores a 4-byte union of either: - a valid UTF-8 sequence up to 4 bytes - an escape char which is invalid UTF-8 (0xFF) plus a 24-bit index to a glyph cache This avoids allocating space for huge composed glyphs _upfront_, while still keeping rendering such glyphs reasonably fast (1 hash table lookup + one plain index lookup). If the same large glyphs are using repeatedly on the screen, this is still a net reduction of memory/cache consumption. The only case which really gets worse is if you blast the screen full with crazy emojis and zalgo text and even this case only leads to 4 extra bytes per char. When only <= 4-byte glyphs are used, plus the 4-byte attribute code, i e 8 bytes in total there is a factor of four reduction of memory use. Memory which will be quite hot in cache as the screen buffer is scanned over in win_line() buffer text drawing A slight complication is that the representation depends on host byte order. I've tested this manually by compling and running this in qemu-s390x and it works fine. We might add a qemu based solution to CI at some point. --- src/nvim/msgpack_rpc/unpacker.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index c3b1022db2..37e32729cc 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -9,6 +9,7 @@ #include "mpack/conv.h" #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" +#include "nvim/grid.h" #include "nvim/macros.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/channel_defs.h" @@ -497,13 +498,13 @@ redo: if (g->icell == g->ncells - 1 && cellsize == 1 && cellbuf[0] == ' ' && repeat > 1) { g->clear_width = repeat; } else { + schar_T sc = schar_from_buf(cellbuf, cellsize); for (int r = 0; r < repeat; r++) { if (g->coloff >= (int)grid_line_buf_size) { p->state = -1; return false; } - memcpy(grid_line_buf_char[g->coloff], cellbuf, cellsize); - grid_line_buf_char[g->coloff][cellsize] = NUL; + grid_line_buf_char[g->coloff] = sc; grid_line_buf_attr[g->coloff++] = g->cur_attr; } } -- cgit From bfdec5b0e71991ebc0a8ad7c12d39f7a9cc56f07 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Wed, 27 Sep 2023 20:43:39 +0500 Subject: fix(clang): null pointer dereference in parse_msgpack #25389 --- src/nvim/msgpack_rpc/channel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index b753d46d64..fb24100f3a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -348,6 +348,7 @@ static void parse_msgpack(Channel *channel) "id %" PRIu32 ". Ensure the client is properly synchronized", channel->id, (unsigned)channel->rpc.client_type, p->request_id); chan_close_with_error(channel, buf, LOGLVL_ERR); + return; } frame->returned = true; frame->errored = (p->error.type != kObjectTypeNil); -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/msgpack_rpc/channel.c | 1 + src/nvim/msgpack_rpc/helpers.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index fb24100f3a..597aa56fa7 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -24,6 +24,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" +#include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" #include "nvim/map.h" diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 9afa3ea02a..5a3f31b7f5 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -11,7 +11,6 @@ #include "klib/kvec.h" #include "msgpack/pack.h" -#include "nvim/api/keysets.h" #include "nvim/api/private/helpers.h" #include "nvim/assert.h" #include "nvim/event/wstream.h" -- cgit From 9ff6f73f838a1f90d09922448c434033ba5e094e Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 9 Oct 2023 00:36:48 +0600 Subject: refactor: allow not having a `default` case for enum Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added. Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases. --- src/nvim/msgpack_rpc/unpacker.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 37e32729cc..5a65e6c5df 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -173,9 +173,6 @@ static void api_parse_enter(mpack_parser_t *parser, mpack_node_t *node) node->data[0].p = result; break; } - - default: - abort(); } } -- cgit From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/msgpack_rpc/channel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index ce5806930c..2a6626a6e1 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -17,7 +17,7 @@ /// HACK: os/input.c drains this queue immediately before blocking for input. /// Events on this queue are async-safe, but they need the resolved state /// of os_inchar(), so they are processed "just-in-time". -EXTERN MultiQueue *ch_before_blocking_events INIT(= NULL); +EXTERN MultiQueue *ch_before_blocking_events INIT( = NULL); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/channel.h.generated.h" -- cgit From 468292dcb743c79714b030557cf2754b7b5bf07d Mon Sep 17 00:00:00 2001 From: LW Date: Fri, 3 Nov 2023 15:56:45 -0700 Subject: fix(rpc): "grid_line" event parsing crashes (#25581) refactor: use a more idiomatic loop to iterate over the cells There are two cases in which the following assertion would fail: ```c assert(g->icell < g->ncells); ``` 1. If `g->ncells = 0`. Update this to be legal. 2. If an EOF is reached while parsing `wrap`. In this case, the unpacker attempts to resume from `cells`, which is a bug. Create a new state for parsing `wrap`. Reference: https://neovim.io/doc/user/ui.html#ui-event-grid_line --- src/nvim/msgpack_rpc/unpacker.c | 98 ++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 5a65e6c5df..9b7fc3fbb7 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -291,13 +291,13 @@ error: // objects. For the moment "redraw/grid_line" uses a hand-rolled decoder, // to avoid a blizzard of small objects for each screen cell. // -// <0>[2, "redraw", <10>[{11}["method", <12>[args], <12>[args], ...], <11>[...], ...]] +// <0>[2, "redraw", <10>[<11>["method", <12>[args], <12>[args], ...], <11>[...], ...]] // // Where [args] gets unpacked as an Array. Note: first {11} is not saved as a state. // // When method is "grid_line", we furthermore decode a cell at a time like: // -// <0>[2, "redraw", <10>[{11}["grid_line", <14>[g, r, c, [<15>[cell], <15>[cell], ...]], ...], <11>[...], ...]] +// <0>[2, "redraw", <10>[<11>["grid_line", <14>[g, r, c, [<15>[cell], <15>[cell], ...], <16>wrap]], <11>[...], ...]] // // where [cell] is [char, repeat, attr], where 'repeat' and 'attr' is optional @@ -322,7 +322,7 @@ bool unpacker_advance(Unpacker *p) return false; } - if (p->state == 15) { + if (p->state == 16) { // grid_line event already unpacked goto done; } else { @@ -357,10 +357,10 @@ done: p->state = 0; return true; case 13: - case 15: + case 16: p->ncalls--; if (p->ncalls > 0) { - p->state = (p->state == 15) ? 14 : 12; + p->state = (p->state == 16) ? 14 : 12; } else if (p->nevents > 0) { p->state = 11; } else { @@ -393,7 +393,6 @@ bool unpacker_parse_redraw(Unpacker *p) return false; \ } -redo: switch (p->state) { case 10: NEXT_TYPE(tok, MPACK_TOKEN_ARRAY); @@ -461,63 +460,64 @@ redo: FALLTHROUGH; case 15: - assert(g->icell < g->ncells); - - NEXT_TYPE(tok, MPACK_TOKEN_ARRAY); - int cellarrsize = (int)tok.length; - if (cellarrsize < 1 || cellarrsize > 3) { - p->state = -1; - return false; - } + for (; g->icell != g->ncells; g->icell++) { + assert(g->icell < g->ncells); + + NEXT_TYPE(tok, MPACK_TOKEN_ARRAY); + int cellarrsize = (int)tok.length; + if (cellarrsize < 1 || cellarrsize > 3) { + p->state = -1; + return false; + } - NEXT_TYPE(tok, MPACK_TOKEN_STR); - if (tok.length > size) { - return false; - } + NEXT_TYPE(tok, MPACK_TOKEN_STR); + if (tok.length > size) { + return false; + } - const char *cellbuf = data; - size_t cellsize = tok.length; - data += cellsize; - size -= cellsize; + const char *cellbuf = data; + size_t cellsize = tok.length; + data += cellsize; + size -= cellsize; - if (cellarrsize >= 2) { - NEXT_TYPE(tok, MPACK_TOKEN_SINT); - g->cur_attr = (int)tok.data.value.lo; - } + if (cellarrsize >= 2) { + NEXT_TYPE(tok, MPACK_TOKEN_SINT); + g->cur_attr = (int)tok.data.value.lo; + } - int repeat = 1; - if (cellarrsize >= 3) { - NEXT_TYPE(tok, MPACK_TOKEN_UINT); - repeat = (int)tok.data.value.lo; - } + int repeat = 1; + if (cellarrsize >= 3) { + NEXT_TYPE(tok, MPACK_TOKEN_UINT); + repeat = (int)tok.data.value.lo; + } - g->clear_width = 0; - if (g->icell == g->ncells - 1 && cellsize == 1 && cellbuf[0] == ' ' && repeat > 1) { - g->clear_width = repeat; - } else { - schar_T sc = schar_from_buf(cellbuf, cellsize); - for (int r = 0; r < repeat; r++) { - if (g->coloff >= (int)grid_line_buf_size) { - p->state = -1; - return false; + g->clear_width = 0; + if (g->icell == g->ncells - 1 && cellsize == 1 && cellbuf[0] == ' ' && repeat > 1) { + g->clear_width = repeat; + } else { + schar_T sc = schar_from_buf(cellbuf, cellsize); + for (int r = 0; r < repeat; r++) { + if (g->coloff >= (int)grid_line_buf_size) { + p->state = -1; + return false; + } + grid_line_buf_char[g->coloff] = sc; + grid_line_buf_attr[g->coloff++] = g->cur_attr; } - grid_line_buf_char[g->coloff] = sc; - grid_line_buf_attr[g->coloff++] = g->cur_attr; } - } - g->icell++; - if (g->icell == g->ncells) { - NEXT_TYPE(tok, MPACK_TOKEN_BOOLEAN); - g->wrap = mpack_unpack_boolean(tok); p->read_ptr = data; p->read_size = size; - return true; } + p->state = 16; + FALLTHROUGH; + case 16: + NEXT_TYPE(tok, MPACK_TOKEN_BOOLEAN); + g->wrap = mpack_unpack_boolean(tok); p->read_ptr = data; p->read_size = size; - goto redo; + return true; case 12: return true; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/msgpack_rpc/channel.c | 3 --- src/nvim/msgpack_rpc/helpers.c | 3 --- src/nvim/msgpack_rpc/server.c | 3 --- src/nvim/msgpack_rpc/unpacker.c | 4 ---- 4 files changed, 13 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 597aa56fa7..f14612ca8a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 5a3f31b7f5..02897e339c 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index c6a0a4d8cc..328d902f0f 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 9b7fc3fbb7..9fd80e506a 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -381,7 +378,6 @@ bool unpacker_parse_redraw(Unpacker *p) size_t size = p->read_size; GridLineEvent *g = p->grid_line_event; -// -V:NEXT_TYPE:501 #define NEXT_TYPE(tok, typ) \ result = mpack_rtoken(&data, &size, &tok); \ if (result == MPACK_EOF) { \ -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/msgpack_rpc/channel.h | 4 +--- src/nvim/msgpack_rpc/channel_defs.h | 5 +---- src/nvim/msgpack_rpc/helpers.h | 5 +---- src/nvim/msgpack_rpc/server.h | 4 +--- src/nvim/msgpack_rpc/unpacker.h | 5 +---- 5 files changed, 5 insertions(+), 18 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index 2a6626a6e1..e2b7f5d8d1 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MSGPACK_RPC_CHANNEL_H -#define NVIM_MSGPACK_RPC_CHANNEL_H +#pragma once #include #include @@ -22,4 +21,3 @@ EXTERN MultiQueue *ch_before_blocking_events INIT( = NULL); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/channel.h.generated.h" #endif -#endif // NVIM_MSGPACK_RPC_CHANNEL_H diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 79aa8c1b13..0bbffb8beb 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H -#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H +#pragma once #include #include @@ -49,5 +48,3 @@ typedef struct { Dictionary info; ClientType client_type; } RpcState; - -#endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H diff --git a/src/nvim/msgpack_rpc/helpers.h b/src/nvim/msgpack_rpc/helpers.h index dab8a16b6b..dd2096f305 100644 --- a/src/nvim/msgpack_rpc/helpers.h +++ b/src/nvim/msgpack_rpc/helpers.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MSGPACK_RPC_HELPERS_H -#define NVIM_MSGPACK_RPC_HELPERS_H +#pragma once #include #include @@ -19,5 +18,3 @@ #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/helpers.h.generated.h" #endif - -#endif // NVIM_MSGPACK_RPC_HELPERS_H diff --git a/src/nvim/msgpack_rpc/server.h b/src/nvim/msgpack_rpc/server.h index 5446e40e0b..c6a240cd55 100644 --- a/src/nvim/msgpack_rpc/server.h +++ b/src/nvim/msgpack_rpc/server.h @@ -1,9 +1,7 @@ -#ifndef NVIM_MSGPACK_RPC_SERVER_H -#define NVIM_MSGPACK_RPC_SERVER_H +#pragma once #include #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/server.h.generated.h" #endif -#endif // NVIM_MSGPACK_RPC_SERVER_H diff --git a/src/nvim/msgpack_rpc/unpacker.h b/src/nvim/msgpack_rpc/unpacker.h index b8b2d38d3b..72e1b04511 100644 --- a/src/nvim/msgpack_rpc/unpacker.h +++ b/src/nvim/msgpack_rpc/unpacker.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MSGPACK_RPC_UNPACKER_H -#define NVIM_MSGPACK_RPC_UNPACKER_H +#pragma once #include #include @@ -49,5 +48,3 @@ struct Unpacker { #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/unpacker.h.generated.h" #endif - -#endif // NVIM_MSGPACK_RPC_UNPACKER_H -- cgit From a6e3d93421ba13c407a96fac9cc01fa41ec7ad98 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 16 Nov 2023 10:59:11 +0100 Subject: refactor: enable formatting for ternaries This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators. --- src/nvim/msgpack_rpc/channel.c | 4 ++-- src/nvim/msgpack_rpc/helpers.c | 4 ++-- src/nvim/msgpack_rpc/server.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index f14612ca8a..21803be226 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -337,8 +337,8 @@ static void parse_msgpack(Channel *channel) arena_mem_free(arena_finish(&p->arena)); } else if (p->type == kMessageTypeResponse) { ChannelCallFrame *frame = channel->rpc.client_type == kClientTypeMsgpackRpc - ? find_call_frame(&channel->rpc, p->request_id) - : kv_last(channel->rpc.call_stack); + ? find_call_frame(&channel->rpc, p->request_id) + : kv_last(channel->rpc.call_stack); if (frame == NULL || p->request_id != frame->request_id) { char buf[256]; snprintf(buf, sizeof(buf), diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 02897e339c..d8a33895d5 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -472,8 +472,8 @@ msgpack_object *msgpack_rpc_method(msgpack_object *req) { msgpack_object *obj = req->via.array.ptr + (msgpack_rpc_is_notification(req) ? 1 : 2); - return obj->type == MSGPACK_OBJECT_STR || obj->type == MSGPACK_OBJECT_BIN ? - obj : NULL; + return obj->type == MSGPACK_OBJECT_STR || obj->type == MSGPACK_OBJECT_BIN + ? obj : NULL; } msgpack_object *msgpack_rpc_args(msgpack_object *req) diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index 328d902f0f..e60c1b88a5 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -68,8 +68,8 @@ static void close_socket_watcher(SocketWatcher **watcher) static void set_vservername(garray_T *srvs) { char *default_server = (srvs->ga_len > 0) - ? ((SocketWatcher **)srvs->ga_data)[0]->addr - : NULL; + ? ((SocketWatcher **)srvs->ga_data)[0]->addr + : NULL; set_vim_var_string(VV_SEND_SERVER, default_server, -1); } -- cgit From a827003e3052c6d9ee7bdb71518182e9bd76317d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 25 Nov 2023 11:32:32 +0100 Subject: build: rework IWYU mapping files Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU. --- src/nvim/msgpack_rpc/channel.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 21803be226..382fdca8fa 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "klib/kvec.h" #include "nvim/api/private/defs.h" -- cgit From 09541d514dd18bf86f673d3784d406236fcbdad8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 09:51:26 +0800 Subject: build(IWYU): replace public-to-public mappings with pragmas (#26237) --- src/nvim/msgpack_rpc/channel.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index e2b7f5d8d1..ac189c98dc 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -9,6 +9,7 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/macros.h" +#include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: export #include "nvim/vim.h" #define METHOD_MAXLEN 512 -- cgit From 574d25642fc9ca65b396633aeab6e2d32778b642 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 17:21:58 +0800 Subject: refactor: move Arena and ArenaMem to memory_defs.h (#26240) --- src/nvim/msgpack_rpc/channel.h | 8 ++++---- src/nvim/msgpack_rpc/channel_defs.h | 2 ++ src/nvim/msgpack_rpc/server.h | 2 +- src/nvim/msgpack_rpc/unpacker.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index ac189c98dc..e8ea71173a 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -1,16 +1,16 @@ #pragma once -#include -#include +#include // IWYU pragma: keep -#include "nvim/api/private/defs.h" +#include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/channel.h" #include "nvim/event/multiqueue.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" +#include "nvim/event/wstream.h" #include "nvim/macros.h" +#include "nvim/memory_defs.h" // IWYU pragma: keep #include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: export -#include "nvim/vim.h" #define METHOD_MAXLEN 512 diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 0bbffb8beb..1e3f8a72c1 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -4,10 +4,12 @@ #include #include +#include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" +#include "nvim/map.h" #include "nvim/vim.h" typedef struct Channel Channel; diff --git a/src/nvim/msgpack_rpc/server.h b/src/nvim/msgpack_rpc/server.h index c6a240cd55..71b578a14b 100644 --- a/src/nvim/msgpack_rpc/server.h +++ b/src/nvim/msgpack_rpc/server.h @@ -1,6 +1,6 @@ #pragma once -#include +#include // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/server.h.generated.h" diff --git a/src/nvim/msgpack_rpc/unpacker.h b/src/nvim/msgpack_rpc/unpacker.h index 72e1b04511..0317255df3 100644 --- a/src/nvim/msgpack_rpc/unpacker.h +++ b/src/nvim/msgpack_rpc/unpacker.h @@ -10,7 +10,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/grid_defs.h" -#include "nvim/memory.h" +#include "nvim/memory_defs.h" #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/types.h" #include "nvim/ui_client.h" -- cgit From acf525287950277e7b83794184e3df5dcfdecc48 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 18:37:35 +0800 Subject: refactor: remove vim.h from more headers (#26244) --- src/nvim/msgpack_rpc/channel_defs.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1e3f8a72c1..1eb57ec4dc 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -10,7 +10,6 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/map.h" -#include "nvim/vim.h" typedef struct Channel Channel; typedef struct Unpacker Unpacker; -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- src/nvim/msgpack_rpc/channel.c | 1 + src/nvim/msgpack_rpc/helpers.c | 2 +- src/nvim/msgpack_rpc/server.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 382fdca8fa..25c58b7a83 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -20,6 +20,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" +#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index d8a33895d5..294ce0e298 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -10,7 +10,7 @@ #include "msgpack/pack.h" #include "nvim/api/private/helpers.h" #include "nvim/assert.h" -#include "nvim/event/wstream.h" +#include "nvim/func_attr.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/helpers.h" #include "nvim/types.h" diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index e60c1b88a5..f3627eaa61 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -7,6 +7,7 @@ #include "nvim/channel.h" #include "nvim/eval.h" #include "nvim/event/socket.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/log.h" #include "nvim/main.h" -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/msgpack_rpc/channel.c | 2 +- src/nvim/msgpack_rpc/helpers.c | 2 +- src/nvim/msgpack_rpc/unpacker.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 25c58b7a83..57c9e64b3b 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -33,7 +33,7 @@ #include "nvim/msgpack_rpc/unpacker.h" #include "nvim/os/input.h" #include "nvim/rbuffer.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_client.h" diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 294ce0e298..3aac2618c0 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -13,7 +13,7 @@ #include "nvim/func_attr.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/helpers.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/helpers.c.generated.h" diff --git a/src/nvim/msgpack_rpc/unpacker.h b/src/nvim/msgpack_rpc/unpacker.h index 0317255df3..53af29761e 100644 --- a/src/nvim/msgpack_rpc/unpacker.h +++ b/src/nvim/msgpack_rpc/unpacker.h @@ -12,7 +12,7 @@ #include "nvim/grid_defs.h" #include "nvim/memory_defs.h" #include "nvim/msgpack_rpc/channel_defs.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/ui_client.h" struct Unpacker { -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/msgpack_rpc/channel.c | 2 +- src/nvim/msgpack_rpc/channel.h | 2 +- src/nvim/msgpack_rpc/channel_defs.h | 2 +- src/nvim/msgpack_rpc/helpers.c | 2 +- src/nvim/msgpack_rpc/unpacker.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/msgpack_rpc') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 57c9e64b3b..0fb1ebf931 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -24,7 +24,7 @@ #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/msgpack_rpc/channel.h" diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index e8ea71173a..818bee8318 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -8,7 +8,7 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/event/wstream.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: keep #include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: export diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1eb57ec4dc..20b8a89afb 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -9,7 +9,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" typedef struct Channel Channel; typedef struct Unpacker Unpacker; diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 3aac2618c0..1fdfc9e536 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -9,7 +9,7 @@ #include "klib/kvec.h" #include "msgpack/pack.h" #include "nvim/api/private/helpers.h" -#include "nvim/assert.h" +#include "nvim/assert_defs.h" #include "nvim/func_attr.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/helpers.h" diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 9fd80e506a..38263381bf 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -5,9 +5,9 @@ #include "klib/kvec.h" #include "mpack/conv.h" #include "nvim/api/private/helpers.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/grid.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/msgpack_rpc/helpers.h" -- cgit