summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-27 15:23:35 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-27 15:23:35 +0100
commit3d6ee8bda0550a01346f5992bbce09c0eb6d7569 (patch)
tree1bc029d00d152ae32522ed705cc5da8cd6c190d4 /src/window.c
parent7abd1c6d8e777bde1700633bafc1a40be9e9c1aa (diff)
downloadvim-git-3d6ee8bda0550a01346f5992bbce09c0eb6d7569.tar.gz
patch 9.0.0094: cursor restored unexpected with nested autocommandv9.0.0094
Problem: Cursor restored unexpected with nested autocommand. Solution: Do not restore the cursor when it was moved intentionally. (closes #10780)
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/window.c b/src/window.c
index 83cc24e23..6be736945 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6781,6 +6781,8 @@ check_lnums_both(int do_curwin, int nested)
FOR_ALL_TAB_WINDOWS(tp, wp)
if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf)
{
+ int need_adjust;
+
if (!nested)
{
// save the original cursor position and topline
@@ -6788,14 +6790,19 @@ check_lnums_both(int do_curwin, int nested)
wp->w_save_cursor.w_topline_save = wp->w_topline;
}
- if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count)
+ need_adjust = wp->w_cursor.lnum > curbuf->b_ml.ml_line_count;
+ if (need_adjust)
wp->w_cursor.lnum = curbuf->b_ml.ml_line_count;
- if (wp->w_topline > curbuf->b_ml.ml_line_count)
- wp->w_topline = curbuf->b_ml.ml_line_count;
+ if (need_adjust || !nested)
+ // save the (corrected) cursor position
+ wp->w_save_cursor.w_cursor_corr = wp->w_cursor;
- // save the (corrected) cursor position and topline
- wp->w_save_cursor.w_cursor_corr = wp->w_cursor;
- wp->w_save_cursor.w_topline_corr = wp->w_topline;
+ need_adjust = wp->w_topline > curbuf->b_ml.ml_line_count;
+ if (need_adjust)
+ wp->w_topline = curbuf->b_ml.ml_line_count;
+ if (need_adjust || !nested)
+ // save the (corrected) topline
+ wp->w_save_cursor.w_topline_corr = wp->w_topline;
}
}