Merge pull request #638 from ichizok/fix/terminal-close

Check the channels of finished-jobs
This commit is contained in:
Kazuki Sakamoto
2018-02-18 10:44:08 -08:00
committed by GitHub
5 changed files with 63 additions and 1 deletions
+21 -1
View File
@@ -24,6 +24,8 @@ int use_gui_macvim_draw_string = 1;
static int use_graphical_sign = 0;
static BOOL is_macos_high_sierra_or_later = NO;
// Max number of files to add to MRU in one go (this matches the maximum that
// Cocoa displays in the MRU -- if this changes in Cocoa then update this
// number as well).
@@ -283,6 +285,15 @@ gui_mch_init(void)
[[MMBackend sharedInstance] addToMRU:filenames];
}
#if defined(MAC_OS_X_VERSION_10_10)
{
NSOperatingSystemVersion version = {10, 13, 0};
is_macos_high_sierra_or_later =
[[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:version];
}
#endif
return OK;
}
@@ -2315,8 +2326,9 @@ static int vimModMaskToEventModifierFlags(int mods)
// -- Channel Support ------------------------------------------------------
// -- Job and Channel Support ------------------------------------------------------
#if defined(FEAT_JOB_CHANNEL)
void *
gui_macvim_add_channel(channel_T *channel, ch_part_T part)
{
@@ -2340,6 +2352,14 @@ gui_macvim_remove_channel(void *cookie)
dispatch_release(s);
}
void
gui_macvim_cleanup_job_all(void)
{
if (is_macos_high_sierra_or_later)
job_cleanup_all();
}
#endif // FEAT_JOB_CHANNEL
// -- Graphical Sign Support ------------------------------------------------
+34
View File
@@ -5686,4 +5686,38 @@ job_stop(job_T *job, typval_T *argvars, char *type)
return 1;
}
# ifdef FEAT_GUI_MACVIM
void
job_cleanup_all(void)
{
job_T *job;
for (job = first_job; job != NULL; job = job->jv_next)
{
channel_T *channel = job->jv_channel;
ch_part_T part;
if (channel == NULL || job->jv_status != JOB_FINISHED)
continue;
/* check the socket and pipes */
for (part = PART_SOCK; part < PART_IN; ++part)
{
sock_T fd = channel->ch_part[part].ch_fd;
if (fd != INVALID_FD)
{
int r = channel_wait(channel, fd, 0);
if (r == CW_READY)
channel_read(channel, part, "job_cleanup_all");
else if (r == CW_ERROR)
ch_close_part_on_error(channel, part, TRUE,
"job_cleanup_all");
}
}
}
}
# endif
#endif /* FEAT_JOB_CHANNEL */
+5
View File
@@ -6361,6 +6361,11 @@ parse_queued_messages(void)
channel_handle_events(FALSE);
# endif
# if defined(FEAT_GUI_MACVIM) && defined(FEAT_JOB_CHANNEL)
if (gui.in_use)
gui_macvim_cleanup_job_all();
# endif
# ifdef FEAT_NETBEANS_INTG
/* Process the queued netbeans messages. */
netbeans_parse_messages();
+1
View File
@@ -71,4 +71,5 @@ job_T *job_start(typval_T *argvars, jobopt_T *opt_arg);
char *job_status(job_T *job);
void job_info(job_T *job, dict_T *dict);
int job_stop(job_T *job, typval_T *argvars, char *type);
void job_cleanup_all(void);
/* vim: set ft=c : */
+2
View File
@@ -240,6 +240,8 @@ im_set_control(int enable);
gui_macvim_add_channel(channel_T *channel, ch_part_T part);
void
gui_macvim_remove_channel(void *cookie);
void
gui_macvim_cleanup_job_all(void);
void
gui_mch_drawsign(int row, int col, int typenr);