mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
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.
This commit is contained in:
@@ -3449,9 +3449,11 @@ void cmdline_screen_cleared(void)
|
||||
/// called by ui_flush, do what redraws necessary to keep cmdline updated.
|
||||
void cmdline_ui_flush(void)
|
||||
{
|
||||
if (!ui_has(kUICmdline)) {
|
||||
static bool flushing = false;
|
||||
if (!ui_has(kUICmdline) || flushing) {
|
||||
return;
|
||||
}
|
||||
flushing = true;
|
||||
int level = ccline.level;
|
||||
CmdlineInfo *line = &ccline;
|
||||
while (level > 0 && line) {
|
||||
@@ -3466,6 +3468,7 @@ void cmdline_ui_flush(void)
|
||||
}
|
||||
line = line->prev_ccline;
|
||||
}
|
||||
flushing = false;
|
||||
}
|
||||
|
||||
// Put a character on the command line. Shifts the following text to the
|
||||
|
Reference in New Issue
Block a user