aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-23 17:45:45 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-23 17:50:25 +0800
commit6cee15da7235b6ba9c428ee43346415fe6a64e6c (patch)
treec1ddf3a082b8379a25c2d862a1df8fda227c37e6 /src/nvim/window.c
parent264791925a76412ed9109028d0d694f7847249be (diff)
downloadrneovim-6cee15da7235b6ba9c428ee43346415fe6a64e6c.tar.gz
rneovim-6cee15da7235b6ba9c428ee43346415fe6a64e6c.tar.bz2
rneovim-6cee15da7235b6ba9c428ee43346415fe6a64e6c.zip
vim-patch:9.0.0061: ml_get error with nested autocommand
Problem: ml_get error with nested autocommand. Solution: Also check line numbers for a nested autocommand. (closes vim/vim#10761) https://github.com/vim/vim/commit/5fa9f23a63651a8abdb074b4fc2ec9b1adc6b089
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 97ca45662e..f00d98ca60 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6858,17 +6858,16 @@ bool only_one_window(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
return count <= 1;
}
-/// Correct the cursor line number in other windows. Used after changing the
-/// current buffer, and before applying autocommands.
-///
-/// @param do_curwin when true, also check current window.
-void check_lnums(bool do_curwin)
+/// Implementation of check_lnums() and check_lnums_nested().
+static void check_lnums_both(bool do_curwin, bool nested)
{
FOR_ALL_TAB_WINDOWS(tp, wp) {
if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) {
- // save the original cursor position and topline
- wp->w_save_cursor.w_cursor_save = wp->w_cursor;
- wp->w_save_cursor.w_topline_save = wp->w_topline;
+ if (!nested) {
+ // save the original cursor position and topline
+ wp->w_save_cursor.w_cursor_save = wp->w_cursor;
+ wp->w_save_cursor.w_topline_save = wp->w_topline;
+ }
if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
wp->w_cursor.lnum = curbuf->b_ml.ml_line_count;
@@ -6877,13 +6876,28 @@ void check_lnums(bool do_curwin)
wp->w_topline = curbuf->b_ml.ml_line_count;
}
- // save the corrected cursor position and topline
+ // 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;
}
}
}
+/// Correct the cursor line number in other windows. Used after changing the
+/// current buffer, and before applying autocommands.
+///
+/// @param do_curwin when true, also check current window.
+void check_lnums(bool do_curwin)
+{
+ check_lnums_both(do_curwin, false);
+}
+
+/// Like check_lnums() but for when check_lnums() was already called.
+void check_lnums_nested(bool do_curwin)
+{
+ check_lnums_both(do_curwin, true);
+}
+
/// Reset cursor and topline to its stored values from check_lnums().
/// check_lnums() must have been called first!
void reset_lnums(void)