mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3640: freeze when calling term_wait() in a close callback
Problem: Freeze when calling term_wait() in a close callback. Solution: Set a "closing" flag to tell term_wait() to return. (closes #9152)
This commit is contained in:
@@ -99,6 +99,7 @@ struct terminal_S {
|
||||
int tl_vterm_size_changed;
|
||||
|
||||
int tl_normal_mode; // TRUE: Terminal-Normal mode
|
||||
int tl_channel_closing;
|
||||
int tl_channel_closed;
|
||||
int tl_channel_recently_closed; // still need to handle tl_finish
|
||||
|
||||
@@ -3458,6 +3459,20 @@ may_close_term_popup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Called when a channel is going to be closed, before invoking the close
|
||||
* callback.
|
||||
*/
|
||||
void
|
||||
term_channel_closing(channel_T *ch)
|
||||
{
|
||||
term_T *term;
|
||||
|
||||
for (term = first_term; term != NULL; term = term->tl_next)
|
||||
if (term->tl_job == ch->ch_job && !term->tl_channel_closed)
|
||||
term->tl_channel_closing = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a channel has been closed.
|
||||
* If this was a channel for a terminal window then finish it up.
|
||||
@@ -6438,6 +6453,9 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
// If the terminal is closed when the channel is closed the
|
||||
// buffer disappears.
|
||||
break;
|
||||
if (buf->b_term == NULL || buf->b_term->tl_channel_closing)
|
||||
// came here from a close callback, only wait one time
|
||||
break;
|
||||
}
|
||||
|
||||
term_flush_messages();
|
||||
|
Reference in New Issue
Block a user