0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.0466: not parsing messages recursively breaks the govim plugin

Problem:    Not parsing messages recursively breaks the govim plugin.
Solution:   When called recursively do handle messages but do not close
            channels.
This commit is contained in:
Bram Moolenaar 2020-03-28 18:06:31 +01:00
parent 599c89c82f
commit 09c569038c
2 changed files with 34 additions and 30 deletions

View File

@ -4428,16 +4428,14 @@ channel_parse_messages(void)
int ret = FALSE; int ret = FALSE;
int r; int r;
ch_part_T part = PART_SOCK; ch_part_T part = PART_SOCK;
static int recursive = FALSE; static int recursive = 0;
#ifdef ELAPSED_FUNC #ifdef ELAPSED_FUNC
elapsed_T start_tv; elapsed_T start_tv;
#endif #endif
// The code below may invoke callbacks, which might call us back. // The code below may invoke callbacks, which might call us back.
// That doesn't work well, just return without doing anything. // In a recursive call channels will not be closed.
if (recursive) ++recursive;
return FALSE;
recursive = TRUE;
++safe_to_invoke_callback; ++safe_to_invoke_callback;
#ifdef ELAPSED_FUNC #ifdef ELAPSED_FUNC
@ -4454,33 +4452,37 @@ channel_parse_messages(void)
} }
while (channel != NULL) while (channel != NULL)
{ {
if (channel_can_close(channel)) if (recursive == 1)
{ {
channel->ch_to_be_closed = (1U << PART_COUNT); if (channel_can_close(channel))
channel_close_now(channel); {
// channel may have been freed, start over channel->ch_to_be_closed = (1U << PART_COUNT);
channel = first_channel; channel_close_now(channel);
continue; // channel may have been freed, start over
} channel = first_channel;
if (channel->ch_to_be_freed || channel->ch_killing) continue;
{ }
channel_free_contents(channel); if (channel->ch_to_be_freed || channel->ch_killing)
if (channel->ch_job != NULL) {
channel->ch_job->jv_channel = NULL; channel_free_contents(channel);
if (channel->ch_job != NULL)
channel->ch_job->jv_channel = NULL;
// free the channel and then start over // free the channel and then start over
channel_free_channel(channel); channel_free_channel(channel);
channel = first_channel; channel = first_channel;
continue; continue;
} }
if (channel->ch_refcount == 0 && !channel_still_useful(channel)) if (channel->ch_refcount == 0 && !channel_still_useful(channel))
{ {
// channel is no longer useful, free it // channel is no longer useful, free it
channel_free(channel); channel_free(channel);
channel = first_channel; channel = first_channel;
part = PART_SOCK; part = PART_SOCK;
continue; continue;
}
} }
if (channel->ch_part[part].ch_fd != INVALID_FD if (channel->ch_part[part].ch_fd != INVALID_FD
|| channel_has_readahead(channel, part)) || channel_has_readahead(channel, part))
{ {
@ -4521,7 +4523,7 @@ channel_parse_messages(void)
} }
--safe_to_invoke_callback; --safe_to_invoke_callback;
recursive = FALSE; --recursive;
return ret; return ret;
} }

View File

@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
466,
/**/ /**/
465, 465,
/**/ /**/