Patch 8.2.3763
Problem:    When editing the command line a FocusLost callback may cause the
            screen to scroll up.
Solution:   Do not redraw at the last line but at the same place where the
            command line was before. (closes #9295)
Files:      src/ex_getln.c, src/ui.c, src/beval.c, src/channel.c,
            src/drawscreen.c, src/proto/drawscreen.pro, src/job.c,
            src/popupwin.c, src/sound.c, src/terminal.c, src/time.c,
            src/testdir/test_terminal.vim,
            src/testdir/dumps/Test_terminal_focus_1.dump,
            src/testdir/dumps/Test_terminal_focus_2.dump,
            src/testdir/dumps/Test_terminal_focus_3.dump


*** ../vim-8.2.3762/src/ex_getln.c      2021-11-20 19:13:35.945146370 +0000
--- src/ex_getln.c      2021-12-09 10:49:50.930876612 +0000
***************
*** 3730,3735 ****
--- 3730,3739 ----
      redrawcmdline_ex(TRUE);
  }
  
+ /*
+  * When "do_compute_cmdrow" is TRUE the command line is redrawn at the bottom.
+  * If FALSE cmdline_row is used, which should redraw in the same place.
+  */
      void
  redrawcmdline_ex(int do_compute_cmdrow)
  {
*** ../vim-8.2.3762/src/ui.c    2021-12-08 22:13:13.101328561 +0000
--- src/ui.c    2021-12-09 10:12:15.796733689 +0000
***************
*** 1156,1184 ****
                                : EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf);
  
      if (need_redraw)
!     {
!       // Something was executed, make sure the cursor is put back where it
!       // belongs.
!       need_wait_return = FALSE;
! 
!       if (State & CMDLINE)
!           redrawcmdline();
!       else if (State == HITRETURN || State == SETWSIZE || State == ASKMORE
!               || State == EXTERNCMD || State == CONFIRM || exmode_active)
!           repeat_message();
!       else if ((State & NORMAL) || (State & INSERT))
!       {
!           if (must_redraw != 0)
!               update_screen(0);
!           setcursor();
!       }
!       cursor_on();        // redrawing may have switched it off
!       out_flush_cursor(FALSE, TRUE);
! # ifdef FEAT_GUI
!       if (gui.in_use)
!           gui_update_scrollbars(FALSE);
! # endif
!     }
  
      // File may have been changed from 'readonly' to 'noreadonly'
      if (need_maketitle)
--- 1156,1162 ----
                                : EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf);
  
      if (need_redraw)
!       redraw_after_callback(TRUE, TRUE);
  
      // File may have been changed from 'readonly' to 'noreadonly'
      if (need_maketitle)
*** ../vim-8.2.3762/src/beval.c 2021-12-06 11:24:05.592240981 +0000
--- src/beval.c 2021-12-09 10:08:56.816943514 +0000
***************
*** 308,314 ****
            // The 'balloonexpr' evaluation may show something on the screen
            // that requires a screen update.
            if (must_redraw)
!               redraw_after_callback(FALSE);
  
            recursive = FALSE;
            return;
--- 308,314 ----
            // The 'balloonexpr' evaluation may show something on the screen
            // that requires a screen update.
            if (must_redraw)
!               redraw_after_callback(FALSE, FALSE);
  
            recursive = FALSE;
            return;
*** ../vim-8.2.3762/src/channel.c       2021-12-05 22:19:22.832153464 +0000
--- src/channel.c       2021-12-09 10:09:17.024923157 +0000
***************
*** 3205,3211 ****
              if (channel_need_redraw)
              {
                  channel_need_redraw = FALSE;
!                 redraw_after_callback(TRUE);
              }
  
              if (!channel->ch_drop_never)
--- 3205,3211 ----
              if (channel_need_redraw)
              {
                  channel_need_redraw = FALSE;
!                 redraw_after_callback(TRUE, FALSE);
              }
  
              if (!channel->ch_drop_never)
***************
*** 4687,4693 ****
      if (channel_need_redraw)
      {
        channel_need_redraw = FALSE;
!       redraw_after_callback(TRUE);
      }
  
      --safe_to_invoke_callback;
--- 4687,4693 ----
      if (channel_need_redraw)
      {
        channel_need_redraw = FALSE;
!       redraw_after_callback(TRUE, FALSE);
      }
  
      --safe_to_invoke_callback;
*** ../vim-8.2.3762/src/drawscreen.c    2021-11-29 20:39:06.670101630 +0000
--- src/drawscreen.c    2021-12-09 10:32:59.742517487 +0000
***************
*** 3019,3032 ****
   * it belongs. If highlighting was changed a redraw is needed.
   * If "call_update_screen" is FALSE don't call update_screen() when at the
   * command line.
   */
      void
