@@ -6770,34 +6770,55 @@ only_one_window(void)
67706770}
67716771
67726772/*
6773- * Correct the cursor line number in other windows. Used after changing the
6774- * current buffer, and before applying autocommands.
6775- * When "do_curwin" is TRUE, also check current window.
6773+ * Implementation of check_lnums() and check_lnums_nested().
67766774 */
6777- void
6778- check_lnums (int do_curwin )
6775+ static void
6776+ check_lnums_both (int do_curwin , int nested )
67796777{
67806778 win_T * wp ;
67816779 tabpage_T * tp ;
67826780
67836781 FOR_ALL_TAB_WINDOWS (tp , wp )
67846782 if ((do_curwin || wp != curwin ) && wp -> w_buffer == curbuf )
67856783 {
6786- // save the original cursor position and topline
6787- wp -> w_save_cursor .w_cursor_save = wp -> w_cursor ;
6788- wp -> w_save_cursor .w_topline_save = wp -> w_topline ;
6784+ if (!nested )
6785+ {
6786+ // save the original cursor position and topline
6787+ wp -> w_save_cursor .w_cursor_save = wp -> w_cursor ;
6788+ wp -> w_save_cursor .w_topline_save = wp -> w_topline ;
6789+ }
67896790
67906791 if (wp -> w_cursor .lnum > curbuf -> b_ml .ml_line_count )
67916792 wp -> w_cursor .lnum = curbuf -> b_ml .ml_line_count ;
67926793 if (wp -> w_topline > curbuf -> b_ml .ml_line_count )
67936794 wp -> w_topline = curbuf -> b_ml .ml_line_count ;
67946795
6795- // save the corrected cursor position and topline
6796+ // save the ( corrected) cursor position and topline
67966797 wp -> w_save_cursor .w_cursor_corr = wp -> w_cursor ;
67976798 wp -> w_save_cursor .w_topline_corr = wp -> w_topline ;
67986799 }
67996800}
68006801
6802+ /*
6803+ * Correct the cursor line number in other windows. Used after changing the
6804+ * current buffer, and before applying autocommands.
6805+ * When "do_curwin" is TRUE, also check current window.
6806+ */
6807+ void
6808+ check_lnums (int do_curwin )
6809+ {
6810+ check_lnums_both (do_curwin , FALSE);
6811+ }
6812+
6813+ /*
6814+ * Like check_lnums() but for when check_lnums() was already called.
6815+ */
6816+ void
6817+ check_lnums_nested (int do_curwin )
6818+ {
6819+ check_lnums_both (do_curwin , TRUE);
6820+ }
6821+
68016822/*
68026823 * Reset cursor and topline to its stored values from check_lnums().
68036824 * check_lnums() must have been called first!
0 commit comments