summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-15 20:32:58 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-15 20:32:58 +0100
commit6a07644db30cb5f3d0c6dc5eb2c348b6289da553 (patch)
tree809c5c0da918231439589f9e34b23b86c8f0aac6
parent2dfae04f376a58d4c5a801cb652c8eae65900672 (diff)
downloadvim-git-6a07644db30cb5f3d0c6dc5eb2c348b6289da553.tar.gz
patch 8.2.1990: cursor position wrong in terminal popup with finished jobv8.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)
-rw-r--r--src/drawline.c1
-rw-r--r--src/move.c4
-rw-r--r--src/popupwin.c14
-rw-r--r--src/structs.h29
-rw-r--r--src/terminal.c3
-rw-r--r--src/testdir/dumps/Test_terminal_popup_m1.dump4
-rw-r--r--src/version.c2
7 files changed, 41 insertions, 16 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 6b9cbc628..fcca38a2e 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -2455,6 +2455,7 @@ win_line(
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
diff --git a/src/move.c b/src/move.c
index cd0af3e64..0a98f0347 100644
--- a/src/move.c
+++ b/src/move.c
@@ -868,6 +868,7 @@ validate_cursor_col(void)
curwin->w_wcol = col;
curwin->w_valid |= VALID_WCOL;
+ curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
}
}
@@ -1180,7 +1181,10 @@ curs_columns(
{
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
diff --git a/src/popupwin.c b/src/popupwin.c
index ab1b6f6b6..90b107eb5 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -3743,13 +3743,17 @@ update_popups(void (*win_update)(win_T *wp))
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
+
+ // Add offset for border and padding if not done already.
+ if ((wp->w_flags & WFLAG_WCOL_OFF_ADDED) == 0)
{
- wp->w_wrow += top_off;
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);
diff --git a/src/structs.h b/src/structs.h
index 90e76203a..24baa34c5 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3348,6 +3348,10 @@ struct window_S
// 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,6 +3365,12 @@ struct window_S
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,11 +3378,14 @@ struct window_S
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,8 +3446,14 @@ struct window_S
# if defined(FEAT_TIMERS)
timer_T *w_popup_timer; // timer for closing popup window
# endif
-#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,14 +3494,6 @@ struct window_S
*/
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.
diff --git a/src/terminal.c b/src/terminal.c
index 7f38bf75c..6be757950 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -2208,7 +2208,10 @@ position_cursor(win_T *wp, VTermPos *pos, int add_off UNUSED)
{
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);
}
diff --git a/src/testdir/dumps/Test_terminal_popup_m1.dump b/src/testdir/dumps/Test_terminal_popup_m1.dump
index 75432945a..0ab9534da 100644
--- a/src/testdir/dumps/Test_terminal_popup_m1.dump
+++ b/src/testdir/dumps/Test_terminal_popup_m1.dump
@@ -5,8 +5,8 @@
|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
+|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
diff --git a/src/version.c b/src/version.c
index 399007609..5978bdce5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1990,
+/**/
1989,
/**/
1988,