! redraw_after_callback(int call_update_screen)
  {
      ++redrawing_for_callback;
  
!     if (State == HITRETURN || State == ASKMORE)
!       ; // do nothing
      else if (State & CMDLINE)
      {
        // Don't redraw when in prompt_for_number().
--- 3019,3037 ----
   * it belongs. If highlighting was changed a redraw is needed.
   * If "call_update_screen" is FALSE don't call update_screen() when at the
   * command line.
+  * If "redraw_message" is TRUE.
   */
      void
! redraw_after_callback(int call_update_screen, int do_message)
  {
      ++redrawing_for_callback;
  
!     if (State == HITRETURN || State == ASKMORE || State == SETWSIZE
!           || State == EXTERNCMD || State == CONFIRM || exmode_active)
!     {
!       if (do_message)
!           repeat_message();
!     }
      else if (State & CMDLINE)
      {
        // Don't redraw when in prompt_for_number().
*** ../vim-8.2.3762/src/proto/drawscreen.pro    2021-04-01 15:15:59.184829183 
+0100
--- src/proto/drawscreen.pro    2021-12-09 10:13:45.528633588 +0000
***************
*** 8,14 ****
  void update_debug_sign(buf_T *buf, linenr_T lnum);
  void updateWindow(win_T *wp);
  int redraw_asap(int type);
! void redraw_after_callback(int call_update_screen);
  void redraw_later(int type);
  void redraw_win_later(win_T *wp, int type);
  void redraw_later_clear(void);
--- 8,14 ----
  void update_debug_sign(buf_T *buf, linenr_T lnum);
  void updateWindow(win_T *wp);
  int redraw_asap(int type);
! void redraw_after_callback(int call_update_screen, int do_message);
  void redraw_later(int type);
  void redraw_win_later(win_T *wp, int type);
  void redraw_later_clear(void);
*** ../vim-8.2.3762/src/job.c   2021-12-07 12:23:53.987565086 +0000
--- src/job.c   2021-12-09 10:13:53.560624481 +0000
***************
*** 1260,1266 ****
      if (channel_need_redraw)
      {
        channel_need_redraw = FALSE;
!       redraw_after_callback(TRUE);
      }
      return did_end;
  }
--- 1260,1266 ----
      if (channel_need_redraw)
      {
        channel_need_redraw = FALSE;
!       redraw_after_callback(TRUE, FALSE);
      }
      return did_end;
  }
*** ../vim-8.2.3762/src/popupwin.c      2021-12-05 22:19:22.836153466 +0000
--- src/popupwin.c      2021-12-09 10:14:09.900605900 +0000
***************
*** 3357,3363 ****
  
        // Reset got_int to avoid a function used in the statusline aborts.
        got_int = FALSE;
!       redraw_after_callback(FALSE);
        got_int |= save_got_int;
      }
      recursive = FALSE;
--- 3357,3363 ----
  
        // Reset got_int to avoid a function used in the statusline aborts.
        got_int = FALSE;
!       redraw_after_callback(FALSE, FALSE);
        got_int |= save_got_int;
      }
      recursive = FALSE;
*** ../vim-8.2.3762/src/sound.c 2021-07-27 21:00:39.749712387 +0100
--- src/sound.c 2021-12-09 10:14:30.760582035 +0000
***************
*** 173,179 ****
        delete_sound_callback(scb->scb_callback);
        vim_free(scb);
      }
!     redraw_after_callback(TRUE);
  }
  
      static void
--- 173,179 ----
        delete_sound_callback(scb->scb_callback);
        vim_free(scb);
      }
!     redraw_after_callback(TRUE, FALSE);
  }
  
      static void
***************
*** 327,333 ****
                    clear_tv(&rettv);
  
                    delete_sound_callback(p);
!                   redraw_after_callback(TRUE);
  
                }
            break;
--- 327,333 ----
                    clear_tv(&rettv);
  
                    delete_sound_callback(p);
!                   redraw_after_callback(TRUE, FALSE);
  
                }
            break;
*** ../vim-8.2.3762/src/terminal.c      2021-12-08 22:13:13.105328552 +0000
--- src/terminal.c      2021-12-09 10:14:36.460575503 +0000
***************
*** 1258,1264 ****
                update_cursor(curbuf->b_term, TRUE);
        }
        else
!           redraw_after_callback(TRUE);
      }
  }
  
--- 1258,1264 ----
                update_cursor(curbuf->b_term, TRUE);
        }
        else
!           redraw_after_callback(TRUE, FALSE);
      }
  }
  
