From c52dfb6e840827a2de713e40ea8506491ec7ce0b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Mar 2024 09:44:10 +0800 Subject: fix(normal): don't check conceal when pressing 'r' (#27892) Problem: Cursor line is unconcealed when pressing 'r' in Normal mode when 'concealcursor' contains 'n' but not 'i'. Solution: Don't check conceal when pressing 'r' in Normal mode. Vim doesn't have this problem because it doesn't call redrawWinline() in conceal_check_cursor_line() and instead sets a global variable. --- src/nvim/ui.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index bddcf98b53..506bb93f5b 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -624,7 +624,7 @@ void ui_check_mouse(void) /// Check if current mode has changed. /// /// May update the shape of the cursor. -void ui_cursor_shape(void) +void ui_cursor_shape_no_check_conceal(void) { if (!full_screen) { return; @@ -635,6 +635,15 @@ void ui_cursor_shape(void) ui_mode_idx = new_mode_idx; pending_mode_update = true; } +} + +/// Check if current mode has changed. +/// +/// May update the shape of the cursor. +/// With concealing on, may conceal or unconceal the cursor line. +void ui_cursor_shape(void) +{ + ui_cursor_shape_no_check_conceal(); conceal_check_cursor_line(); } -- cgit From ae28ef327e02ac87ef26f941c401312ed0462d8c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Apr 2024 11:18:43 +0800 Subject: fix: adjust error message for error in UI event callback (#28200) Also close Nvim instance before removing log file, otherwise the Nvim instance will still write to the log file. Also adjust log level in libuv_process_spawn(). Ref #27660 --- src/nvim/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 506bb93f5b..98751c8952 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -723,7 +723,7 @@ void ui_call_event(char *name, Array args) handled = true; } if (ERROR_SET(&err)) { - ELOG("Error while executing ui_comp_event callback: %s", err.msg); + ELOG("Error executing UI event callback: %s", err.msg); } api_clear_error(&err); }) -- cgit From b5a38530ba18b324c739e1d087bd78e4a0a6d4b3 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 15 Mar 2024 12:54:39 +0100 Subject: fix(ui): don't force 'cmdheight' to zero with ext_messages Remove remaining code that prevents non-zero 'cmdheight' with ext_messages. --- src/nvim/ui.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 98751c8952..75af543448 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -227,6 +227,11 @@ void ui_refresh(void) if (i < kUIGlobalCount) { ext_widgets[i] |= ui_cb_ext[i]; } + // Set 'cmdheight' to zero when ext_messages becomes active. + if (i == kUIMessages && !ui_ext[i] && ext_widgets[i]) { + set_option_value(kOptCmdheight, NUMBER_OPTVAL(0), 0); + command_height(); + } ui_ext[i] = ext_widgets[i]; if (i < kUIGlobalCount) { ui_call_option_set(cstr_as_string(ui_ext_names[i]), @@ -241,10 +246,6 @@ void ui_refresh(void) screen_resize(width, height); p_lz = save_p_lz; - if (ext_widgets[kUIMessages]) { - set_option_value(kOptCmdheight, NUMBER_OPTVAL(0), 0); - command_height(); - } ui_mode_info_set(); pending_mode_update = true; ui_cursor_shape(); -- cgit From 7626f431d84fc3a6eb82d0d23d436e3e31e991ce Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 26 Apr 2024 16:21:56 +0200 Subject: fix(ui): update ext_ui widgets when attaching non-remote UI Problem: Updating internalized UI capabilities is postponed until a remote UI attaches. Solution: Always update active UI widgets in ui_refresh(). --- src/nvim/ui.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 75af543448..dd3bb53dde 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -194,15 +194,6 @@ void ui_refresh(void) abort(); } - if (!ui_active()) { - return; - } - - if (updating_screen) { - ui_schedule_refresh(); - return; - } - int width = INT_MAX; int height = INT_MAX; bool ext_widgets[kUIExtCount]; @@ -234,11 +225,19 @@ void ui_refresh(void) } ui_ext[i] = ext_widgets[i]; if (i < kUIGlobalCount) { - ui_call_option_set(cstr_as_string(ui_ext_names[i]), - BOOLEAN_OBJ(ext_widgets[i])); + ui_call_option_set(cstr_as_string(ui_ext_names[i]), BOOLEAN_OBJ(ext_widgets[i])); } } + if (!ui_active()) { + return; + } + + if (updating_screen) { + ui_schedule_refresh(); + return; + } + ui_default_colors_set(); int save_p_lz = p_lz; -- cgit From b8c1b36061f443f82f34f3d4fe7807fc33edefa6 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 27 Apr 2024 01:00:55 +0200 Subject: fix(ui): set 'cmdheight' to zero for all open tabpages Problem: Enabling ext_messages claims to set 'cmdheight' to zero, but only does so for the current tabpage. Solution: Set stored 'cmdheight' value to zero for all tabpages. --- src/nvim/ui.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index dd3bb53dde..27458d588b 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -218,10 +218,13 @@ void ui_refresh(void) if (i < kUIGlobalCount) { ext_widgets[i] |= ui_cb_ext[i]; } - // Set 'cmdheight' to zero when ext_messages becomes active. + // Set 'cmdheight' to zero when ext_messages becomes active for all tabpages. if (i == kUIMessages && !ui_ext[i] && ext_widgets[i]) { set_option_value(kOptCmdheight, NUMBER_OPTVAL(0), 0); command_height(); + FOR_ALL_TABS(tp) { + tp->tp_ch_used = 0; + } } ui_ext[i] = ext_widgets[i]; if (i < kUIGlobalCount) { -- cgit From ab1c2220f0c7f63e2081eb22544fed9fc4b4c611 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 29 Apr 2024 02:51:33 +0200 Subject: fix(ui): activating all ext capabilities without remote UI #28555 --- src/nvim/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 27458d588b..f5bab309d8 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -198,7 +198,7 @@ void ui_refresh(void) int height = INT_MAX; bool ext_widgets[kUIExtCount]; for (UIExtension i = 0; (int)i < kUIExtCount; i++) { - ext_widgets[i] = true; + ext_widgets[i] = ui_active(); } bool inclusive = ui_override(); -- cgit From e778e0116198470ba037b9426f4ff7fa5cb7f880 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Wed, 1 May 2024 22:51:06 +0200 Subject: fix(ui): avoid recursiveness and invalid memory access #28578 Problem: Calling :redraw from vim.ui_attach() callback results in recursive cmdline/message events. Solution: Avoid recursiveness where possible and replace global "call_buf" with separate, temporary buffers for each event so that when a Lua callback for one event fires another event, that does not result in invalid memory access. --- src/nvim/ui.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index f5bab309d8..9bb66b886e 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -71,8 +71,6 @@ static bool has_mouse = false; static int pending_has_mouse = -1; static bool pending_default_colors = false; -static Array call_buf = ARRAY_DICT_INIT; - #ifdef NVIM_LOG_DEBUG static size_t uilog_seen = 0; static const char *uilog_last_event = NULL; @@ -128,14 +126,11 @@ void ui_init(void) default_grid.handle = 1; msg_grid_adj.target = &default_grid; ui_comp_init(); - kv_ensure_space(call_buf, 16); } #ifdef EXITFREE void ui_free_all_mem(void) { - kv_destroy(call_buf); - UIEventCallback *event_cb; map_foreach_value(&ui_event_cbs, event_cb, { free_ui_event_callback(event_cb); @@ -197,11 +192,9 @@ void ui_refresh(void) int width = INT_MAX; int height = INT_MAX; bool ext_widgets[kUIExtCount]; - for (UIExtension i = 0; (int)i < kUIExtCount; i++) { - ext_widgets[i] = ui_active(); - } - bool inclusive = ui_override(); + memset(ext_widgets, ui_active(), ARRAY_SIZE(ext_widgets)); + for (size_t i = 0; i < ui_count; i++) { RemoteUI *ui = uis[i]; width = MIN(ui->width, width); @@ -218,7 +211,7 @@ void ui_refresh(void) if (i < kUIGlobalCount) { ext_widgets[i] |= ui_cb_ext[i]; } - // Set 'cmdheight' to zero when ext_messages becomes active for all tabpages. + // Set 'cmdheight' to zero for all tabpages when ext_messages becomes active. if (i == kUIMessages && !ui_ext[i] && ext_widgets[i]) { set_option_value(kOptCmdheight, NUMBER_OPTVAL(0), 0); command_height(); @@ -722,6 +715,9 @@ void ui_call_event(char *name, Array args) map_foreach_value(&ui_event_cbs, event_cb, { Error err = ERROR_INIT; Object res = nlua_call_ref(event_cb->cb, name, args, kRetNilBool, NULL, &err); + // TODO(bfredl/luukvbaal): should this be documented or reconsidered? + // Why does truthy return from Lua callback mean remote UI should not receive + // the event. if (LUARET_TRUTHY(res)) { handled = true; } -- cgit