summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-05-21 18:48:12 +0200
committerBram Moolenaar <Bram@vim.org>2018-05-21 18:48:12 +0200
commit05af9a419198245f0810301ac9a3d59a9432ef21 (patch)
tree8b9ef822244632edb2c3d6ca90fd15e1278eb7e2
parent6053f2d29a979ffed1fe01b0a2f28e23750530e9 (diff)
patch 8.1.0015: cursor color wrong when closing a terminal windowv8.1.0015
Problem: Cursor color wrong when closing a terminal window, ending up in another terminal window. (Dominique Pelle) Solution: Bail out of terminal_loop() when the buffer changes. (closes #2942)
-rw-r--r--src/terminal.c28
-rw-r--r--src/version.c2
2 files changed, 18 insertions, 12 deletions
diff --git a/src/terminal.c b/src/terminal.c
index dea902f3a4..817e6b9375 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -183,14 +183,7 @@ static int desired_cursor_blink = -1;
* 1. Generic code for all systems.
*/
- static void
-cursor_color_copy(char_u** to_color, char_u* from_color)
-{
- vim_free(*to_color);
- *to_color = (from_color == NULL) ? NULL : vim_strsave(from_color);
-}
-
- static int
+ static int
cursor_color_equal(char_u *lhs_color, char_u *rhs_color)
{
if (lhs_color != NULL && rhs_color != NULL)
@@ -198,7 +191,17 @@ cursor_color_equal(char_u *lhs_color, char_u *rhs_color)
return lhs_color == NULL && rhs_color == NULL;
}
- static char_u *
+ static void
+cursor_color_copy(char_u **to_color, char_u *from_color)
+{
+ // Avoid a free & alloc if the value is already right.
+ if (cursor_color_equal(*to_color, from_color))
+ return;
+ vim_free(*to_color);
+ *to_color = (from_color == NULL) ? NULL : vim_strsave(from_color);
+}
+
+ static char_u *
cursor_color_get(char_u *color)
{
return (color == NULL) ? (char_u *)"" : color;
@@ -2119,7 +2122,7 @@ terminal_loop(int blocking)
while (must_redraw != 0)
if (update_screen(0) == FAIL)
break;
- if (!term_use_loop_check(TRUE))
+ if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
/* job finished while redrawing */
break;
@@ -2127,7 +2130,7 @@ terminal_loop(int blocking)
restore_cursor = TRUE;
c = term_vgetc();
- if (!term_use_loop_check(TRUE))
+ if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
{
/* Job finished while waiting for a character. Push back the
* received character. */
@@ -2178,7 +2181,8 @@ terminal_loop(int blocking)
#ifdef FEAT_CMDL_INFO
clear_showcmd();
#endif
- if (!term_use_loop_check(TRUE))
+ if (!term_use_loop_check(TRUE)
+ || in_terminal_loop != curbuf->b_term)
/* job finished while waiting for a character */
break;
diff --git a/src/version.c b/src/version.c
index 41973d7035..d1a75a1148 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 15,
+/**/
14,
/**/
13,