*** ../vim-8.2.3762/src/time.c  2021-08-14 13:00:58.233863891 +0100
--- src/time.c  2021-12-09 10:14:48.252561947 +0000
***************
*** 595,601 ****
      }
  
      if (did_one)
!       redraw_after_callback(need_update_screen);
  
  #ifdef FEAT_BEVAL_TERM
      if (bevalexpr_due_set)
--- 595,601 ----
      }
  
      if (did_one)
!       redraw_after_callback(need_update_screen, FALSE);
  
  #ifdef FEAT_BEVAL_TERM
      if (bevalexpr_due_set)
*** ../vim-8.2.3762/src/testdir/test_terminal.vim       2021-12-08 
22:13:13.105328552 +0000
--- src/testdir/test_terminal.vim       2021-12-09 10:35:16.002673429 +0000
***************
*** 1135,1142 ****
  
    let lines =<< trim END
        set term=xterm ttymouse=xterm2
!       au FocusLost * echo 'I am lost'
!       au FocusGained * echo 'I am back'
        " FIXME: sometimes this job hangs, exit after a couple of seconds
        call timer_start(2000, {id -> execute('qall')})
    END
--- 1135,1142 ----
  
    let lines =<< trim END
        set term=xterm ttymouse=xterm2
!       au FocusLost * call setline(1, 'I am lost') | set nomod
!       au FocusGained * call setline(1, 'I am back') | set nomod
        " FIXME: sometimes this job hangs, exit after a couple of seconds
        call timer_start(2000, {id -> execute('qall')})
    END
***************
*** 1152,1157 ****
--- 1152,1165 ----
    call TermWait(buf)
    call VerifyScreenDump(buf, 'Test_terminal_focus_2', {})
  
+   " check that a command line being edited is redrawn in place
+   call term_sendkeys(buf, ":" .. repeat('x', 80))
+   call TermWait(buf)
+   call feedkeys("\<Esc>[O", "Lx!")
+   call TermWait(buf)
+   call VerifyScreenDump(buf, 'Test_terminal_focus_3', {})
+   call term_sendkeys(buf, "\<Esc>")
+ 
    call StopVimInTerminal(buf)
    call delete('XtermFocus')
    let &term = save_term
*** ../vim-8.2.3762/src/testdir/dumps/Test_terminal_focus_1.dump        
2021-12-08 22:13:13.105328552 +0000
--- src/testdir/dumps/Test_terminal_focus_1.dump        2021-12-09 
10:25:12.701352475 +0000
***************
*** 1,6 ****
! > +0&#ffffff0@74
  |~+0#4040ff13&| @73
  |~| @73
  |~| @73
  |~| @73
! |I+0#0000000&| |a|m| |l|o|s|t| @65
--- 1,6 ----
! >I+0&#ffffff0| |a|m| |l|o|s|t| @65
  |~+0#4040ff13&| @73
  |~| @73
  |~| @73
  |~| @73
! | +0#0000000&@56|0|,|0|-|1| @8|A|l@1| 
*** ../vim-8.2.3762/src/testdir/dumps/Test_terminal_focus_2.dump        
2021-12-08 22:13:13.105328552 +0000
--- src/testdir/dumps/Test_terminal_focus_2.dump        2021-12-09 
10:27:14.341782689 +0000
***************
*** 1,6 ****
! > +0&#ffffff0@74
  |~+0#4040ff13&| @73
  |~| @73
  |~| @73
  |~| @73
! |I+0#0000000&| |a|m| |b|a|c|k| @65
--- 1,6 ----
! >I+0&#ffffff0| |a|m| |b|a|c|k| @65
  |~+0#4040ff13&| @73
  |~| @73
  |~| @73
  |~| @73
! | +0#0000000&@56|0|,|0|-|1| @8|A|l@1| 
*** ../vim-8.2.3762/src/testdir/dumps/Test_terminal_focus_3.dump        
2021-12-09 10:49:14.618882724 +0000
--- src/testdir/dumps/Test_terminal_focus_3.dump        2021-12-09 
10:31:09.658344717 +0000
***************
*** 0 ****
--- 1,6 ----
+ |~+0#4040ff13#ffffff0| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |:+0#0000000&|x@73
+ @6> @68
*** ../vim-8.2.3762/src/version.c       2021-12-09 09:26:58.499426044 +0000
--- src/version.c       2021-12-09 10:03:23.945233402 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3763,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
12. You turn off your Wifi and get this awful empty feeling, like you just
    pulled the plug on a loved one.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211209105137.419541C0B28%40moolenaar.net.

Raspunde prin e-mail lui