Skip to content

Commit a3f7e58

Browse files
committed
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)
1 parent c9e9c71 commit a3f7e58

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/misc2.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6300,6 +6300,8 @@ has_non_ascii(char_u *s)
63006300
void
63016301
parse_queued_messages(void)
63026302
{
6303+
win_T *old_curwin = curwin;
6304+
63036305
/* For Win32 mch_breakcheck() does not check for input, do it here. */
63046306
# if defined(WIN32) && defined(FEAT_JOB_CHANNEL)
63056307
channel_handle_events(FALSE);
@@ -6324,6 +6326,11 @@ parse_queued_messages(void)
63246326
/* Check if any jobs have ended. */
63256327
job_check_ended();
63266328
# endif
6329+
6330+
/* If the current window changed we need to bail out of the waiting loop.
6331+
* E.g. when a job exit callback closes the terminal window. */
6332+
if (curwin != old_curwin)
6333+
ins_char_typebuf(K_IGNORE);
63276334
}
63286335
#endif
63296336

src/terminal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
* in tl_scrollback are no longer used.
3939
*
4040
* TODO:
41-
* - Termdebug: issue #2154 might be avoided by adding -quiet to gdb?
42-
* patch by Christian, 2017 Oct 23.
4341
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
4442
* Higashi, 2017 Sep 19)
4543
* - double click in Window toolbar starts Visual mode (but not always?).
@@ -1581,8 +1579,12 @@ terminal_loop(int blocking)
15811579

15821580
c = term_vgetc();
15831581
if (!term_use_loop())
1582+
{
15841583
/* job finished while waiting for a character */
1584+
if (c != K_IGNORE)
1585+
vungetc(c);
15851586
break;
1587+
}
15861588
if (c == K_IGNORE)
15871589
continue;
15881590

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1276,
764766
/**/
765767
1275,
766768
/**/

0 commit comments

Comments
 (0)