diff src/misc2.c @ 12798:5ae0d05e046a v8.0.1276

patch 8.0.1276: key lost when window closed in exit callback commit https://github.com/vim/vim/commit/a3f7e58bf846b28b347a5d5b96c2d829871bd212 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 9 13:21:58 2017 +0100 patch 8.0.1276: key lost when window closed in exit callback Problem: Typed key is lost when the terminal window is closed in exit callback. (Gabriel Barta) Solution: When the current window changes bail out of the wait loop. (closes #2302)
author Christian Brabandt <cb@256bit.org>
date Thu, 09 Nov 2017 13:30:05 +0100
parents 351cf7c67bbe
children ebb4f6c93598
line wrap: on
line diff
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -6300,6 +6300,8 @@ has_non_ascii(char_u *s)
     void
 parse_queued_messages(void)
 {
+    win_T *old_curwin = curwin;
+
     /* For Win32 mch_breakcheck() does not check for input, do it here. */
 # if defined(WIN32) && defined(FEAT_JOB_CHANNEL)
     channel_handle_events(FALSE);
@@ -6324,6 +6326,11 @@ parse_queued_messages(void)
     /* Check if any jobs have ended. */
     job_check_ended();
 # endif
+
+    /* If the current window changed we need to bail out of the waiting loop.
+     * E.g. when a job exit callback closes the terminal window. */
+    if (curwin != old_curwin)
+	ins_char_typebuf(K_IGNORE);
 }
 #endif