summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-04-29 14:26:02 +0100
committerBram Moolenaar <Bram@vim.org>2023-04-29 14:26:02 +0100
commit58806c1553afa2924377f6445ac6ed8cb852f9ca (patch)
tree11c6e8006686892fe9f826334c0d8a9cddfdd02e
parent971cd2b8bc3e3a7faa886162cd7568938c627882 (diff)
patch 9.0.1498: in a terminal window the cursor may jump aroundv9.0.1498
Problem: In a terminal window the cursor may jump around. (Kenny Stauffer) Solution: Do not move the cursor to the position for terminal-normal mode. (closes #12312)
-rw-r--r--src/terminal.c45
-rw-r--r--src/version.c2
2 files changed, 29 insertions, 18 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 71602da928..683b74fa86 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1209,6 +1209,24 @@ term_write_job_output(term_T *term, char_u *msg_arg, size_t len_arg)
}
static void
+position_cursor(win_T *wp, VTermPos *pos)
+{
+ wp->w_wrow = MIN(pos->row, MAX(0, wp->w_height - 1));
+ wp->w_wcol = MIN(pos->col, MAX(0, wp->w_width - 1));
+#ifdef FEAT_PROP_POPUP
+ if (popup_is_popup(wp))
+ {
+ wp->w_wrow += popup_top_extra(wp);
+ wp->w_wcol += popup_left_extra(wp);
+ 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);
+}
+
+ static void
update_cursor(term_T *term, int redraw)
{
if (term->tl_normal_mode)
@@ -1219,7 +1237,16 @@ update_cursor(term_T *term, int redraw)
term->tl_cursor_pos.col);
else
#endif
+ if (!term_job_running(term))
+ // avoid the cursor positioned below the last used line
setcursor();
+ else
+ {
+ // do not use the window cursor position
+ position_cursor(curwin, &curbuf->b_term->tl_cursor_pos);
+ windgoto(W_WINROW(curwin) + curwin->w_wrow,
+ curwin->w_wincol + curwin->w_wcol);
+ }
if (redraw)
{
aco_save_T aco;
@@ -2358,24 +2385,6 @@ send_keys_to_term(term_T *term, int c, int modmask, int typed)
return OK;
}
- static void
-position_cursor(win_T *wp, VTermPos *pos)
-{
- wp->w_wrow = MIN(pos->row, MAX(0, wp->w_height - 1));
- wp->w_wcol = MIN(pos->col, MAX(0, wp->w_width - 1));
-#ifdef FEAT_PROP_POPUP
- if (popup_is_popup(wp))
- {
- wp->w_wrow += popup_top_extra(wp);
- wp->w_wcol += popup_left_extra(wp);
- 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);
-}
-
/*
* Handle CTRL-W "": send register contents to the job.
*/
diff --git a/src/version.c b/src/version.c
index 7bb63e9546..ce94bc80c0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1498,
+/**/
1497,
/**/
1496,