comparison src/terminal.c @ 13994:411dd50f1daa v8.1.0015

patch 8.1.0015: cursor color wrong when closing a terminal window commit https://github.com/vim/vim/commit/05af9a419198245f0810301ac9a3d59a9432ef21 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 21 18:48:12 2018 +0200 patch 8.1.0015: cursor color wrong when closing a terminal window 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)
author Christian Brabandt <cb@256bit.org>
date Mon, 21 May 2018 19:00:07 +0200
parents 017c5462ed5e
children 59121ffd7fce
comparison
equal deleted inserted replaced
13993:4019a7f0d970 13994:411dd50f1daa
181 181
182 /************************************** 182 /**************************************
183 * 1. Generic code for all systems. 183 * 1. Generic code for all systems.
184 */ 184 */
185 185
186 static void 186 static int
187 cursor_color_copy(char_u** to_color, char_u* from_color)
188 {
189 vim_free(*to_color);
190 *to_color = (from_color == NULL) ? NULL : vim_strsave(from_color);
191 }
192
193 static int
194 cursor_color_equal(char_u *lhs_color, char_u *rhs_color) 187 cursor_color_equal(char_u *lhs_color, char_u *rhs_color)
195 { 188 {
196 if (lhs_color != NULL && rhs_color != NULL) 189 if (lhs_color != NULL && rhs_color != NULL)
197 return STRCMP(lhs_color, rhs_color) == 0; 190 return STRCMP(lhs_color, rhs_color) == 0;
198 return lhs_color == NULL && rhs_color == NULL; 191 return lhs_color == NULL && rhs_color == NULL;
199 } 192 }
200 193
201 static char_u * 194 static void
195 cursor_color_copy(char_u **to_color, char_u *from_color)
196 {
197 // Avoid a free & alloc if the value is already right.
198 if (cursor_color_equal(*to_color, from_color))
199 return;
200 vim_free(*to_color);
201 *to_color = (from_color == NULL) ? NULL : vim_strsave(from_color);
202 }
203
204 static char_u *
202 cursor_color_get(char_u *color) 205 cursor_color_get(char_u *color)
203 { 206 {
204 return (color == NULL) ? (char_u *)"" : color; 207 return (color == NULL) ? (char_u *)"" : color;
205 } 208 }
206 209
2117 /* Repeat redrawing in case a message is received while redrawing. 2120 /* Repeat redrawing in case a message is received while redrawing.
2118 */ 2121 */
2119 while (must_redraw != 0) 2122 while (must_redraw != 0)
2120 if (update_screen(0) == FAIL) 2123 if (update_screen(0) == FAIL)
2121 break; 2124 break;
2122 if (!term_use_loop_check(TRUE)) 2125 if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
2123 /* job finished while redrawing */ 2126 /* job finished while redrawing */
2124 break; 2127 break;
2125 2128
2126 update_cursor(curbuf->b_term, FALSE); 2129 update_cursor(curbuf->b_term, FALSE);
2127 restore_cursor = TRUE; 2130 restore_cursor = TRUE;
2128 2131
2129 c = term_vgetc(); 2132 c = term_vgetc();
2130 if (!term_use_loop_check(TRUE)) 2133 if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
2131 { 2134 {
2132 /* Job finished while waiting for a character. Push back the 2135 /* Job finished while waiting for a character. Push back the
2133 * received character. */ 2136 * received character. */
2134 if (c != K_IGNORE) 2137 if (c != K_IGNORE)
2135 vungetc(c); 2138 vungetc(c);
2176 #endif 2179 #endif
2177 c = term_vgetc(); 2180 c = term_vgetc();
2178 #ifdef FEAT_CMDL_INFO 2181 #ifdef FEAT_CMDL_INFO
2179 clear_showcmd(); 2182 clear_showcmd();
2180 #endif 2183 #endif
2181 if (!term_use_loop_check(TRUE)) 2184 if (!term_use_loop_check(TRUE)
2185 || in_terminal_loop != curbuf->b_term)
2182 /* job finished while waiting for a character */ 2186 /* job finished while waiting for a character */
2183 break; 2187 break;
2184 2188
2185 if (prev_c == Ctrl_BSL) 2189 if (prev_c == Ctrl_BSL)
2186 { 2190 {