]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0374: wrong botline in BufEnter v9.1.0374
authorJaehwang Jung <tomtomjhj@gmail.com>
Fri, 26 Apr 2024 16:48:48 +0000 (18:48 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 26 Apr 2024 16:48:48 +0000 (18:48 +0200)
Problem:  When :edit an existing buffer, line('w$') may return a
          wrong result.
Solution: Reset w_valid in curwin_init() (Jaehwang Jung)

`do_ecmd()` reinitializes the current window (`curwin_init()`) whose
`w_valid` field may have `VALID_BOTLINE` set. Resetting `w_botline`
without marking it as invalid makes subsequent `validate_botline()`
calls a no-op, thus resulting in wrong `line('w$')` value.

closes: #14642

Signed-off-by: Jaehwang Jung <tomtomjhj@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_autocmd.vim
src/version.c
src/vim.h
src/window.c

index c7d2534a288c8596431fb8c7fc3ca5d9b6978377..6745ecbe47944a825d5575437aea44e8b81145c8 100644 (file)
@@ -4679,4 +4679,16 @@ func Test_SwapExists_set_other_buf_modified()
   bwipe!
 endfunc
 
+func Test_BufEnter_botline()
+  set hidden
+  call writefile(range(10), 'Xxx1', 'D')
+  call writefile(range(20), 'Xxx2', 'D')
+  edit Xxx1
+  edit Xxx2
+  au BufEnter Xxx1 call assert_true(line('w$') > 1)
+  edit Xxx1
+  au! BufEnter Xxx1
+  set hidden&vim
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 11e18ede293b54fafbdd83165b7e89e0cfb8a844..2bd0667899139b02aced565b65a9d936029d06f9 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    374,
 /**/
     373,
 /**/
index 4507674fcde6efb73c2ab9455f0f4ab969120d3c..f359245fa22d77820067a92f0616c32dd3cbf67b 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -656,8 +656,8 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
 #define VALID_VIRTCOL  0x04    // w_virtcol (file col) is valid
 #define VALID_CHEIGHT  0x08    // w_cline_height and w_cline_folded valid
 #define VALID_CROW     0x10    // w_cline_row is valid
-#define VALID_BOTLINE  0x20    // w_botine and w_empty_rows are valid
-#define VALID_BOTLINE_AP 0x40  // w_botine is approximated
+#define VALID_BOTLINE  0x20    // w_botline and w_empty_rows are valid
+#define VALID_BOTLINE_AP 0x40  // w_botline is approximated
 #define VALID_TOPLINE  0x80    // w_topline is valid (for cursor position)
 
 // Values for w_popup_flags.
index 7d78b5f29a7852abd08be865b48b0dd50a864e3e..73229059eabacdde1642dfc76a2fdee6e0dff105 100644 (file)
@@ -2475,6 +2475,7 @@ win_init_empty(win_T *wp)
     wp->w_topfill = 0;
 #endif
     wp->w_botline = 2;
+    wp->w_valid = 0;
 #if defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
     wp->w_s = &wp->w_buffer->b_s;
 #endif