changeset 13900:f71ed35527eb v8.0.1821

patch 8.0.1821: cursor in terminal window moves when pressing CTRL-W commit https://github.com/vim/vim/commit/2bc799579d06936968fa00e52b79ddd4eaca7678 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 12 20:36:24 2018 +0200 patch 8.0.1821: cursor in terminal window moves when pressing CTRL-W Problem: Cursor in terminal window moves when pressing CTRL-W. (Dominique Pelle) Solution: Do not more the cursor or redraw when not in Terminal-Normal mode. (closes #2904)
author Christian Brabandt <cb@256bit.org>
date Sat, 12 May 2018 20:45:04 +0200
parents a22bfa7581f2
children 02624d2d4780
files src/terminal.c src/version.c
diffstat 2 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1606,23 +1606,24 @@ move_terminal_to_buffer(term_T *term)
     vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
 		       &term->tl_default_color.fg, &term->tl_default_color.bg);
 
-    FOR_ALL_WINDOWS(wp)
-    {
-	if (wp->w_buffer == term->tl_buffer)
+    if (term->tl_normal_mode)
+	FOR_ALL_WINDOWS(wp)
 	{
-	    wp->w_cursor.lnum = term->tl_buffer->b_ml.ml_line_count;
-	    wp->w_cursor.col = 0;
-	    wp->w_valid = 0;
-	    if (wp->w_cursor.lnum >= wp->w_height)
+	    if (wp->w_buffer == term->tl_buffer)
 	    {
-		linenr_T min_topline = wp->w_cursor.lnum - wp->w_height + 1;
-
-		if (wp->w_topline < min_topline)
-		    wp->w_topline = min_topline;
+		wp->w_cursor.lnum = term->tl_buffer->b_ml.ml_line_count;
+		wp->w_cursor.col = 0;
+		wp->w_valid = 0;
+		if (wp->w_cursor.lnum >= wp->w_height)
+		{
+		    linenr_T min_topline = wp->w_cursor.lnum - wp->w_height + 1;
+
+		    if (wp->w_topline < min_topline)
+			wp->w_topline = min_topline;
+		}
+		redraw_win_later(wp, NOT_VALID);
 	    }
-	    redraw_win_later(wp, NOT_VALID);
 	}
-    }
 }
 
 #if defined(FEAT_TIMERS) || defined(PROTO)
@@ -1688,11 +1689,11 @@ term_enter_normal_mode(void)
 {
     term_T *term = curbuf->b_term;
 
+    set_terminal_mode(term, TRUE);
+
     /* Append the current terminal contents to the buffer. */
     move_terminal_to_buffer(term);
 
-    set_terminal_mode(term, TRUE);
-
     /* Move the window cursor to the position of the cursor in the
      * terminal. */
     curwin->w_cursor.lnum = term->tl_scrollback_scrolled
--- 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 */
 /**/
+    1821,
+/**/
     1820,
 /**/
     1819,