Patch 8.2.1990
Problem:    Cursor position wrong in terminal popup with finished job.
Solution:   Only add the top and left offset when not done already.
            (closes #7298)
Files:      src/popupwin.c, src/structs.h, src/drawline.c, src/move.c,
            src/terminal.c, src/testdir/dumps/Test_terminal_popup_m1.dump


*** ../vim-8.2.1989/src/popupwin.c      2020-11-05 19:34:37.774638811 +0100
--- src/popupwin.c      2020-11-15 20:05:59.755275963 +0100
***************
*** 3743,3755 ****
  
        wp->w_winrow -= top_off;
        wp->w_wincol -= left_extra;
!       // cursor position matters in terminal in job mode
! #ifdef FEAT_TERMINAL
!       if (wp != curwin || !term_in_normal_mode())
! #endif
        {
-           wp->w_wrow += top_off;
            wp->w_wcol += left_extra;
        }
  
        total_width = popup_width(wp);
--- 3743,3759 ----
  
        wp->w_winrow -= top_off;
        wp->w_wincol -= left_extra;
! 
!       // Add offset for border and padding if not done already.
!       if ((wp->w_flags & WFLAG_WCOL_OFF_ADDED) == 0)
        {
            wp->w_wcol += left_extra;
+           wp->w_flags |= WFLAG_WCOL_OFF_ADDED;
+       }
+       if ((wp->w_flags & WFLAG_WROW_OFF_ADDED) == 0)
+       {
+           wp->w_wrow += top_off;
+           wp->w_flags |= WFLAG_WROW_OFF_ADDED;
        }
  
        total_width = popup_width(wp);
*** ../vim-8.2.1989/src/structs.h       2020-11-07 16:58:55.894354883 +0100
--- src/structs.h       2020-11-15 19:43:05.658089258 +0100
***************
*** 3348,3353 ****
--- 3348,3357 ----
                                    // top of the window
      char      w_topline_was_set;  // flag set to TRUE when topline is set,
                                    // e.g. by winrestview()
+ 
+     linenr_T  w_botline;          // number of the line below the bottom of
+                                   // the window
+ 
  #ifdef FEAT_DIFF
      int               w_topfill;          // number of filler lines above 
w_topline
      int               w_old_topfill;      // w_topfill at last redraw
***************
*** 3361,3366 ****
--- 3365,3376 ----
      colnr_T   w_skipcol;          // starting column when a single line
                                    // doesn't fit in the window
  
+     int               w_empty_rows;       // number of ~ rows in window
+ #ifdef FEAT_DIFF
+     int               w_filler_rows;      // number of filler rows at the end 
of the
+                                   // window
+ #endif
+ 
      /*
       * Layout of the window in the screen.
       * May need to add "msg_scrolled" to "w_winrow" in rare situations.
***************
*** 3368,3378 ****
--- 3378,3391 ----
      int               w_winrow;           // first row of window in screen
      int               w_height;           // number of rows in window, 
excluding
                                    // status/command/winbar line(s)
+ 
      int               w_status_height;    // number of status lines (0 or 1)
      int               w_wincol;           // Leftmost column of window in 
screen.
      int               w_width;            // Width of window, excluding 
separation.
      int               w_vsep_width;       // Number of separator columns (0 
or 1).
+ 
      pos_save_T        w_save_cursor;      // backup of cursor pos and topline
+ 
  #ifdef FEAT_PROP_POPUP
      int               w_popup_flags;      // POPF_ values
      int               w_popup_handled;    // POPUP_HANDLE[0-9] flags
***************
*** 3433,3440 ****
  # if defined(FEAT_TIMERS)
      timer_T   *w_popup_timer;     // timer for closing popup window
  # endif
- #endif
  
  
      /*
       * === start of cached values ====
--- 3446,3459 ----
  # if defined(FEAT_TIMERS)
      timer_T   *w_popup_timer;     // timer for closing popup window
  # endif
  
+     int               w_flags;            // WFLAG_ flags
+ 
+ # define WFLAG_WCOL_OFF_ADDED 1   // popup border and padding were added to
+                                   // w_wcol
+ # define WFLAG_WROW_OFF_ADDED 2   // popup border and padding were added to
+                                   // w_wrow
+ #endif
  
      /*
       * === start of cached values ====
***************
*** 3475,3488 ****
       */
      int               w_wrow, w_wcol;     // cursor position in window
  
-     linenr_T  w_botline;          // number of the line below the bottom of
-                                   // the window
-     int               w_empty_rows;       // number of ~ rows in window
- #ifdef FEAT_DIFF
-     int               w_filler_rows;      // number of filler rows at the end 
of the
-                                   // window
- #endif
- 
      /*
       * Info about the lines currently in the window is remembered to avoid
       * recomputing it every time.  The allocated size of w_lines[] is Rows.
--- 3494,3499 ----
*** ../vim-8.2.1989/src/drawline.c      2020-11-05 19:06:55.739582600 +0100
--- src/drawline.c      2020-11-15 19:56:23.948311232 +0100
***************
*** 2455,2460 ****
--- 2455,2461 ----
            wp->w_wrow = row;
            did_wcol = TRUE;
            curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
+           curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
        }
  #endif
  
*** ../vim-8.2.1989/src/move.c  2020-11-01 21:56:36.613059948 +0100
--- src/move.c  2020-11-15 20:08:30.935015648 +0100
***************
*** 868,873 ****
--- 868,874 ----
        curwin->w_wcol = col;
  
        curwin->w_valid |= VALID_WCOL;
+       curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
      }
  }
  
***************
*** 1180,1186 ****
--- 1181,1190 ----
      {
        curwin->w_wrow += popup_top_extra(curwin);
        curwin->w_wcol += popup_left_extra(curwin);
+       curwin->w_flags |= WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED;
      }
+     else
+       curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED);
  #endif
  
      // now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise
*** ../vim-8.2.1989/src/terminal.c      2020-11-14 20:21:51.361723986 +0100
--- src/terminal.c      2020-11-15 20:09:22.782920836 +0100
***************
*** 2208,2214 ****
--- 2208,2217 ----
      {
        wp->w_wrow += popup_top_extra(curwin);
        wp->w_wcol += popup_left_extra(curwin);
+       wp->w_flags |= WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED;
      }
+     else
+       wp->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
  #endif
      wp->w_valid |= (VALID_WCOL|VALID_WROW);
  }
*** ../vim-8.2.1989/src/testdir/dumps/Test_terminal_popup_m1.dump       
2020-03-15 14:19:19.394376259 +0100
--- src/testdir/dumps/Test_terminal_popup_m1.dump       2020-11-15 
17:48:42.077595712 +0100
***************
*** 5,12 ****
  |4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26
  |5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| 
+0#0000000#ffffff0@26
  |6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26
! |7| @24|║+0#0000001#ffd7ff255|i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| 
+0#0000000#ffffff0@26
! |8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&> @18|║+0#0000001&| 
+0#0000000#ffffff0@26
  |9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| 
+0#0000000#ffffff0@26
  |1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26
  |1@1| @72
--- 5,12 ----
  |4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26
  |5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| 
+0#0000000#ffffff0@26
  |6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26
! |7| @24|║+0#0000001#ffd7ff255>i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| 
+0#0000000#ffffff0@26
! |8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| 
+0#0000000#ffffff0@26
  |9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| 
+0#0000000#ffffff0@26
  |1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26
  |1@1| @72
*** ../vim-8.2.1989/src/version.c       2020-11-15 14:09:34.100728303 +0100
--- src/version.c       2020-11-15 20:31:37.512056593 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1990,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
249. You've forgotten what the outside looks like.

 /// 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202011151933.0AFJXQg6959891%40masaka.moolenaar.net.

Raspunde prin e-mail lui