diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index ff62531dc7..bcf245ef93 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -57,7 +57,6 @@ #include "nvim/option_defs.h" #include "nvim/option_vars.h" #include "nvim/os/fs.h" -#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/plines.h" #include "nvim/pos_defs.h" @@ -7102,8 +7101,9 @@ void reset_lnums(void) { FOR_ALL_TAB_WINDOWS(tp, wp) { if (wp->w_buffer == curbuf) { - // Restore the value if the autocommand didn't change it and it was - // set. + // Restore the value if the autocommand didn't change it and it was set. + // Note: This triggers e.g. on BufReadPre, when the buffer is not yet + // loaded, so cannot validate the buffer line if (equalpos(wp->w_save_cursor.w_cursor_corr, wp->w_cursor) && wp->w_save_cursor.w_cursor_save.lnum != 0) { wp->w_cursor = wp->w_save_cursor.w_cursor_save; @@ -7112,6 +7112,9 @@ void reset_lnums(void) && wp->w_save_cursor.w_topline_save != 0) { wp->w_topline = wp->w_save_cursor.w_topline_save; } + if (wp->w_save_cursor.w_topline_save > wp->w_buffer->b_ml.ml_line_count) { + wp->w_valid &= ~VALID_TOPLINE; + } } } } |