Skip to content

Commit 6a07644

Browse files
committed
patch 8.2.1990: cursor position wrong in terminal popup with finished job
Problem: Cursor position wrong in terminal popup with finished job. Solution: Only add the top and left offset when not done already. (closes #7298)
1 parent 2dfae04 commit 6a07644

7 files changed

Lines changed: 41 additions & 16 deletions

File tree

src/drawline.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,7 @@ win_line(
24552455
wp->w_wrow = row;
24562456
did_wcol = TRUE;
24572457
curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
2458+
curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
24582459
}
24592460
#endif
24602461

src/move.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ validate_cursor_col(void)
868868
curwin->w_wcol = col;
869869

870870
curwin->w_valid |= VALID_WCOL;
871+
curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
871872
}
872873
}
873874

@@ -1180,7 +1181,10 @@ curs_columns(
11801181
{
11811182
curwin->w_wrow += popup_top_extra(curwin);
11821183
curwin->w_wcol += popup_left_extra(curwin);
1184+
curwin->w_flags |= WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED;
11831185
}
1186+
else
1187+
curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED);
11841188
#endif
11851189

11861190
// now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise

src/popupwin.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,13 +3743,17 @@ update_popups(void (*win_update)(win_T *wp))
37433743

37443744
wp->w_winrow -= top_off;
37453745
wp->w_wincol -= left_extra;
3746-
// cursor position matters in terminal in job mode
3747-
#ifdef FEAT_TERMINAL
3748-
if (wp != curwin || !term_in_normal_mode())
3749-
#endif
3746+
3747+
// Add offset for border and padding if not done already.
3748+
if ((wp->w_flags & WFLAG_WCOL_OFF_ADDED) == 0)
37503749
{
3751-
wp->w_wrow += top_off;
37523750
wp->w_wcol += left_extra;
3751+
wp->w_flags |= WFLAG_WCOL_OFF_ADDED;
3752+
}
3753+
if ((wp->w_flags & WFLAG_WROW_OFF_ADDED) == 0)
3754+
{
3755+
wp->w_wrow += top_off;
3756+
wp->w_flags |= WFLAG_WROW_OFF_ADDED;
37533757
}
37543758

37553759
total_width = popup_width(wp);

src/structs.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,6 +3348,10 @@ struct window_S
33483348
// top of the window
33493349
char w_topline_was_set; // flag set to TRUE when topline is set,
33503350
// e.g. by winrestview()
3351+
3352+
linenr_T w_botline; // number of the line below the bottom of
3353+
// the window
3354+
33513355
#ifdef FEAT_DIFF
33523356
int w_topfill; // number of filler lines above w_topline
33533357
int w_old_topfill; // w_topfill at last redraw
@@ -3361,18 +3365,27 @@ struct window_S
33613365
colnr_T w_skipcol; // starting column when a single line
33623366
// doesn't fit in the window
33633367

3368+
int w_empty_rows; // number of ~ rows in window
3369+
#ifdef FEAT_DIFF
3370+
int w_filler_rows; // number of filler rows at the end of the
3371+
// window
3372+
#endif
3373+
33643374
/*
33653375
* Layout of the window in the screen.
33663376
* May need to add "msg_scrolled" to "w_winrow" in rare situations.
33673377
*/
33683378
int w_winrow; // first row of window in screen
33693379
int w_height; // number of rows in window, excluding
33703380
// status/command/winbar line(s)
3381+
33713382
int w_status_height; // number of status lines (0 or 1)
33723383
int w_wincol; // Leftmost column of window in screen.
33733384
int w_width; // Width of window, excluding separation.
33743385
int w_vsep_width; // Number of separator columns (0 or 1).
3386+
33753387
pos_save_T w_save_cursor; // backup of cursor pos and topline
3388+
33763389
#ifdef FEAT_PROP_POPUP
33773390
int w_popup_flags; // POPF_ values
33783391
int w_popup_handled; // POPUP_HANDLE[0-9] flags
@@ -3433,8 +3446,14 @@ struct window_S
34333446
# if defined(FEAT_TIMERS)
34343447
timer_T *w_popup_timer; // timer for closing popup window
34353448
# endif
3436-
#endif
34373449

3450+
int w_flags; // WFLAG_ flags
3451+
3452+
# define WFLAG_WCOL_OFF_ADDED 1 // popup border and padding were added to
3453+
// w_wcol
3454+
# define WFLAG_WROW_OFF_ADDED 2 // popup border and padding were added to
3455+
// w_wrow
3456+
#endif
34383457

34393458
/*
34403459
* === start of cached values ====
@@ -3475,14 +3494,6 @@ struct window_S
34753494
*/
34763495
int w_wrow, w_wcol; // cursor position in window
34773496

3478-
linenr_T w_botline; // number of the line below the bottom of
3479-
// the window
3480-
int w_empty_rows; // number of ~ rows in window
3481-
#ifdef FEAT_DIFF
3482-
int w_filler_rows; // number of filler rows at the end of the
3483-
// window
3484-
#endif
3485-
34863497
/*
34873498
* Info about the lines currently in the window is remembered to avoid
34883499
* recomputing it every time. The allocated size of w_lines[] is Rows.

src/terminal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,10 @@ position_cursor(win_T *wp, VTermPos *pos, int add_off UNUSED)
22082208
{
22092209
wp->w_wrow += popup_top_extra(curwin);
22102210
wp->w_wcol += popup_left_extra(curwin);
2211+
wp->w_flags |= WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED;
22112212
}
2213+
else
2214+
wp->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
22122215
#endif
22132216
wp->w_valid |= (VALID_WCOL|VALID_WROW);
22142217
}

src/testdir/dumps/Test_terminal_popup_m1.dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
|4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26
66
|5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| +0#0000000#ffffff0@26
77
|6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26
8-
|7| @24|║+0#0000001#ffd7ff255|i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26
9-
|8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&> @18|║+0#0000001&| +0#0000000#ffffff0@26
8+
|7| @24|║+0#0000001#ffd7ff255>i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26
9+
|8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26
1010
|9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26
1111
|1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26
1212
|1@1| @72

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1990,
753755
/**/
754756
1989,
755757
/**/

0 commit comments

Comments
 (0)