diff src/channel.c @ 9189:4b55d8e162d4 v7.4.1878

commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 2 20:05:26 2016 +0200 patch 7.4.1878 Problem: Whether a job has exited isn't detected until a character is typed. After calling exit_cb the cursor is in the wrong place. Solution: Don't wait forever for a character to be typed when there is a pending job. Update the screen if neede after calling exit_cb.
author Christian Brabandt <cb@256bit.org>
date Thu, 02 Jun 2016 20:15:05 +0200
parents d0f69d0bea7a
children d2d44592467d
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -4403,6 +4403,21 @@ job_stop_on_exit()
 }
 
 /*
+ * Return TRUE when there is any job that might exit, which means
+ * job_check_ended() should be called once in a while.
+ */
+    int
+has_pending_job()
+{
+    job_T	    *job;
+
+    for (job = first_job; job != NULL; job = job->jv_next)
+	if (job->jv_status == JOB_STARTED && job_still_useful(job))
+	    return TRUE;
+    return FALSE;
+}
+
+/*
  * Called once in a while: check if any jobs that seem useful have ended.
  */
     void
@@ -4425,6 +4440,11 @@ job_check_ended(void)
 		job_status(job); /* may free "job" */
 	}
     }
+    if (channel_need_redraw)
+    {
+	channel_need_redraw = FALSE;
+	redraw_after_callback();
+    }
 }
 
 /*
@@ -4658,6 +4678,7 @@ job_status(job_T *job)
 			   job->jv_exit_partial, NULL);
 	    clear_tv(&rettv);
 	    --job->jv_refcount;
+	    channel_need_redraw = TRUE;
 	}
 	if (job->jv_status == JOB_ENDED && job->jv_refcount == 0)
 	{