patch 8.0.1000: cannot open a terminal without running a job in it
Problem: Cannot open a terminal without running a job in it.
Solution: Make ":terminal NONE" open a terminal with a pty.
diff --git a/src/channel.c b/src/channel.c
index 1680d0d..b31d95d 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -503,6 +503,10 @@
if (!CH_HAS_GUI)
return;
+ /* gets stuck in handling events for a not connected channel */
+ if (channel->ch_keep_open)
+ return;
+
# ifdef FEAT_GUI_X11
/* Tell notifier we are interested in being called
* when there is input on the editor connection socket. */
@@ -548,9 +552,12 @@
{
if (channel->CH_SOCK_FD != INVALID_FD)
channel_gui_register_one(channel, PART_SOCK);
- if (channel->CH_OUT_FD != INVALID_FD)
+ if (channel->CH_OUT_FD != INVALID_FD
+ && channel->CH_OUT_FD != channel->CH_SOCK_FD)
channel_gui_register_one(channel, PART_OUT);
- if (channel->CH_ERR_FD != INVALID_FD)
+ if (channel->CH_ERR_FD != INVALID_FD
+ && channel->CH_ERR_FD != channel->CH_SOCK_FD
+ && channel->CH_ERR_FD != channel->CH_OUT_FD)
channel_gui_register_one(channel, PART_ERR);
}
@@ -3247,11 +3254,13 @@
/* Reading a disconnection (readlen == 0), or an error. */
if (readlen <= 0)
- ch_close_part_on_error(channel, part, (len < 0), func);
-
+ {
+ if (!channel->ch_keep_open)
+ ch_close_part_on_error(channel, part, (len < 0), func);
+ }
#if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK)
- /* signal the main loop that there is something to read */
- if (CH_HAS_GUI && gtk_main_level() > 0)
+ else if (CH_HAS_GUI && gtk_main_level() > 0)
+ /* signal the main loop that there is something to read */
gtk_main_quit();
#endif
}
@@ -3509,13 +3518,14 @@
}
# endif
-# if defined(WIN32) || defined(PROTO)
+# if defined(WIN32) || defined(FEAT_GUI) || defined(PROTO)
/*
* Check the channels for anything that is ready to be read.
* The data is put in the read queue.
+ * if "only_keep_open" is TRUE only check channels where ch_keep_open is set.
*/
void
-channel_handle_events(void)
+channel_handle_events(int only_keep_open)
{
channel_T *channel;
ch_part_T part;
@@ -3523,6 +3533,9 @@
for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
+ if (only_keep_open && !channel->ch_keep_open)
+ continue;
+
/* check the socket and pipes */
for (part = PART_SOCK; part < PART_IN; ++part)
{