Patch 8.0.0592
Problem:    If a job writes to a buffer and the user is typing a command, the
            screen isn't updated. When a message is displayed the changed
            buffer may cause it to be cleared. (Ramel Eshed)
Solution:   Update the screen and then the command line if the screen didn't
            scroll. Avoid inserting screen lines, as it clears any message.
            Update the status line when the buffer changed.
Files:      src/channel.c, src/screen.c, src/ex_getln.c, src/globals.h,
            src/vim.h, src/proto/ex_getln.pro, src/proto/screen.pro


*** ../vim-8.0.0591/src/channel.c       2017-04-29 16:24:32.211919570 +0200
--- src/channel.c       2017-04-30 17:58:25.667927786 +0200
***************
*** 2404,2410 ****
                curbuf = curwin->w_buffer;
            }
        }
!       redraw_buf_later(buffer, VALID);
        channel_need_redraw = TRUE;
      }
  
--- 2404,2410 ----
                curbuf = curwin->w_buffer;
            }
        }
!       redraw_buf_and_status_later(buffer, VALID);
        channel_need_redraw = TRUE;
      }
  
*** ../vim-8.0.0591/src/screen.c        2017-03-29 20:38:53.309068287 +0200
--- src/screen.c        2017-04-30 18:00:04.691329836 +0200
***************
*** 265,270 ****
--- 265,285 ----
      }
  }
  
+     void
+ redraw_buf_and_status_later(buf_T *buf, int type)
+ {
+     win_T     *wp;
+ 
+     FOR_ALL_WINDOWS(wp)
+     {
+       if (wp->w_buffer == buf)
+       {
+           redraw_win_later(wp, type);
+           wp->w_redr_status = TRUE;
+       }
+     }
+ }
+ 
  /*
   * Redraw as soon as possible.  When the command line is not scrolled redraw
   * right away and restore what was on the command line.
***************
*** 421,430 ****
      if (State == HITRETURN || State == ASKMORE)
        ; /* do nothing */
      else if (State & CMDLINE)
!       redrawcmdline();
      else if (State & (NORMAL | INSERT))
      {
!       update_screen(0);
        setcursor();
      }
      cursor_on();
--- 436,464 ----
      if (State == HITRETURN || State == ASKMORE)
        ; /* do nothing */
      else if (State & CMDLINE)
!     {
!       /* Redrawing only works when the screen didn't scroll. */
!       if (msg_scrolled == 0)
!       {
!           update_screen(0);
!           compute_cmdrow();
!       }
!       else
!       {
!           /* Redraw in the same position, so that the user can continue
!            * editing the command. */
!           compute_cmdrow();
!           if (cmdline_row > msg_scrolled)
!               cmdline_row -= msg_scrolled;
!           else
!               cmdline_row = 0;
!       }
!       redrawcmdline_ex(FALSE);
!     }
      else if (State & (NORMAL | INSERT))
      {
!       /* keep the command line if possible */
!       update_screen(VALID_NO_UPDATE);
        setcursor();
      }
      cursor_on();
***************
*** 476,482 ****
  }
  
  /*
!  * update all windows that are editing the current buffer
   */
      void
  update_curbuf(int type)
--- 510,516 ----
  }
  
  /*
!  * Update all windows that are editing the current buffer.
   */
      void
  update_curbuf(int type)
***************
*** 490,497 ****
   * of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
   */
      void
