Patch 8.0.1830
Problem:    Switching to Terminal-Normal mode does not redraw. (Dominique
            Pelle)
Solution:   Also redraw when not updating the snapshot. (closes #2904)
Files:      src/terminal.c


*** ../vim-8.0.1829/src/terminal.c      2018-05-12 21:16:15.361769892 +0200
--- src/terminal.c      2018-05-13 15:11:00.252618575 +0200
***************
*** 1479,1506 ****
  
  /*
   * Add the current lines of the terminal to scrollback and to the buffer.
-  * Called after the job has ended and when switching to Terminal-Normal mode.
   */
      static void
! move_terminal_to_buffer(term_T *term)
  {
!     win_T         *wp;
      int                   len;
      int                   lines_skipped = 0;
      VTermPos      pos;
      VTermScreenCell cell;
      cellattr_T            fill_attr, new_fill_attr;
      cellattr_T            *p;
-     VTermScreen           *screen;
- 
-     if (term->tl_vterm == NULL)
-       return;
- 
-     /* Nothing to do if the buffer already has the lines and nothing was
-      * changed. */
-     if (!term->tl_dirty_snapshot && term->tl_buffer->b_ml.ml_line_count
-                                               > term->tl_scrollback_scrolled)
-       return;
  
      ch_log(term->tl_job == NULL ? NULL : term->tl_job->jv_channel,
                                  "Adding terminal window snapshot to buffer");
--- 1479,1495 ----
  
  /*
   * Add the current lines of the terminal to scrollback and to the buffer.
   */
      static void
! update_snapshot(term_T *term)
  {
!     VTermScreen           *screen;
      int                   len;
      int                   lines_skipped = 0;
      VTermPos      pos;
      VTermScreenCell cell;
      cellattr_T            fill_attr, new_fill_attr;
      cellattr_T            *p;
  
      ch_log(term->tl_job == NULL ? NULL : term->tl_job->jv_channel,
                                  "Adding terminal window snapshot to buffer");
***************
*** 1601,1612 ****
  #ifdef FEAT_TIMERS
      term->tl_timer_set = FALSE;
  #endif
  
      /* Obtain the current background color. */
      vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
                       &term->tl_default_color.fg, &term->tl_default_color.bg);
  
!     if (term->tl_normal_mode)
        FOR_ALL_WINDOWS(wp)
        {
            if (wp->w_buffer == term->tl_buffer)
--- 1590,1622 ----
  #ifdef FEAT_TIMERS
      term->tl_timer_set = FALSE;
  #endif
+ }
+ 
+ /*
+  * If needed, add the current lines of the terminal to scrollback and to the
+  * buffer.  Called after the job has ended and when switching to
+  * Terminal-Normal mode.
+  * When "redraw" is TRUE redraw the windows that show the terminal.
+  */
+     static void
+ may_move_terminal_to_buffer(term_T *term, int redraw)
+ {
+     win_T         *wp;
+ 
+     if (term->tl_vterm == NULL)
+       return;
+ 
+     /* Update the snapshot only if something changes or the buffer does not
+      * have all the lines. */
+     if (term->tl_dirty_snapshot || term->tl_buffer->b_ml.ml_line_count
+                                              <= term->tl_scrollback_scrolled)
+       update_snapshot(term);
  
      /* Obtain the current background color. */
      vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
                       &term->tl_default_color.fg, &term->tl_default_color.bg);
  
!     if (redraw)
        FOR_ALL_WINDOWS(wp)
        {
            if (wp->w_buffer == term->tl_buffer)
***************
*** 1647,1653 ****
            if (this_due <= 1)
            {
                term->tl_timer_set = FALSE;
!               move_terminal_to_buffer(term);
            }
            else if (next_due == -1 || next_due > this_due)
                next_due = this_due;
--- 1657,1663 ----
            if (this_due <= 1)
            {
                term->tl_timer_set = FALSE;
!               may_move_terminal_to_buffer(term, FALSE);
            }
            else if (next_due == -1 || next_due > this_due)
                next_due = this_due;
***************
*** 1675,1681 ****
  cleanup_vterm(term_T *term)
  {
      if (term->tl_finish != TL_FINISH_CLOSE)
!       move_terminal_to_buffer(term);
      term_free_vterm(term);
      set_terminal_mode(term, FALSE);
  }
--- 1685,1691 ----
  cleanup_vterm(term_T *term)
  {
      if (term->tl_finish != TL_FINISH_CLOSE)
!       may_move_terminal_to_buffer(term, TRUE);
      term_free_vterm(term);
      set_terminal_mode(term, FALSE);
  }
***************
*** 1692,1698 ****
      set_terminal_mode(term, TRUE);
  
      /* Append the current terminal contents to the buffer. */
!     move_terminal_to_buffer(term);
  
      /* Move the window cursor to the position of the cursor in the
       * terminal. */
--- 1702,1708 ----
      set_terminal_mode(term, TRUE);
  
      /* Append the current terminal contents to the buffer. */
!     may_move_terminal_to_buffer(term, TRUE);
  
      /* Move the window cursor to the position of the cursor in the
       * terminal. */
***************
*** 2255,2261 ****
      /* Move a snapshot of the screen contents to the buffer, so that 
completion
       * works in other buffers. */
      if (curbuf->b_term != NULL)
!       move_terminal_to_buffer(curbuf->b_term);
  
      return ret;
  }
--- 2265,2272 ----
      /* Move a snapshot of the screen contents to the buffer, so that 
completion
       * works in other buffers. */
      if (curbuf->b_term != NULL)
!       may_move_terminal_to_buffer(
!                              curbuf->b_term, curbuf->b_term->tl_normal_mode);
  
      return ret;
  }
*** ../vim-8.0.1829/src/version.c       2018-05-13 14:45:20.649913183 +0200
--- src/version.c       2018-05-13 15:14:47.986931491 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1830,
  /**/

-- 
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui