]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1878 v7.4.1878
authorBram Moolenaar <Bram@vim.org>
Thu, 2 Jun 2016 18:05:26 +0000 (20:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 2 Jun 2016 18:05:26 +0000 (20:05 +0200)
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.

src/channel.c
src/os_unix.c
src/proto/channel.pro
src/version.c

index 75cadae7ab33a51a642883cb20dd9b6a5f248d86..5168f7410d7def0eb57f2ddf99e1ef5d74101257 100644 (file)
@@ -4402,6 +4402,21 @@ job_stop_on_exit()
            mch_stop_job(job, job->jv_stoponexit);
 }
 
+/*
+ * 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.
  */
@@ -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)
        {
index f7b5ae4b112e5def3de9da1717639311b486cd5d..b4808b5fe8a69c5cbbb3dc21a524555c3a3e849c 100644 (file)
@@ -438,17 +438,31 @@ mch_inchar(
 
     for (;;)   /* repeat until we got a character */
     {
+       long    wtime_now = -1L;
+
        while (do_resize)    /* window changed size */
            handle_resize();
 
 #ifdef MESSAGE_QUEUE
        parse_queued_messages();
+
+# ifdef FEAT_JOB_CHANNEL
+       if (has_pending_job())
+       {
+           /* Don't wait longer than a few seconds, checking for a finished
+            * job requires polling. */
+           if (p_ut > 9000L)
+               wtime_now = 1000L;
+           else
+               wtime_now = 10000L - p_ut;
+       }
+# endif
 #endif
        /*
         * We want to be interrupted by the winch signal
         * or by an event on the monitored file descriptors.
         */
-       if (!WaitForChar(-1L))
+       if (!WaitForChar(wtime_now))
        {
            if (do_resize)          /* interrupted by SIGWINCH signal */
                handle_resize();
index 60b68f013352d27e428a8de9600f6ec980464dbb..2f2deb4bc852a8ca4131b3cf29dfbdb60d4b5888 100644 (file)
@@ -57,6 +57,7 @@ int free_unused_jobs_contents(int copyID, int mask);
 void free_unused_jobs(int copyID, int mask);
 void job_set_options(job_T *job, jobopt_T *opt);
 void job_stop_on_exit(void);
+int has_pending_job(void);
 void job_check_ended(void);
 job_T *job_start(typval_T *argvars);
 char *job_status(job_T *job);
index aeed59180116e83cfbf00b7ee54903c6813df690..f450ba8bbb0fdf6aab6cab56125450cf668e344c 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1878,
 /**/
     1877,
 /**/