! update_screen(int type)
  {
      win_T     *wp;
      static int        did_intro = FALSE;
  #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
--- 524,532 ----
   * of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
   */
      void
! update_screen(int type_arg)
  {
+     int               type = type_arg;
      win_T     *wp;
      static int        did_intro = FALSE;
  #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
***************
*** 502,512 ****
--- 537,554 ----
      int               gui_cursor_col;
      int               gui_cursor_row;
  #endif
+     int               no_update = FALSE;
  
      /* Don't do anything if the screen structures are (not yet) valid. */
      if (!screen_valid(TRUE))
        return;
  
+     if (type == VALID_NO_UPDATE)
+     {
+       no_update = TRUE;
+       type = 0;
+     }
+ 
      if (must_redraw)
      {
        if (type < must_redraw)     /* use maximal type */
***************
*** 539,544 ****
--- 581,588 ----
      ++display_tick;       /* let syntax code know we're in a next round of
                             * display updating */
  #endif
+     if (no_update)
+       ++no_win_do_lines_ins;
  
      /*
       * if the screen was scrolled up when displaying a message, scroll it down
***************
*** 576,582 ****
                    }
                }
            }
!           redraw_cmdline = TRUE;
  #ifdef FEAT_WINDOWS
            redraw_tabline = TRUE;
  #endif
--- 620,627 ----
                    }
                }
            }
!           if (!no_update)
!               redraw_cmdline = TRUE;
  #ifdef FEAT_WINDOWS
            redraw_tabline = TRUE;
  #endif
***************
*** 748,753 ****
--- 793,801 ----
      if (clear_cmdline || redraw_cmdline)
        showmode();
  
+     if (no_update)
+       --no_win_do_lines_ins;
+ 
      /* May put up an introductory message when not editing a file */
      if (!did_intro)
        maybe_intro_message();
***************
*** 9475,9480 ****
--- 9523,9533 ----
      if (!redrawing() || line_count <= 0)
        return FAIL;
  
+     /* When inserting lines would result in loss of command output, just 
redraw
+      * the lines. */
+     if (no_win_do_lines_ins && !del)
+       return FAIL;
+ 
      /* only a few lines left: redraw is faster */
      if (mayclear && Rows - line_count < 5
  #ifdef FEAT_WINDOWS
***************
*** 9482,9488 ****
  #endif
            )
      {
!       screenclear();      /* will set wp->w_lines_valid to 0 */
        return FAIL;
      }
  
--- 9535,9542 ----
  #endif
            )
      {
!       if (!no_win_do_lines_ins)
!           screenclear();          /* will set wp->w_lines_valid to 0 */
        return FAIL;
      }
  
***************
*** 9498,9507 ****
      }
  
      /*
!      * when scrolling, the message on the command line should be cleared,
       * otherwise it will stay there forever.
       */
!     clear_cmdline = TRUE;
  
      /*
       * If the terminal can set a scroll region, use that.
--- 9552,9563 ----
      }
  
      /*
!      * When scrolling, the message on the command line should be cleared,
       * otherwise it will stay there forever.
+      * Don't do this when avoiding to insert lines.
       */
!     if (!no_win_do_lines_ins)
!       clear_cmdline = TRUE;
  
      /*
       * If the terminal can set a scroll region, use that.
*** ../vim-8.0.0591/src/ex_getln.c      2017-04-07 15:42:20.154333034 +0200
--- src/ex_getln.c      2017-04-30 16:56:36.310341504 +0200
***************
*** 3337,3346 ****
      void
  redrawcmdline(void)
  {
      if (cmd_silent)
        return;
      need_wait_return = FALSE;
!     compute_cmdrow();
      redrawcmd();
      cursorcmd();
  }
--- 3337,3353 ----
      void
  redrawcmdline(void)
  {
+     redrawcmdline_ex(TRUE);
+ }
+ 
+     void
+ redrawcmdline_ex(int do_compute_cmdrow)
+ {
      if (cmd_silent)
        return;
      need_wait_return = FALSE;
!     if (do_compute_cmdrow)
!       compute_cmdrow();
      redrawcmd();
      cursorcmd();
  }
*** ../vim-8.0.0591/src/globals.h       2017-03-29 19:20:25.385015086 +0200
--- src/globals.h       2017-04-30 17:38:46.819043256 +0200
***************
*** 97,102 ****
--- 97,103 ----
  EXTERN int    redraw_cmdline INIT(= FALSE);   /* cmdline must be redrawn */
  EXTERN int    clear_cmdline INIT(= FALSE);    /* cmdline must be cleared */
  EXTERN int    mode_displayed INIT(= FALSE);   /* mode is being displayed */
+ EXTERN int    no_win_do_lines_ins INIT(= FALSE); /* don't insert lines */
  #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
  EXTERN int    cmdline_star INIT(= FALSE);     /* cmdline is crypted */
  #endif
*** ../vim-8.0.0591/src/vim.h   2017-03-19 21:20:45.889034350 +0100
--- src/vim.h   2017-04-30 17:07:05.282521867 +0200
***************
*** 630,635 ****
--- 630,637 ----
   * flags for update_screen()
   * The higher the value, the higher the priority
   */
+ #define VALID_NO_UPDATE                5  /* no new changes, keep the command 
line if
+                                      possible */
  #define VALID                 10  /* buffer not changed, or changes marked
                                       with b_mod_* */
  #define INVERTED              20  /* redisplay inverted part that changed */
*** ../vim-8.0.0591/src/proto/ex_getln.pro      2016-09-12 13:04:03.000000000 
+0200
--- src/proto/ex_getln.pro      2017-04-30 16:57:42.945936706 +0200
***************
*** 19,24 ****
--- 19,25 ----
  void restore_cmdline_alloc(char_u *p);
  void cmdline_paste_str(char_u *s, int literally);
  void redrawcmdline(void);
+ void redrawcmdline_ex(int do_compute_cmdrow);
  void redrawcmd(void);
  void compute_cmdrow(void);
  void gotocmdline(int clr);
*** ../vim-8.0.0591/src/proto/screen.pro        2016-09-12 13:04:17.000000000 
+0200
--- src/proto/screen.pro        2017-04-30 18:00:39.119121942 +0200
***************
*** 5,15 ****
  void redraw_all_later(int type);
  void redraw_curbuf_later(int type);
  void redraw_buf_later(buf_T *buf, int type);
  int redraw_asap(int type);
  void redraw_after_callback(void);
  void redrawWinline(linenr_T lnum, int invalid);
  void update_curbuf(int type);
! void update_screen(int type);
  int conceal_cursor_line(win_T *wp);
  void conceal_check_cursur_line(void);
  void update_single_line(win_T *wp, linenr_T lnum);
--- 5,16 ----
  void redraw_all_later(int type);
  void redraw_curbuf_later(int type);
  void redraw_buf_later(buf_T *buf, int type);
+ void redraw_buf_and_status_later(buf_T *buf, int type);
  int redraw_asap(int type);
  void redraw_after_callback(void);
  void redrawWinline(linenr_T lnum, int invalid);
  void update_curbuf(int type);
! void update_screen(int type_arg);
  int conceal_cursor_line(win_T *wp);
  void conceal_check_cursur_line(void);
  void update_single_line(win_T *wp, linenr_T lnum);
*** ../vim-8.0.0591/src/version.c       2017-04-30 16:35:22.678145560 +0200
--- src/version.c       2017-04-30 16:46:34.102024004 +0200
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     592,
  /**/

-- 
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
ANOTHER MONK:    And St.  Attila raised his hand grenade up on high saying "O
                 Lord bless this thy hand grenade that with it thou mayest
                 blow thine enemies to tiny bits, in thy mercy. "and the Lord
                 did grin and people did feast upon the lambs and sloths and
                 carp and anchovies and orang-utans and breakfast cereals and
                 fruit bats and...
BROTHER MAYNARD: Skip a bit brother ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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