]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2198: ml_get error when resizing window and using text property v8.2.2198
authorBram Moolenaar <Bram@vim.org>
Wed, 23 Dec 2020 13:36:00 +0000 (14:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 23 Dec 2020 13:36:00 +0000 (14:36 +0100)
Problem:    ml_get error when resizing window and using text property.
Solution:   Validate botline of the right window. (closes #7528)

src/move.c
src/proto/move.pro
src/testdir/test_textprop.vim
src/textprop.c
src/version.c

index 69091fd3da4f25c0a4ddd4cc903ea6bb8bacc6fc..aa90b528aafdcc901ca858de8604ac8fd0e4d54f 100644 (file)
@@ -541,6 +541,8 @@ set_topline(win_T *wp, linenr_T lnum)
 #endif
     // Approximate the value of w_botline
     wp->w_botline += lnum - wp->w_topline;
+    if (wp->w_botline > wp->w_buffer->b_ml.ml_line_count + 1)
+       wp->w_botline = wp->w_buffer->b_ml.ml_line_count + 1;
     wp->w_topline = lnum;
     wp->w_topline_was_set = TRUE;
 #ifdef FEAT_DIFF
@@ -595,8 +597,17 @@ changed_line_abv_curs_win(win_T *wp)
     void
 validate_botline(void)
 {
-    if (!(curwin->w_valid & VALID_BOTLINE))
-       comp_botline(curwin);
+    validate_botline_win(curwin);
+}
+
+/*
+ * Make sure the value of wp->w_botline is valid.
+ */
+    void
+validate_botline_win(win_T *wp)
+{
+    if (!(wp->w_valid & VALID_BOTLINE))
+       comp_botline(wp);
 }
 
 /*
index 8efecb9f20486e9c4beba376584b0ffc81dcb5cc..d78623acc5c17f0a09c028837c033759227452f9 100644 (file)
@@ -13,6 +13,7 @@ void changed_cline_bef_curs_win(win_T *wp);
 void changed_line_abv_curs(void);
 void changed_line_abv_curs_win(win_T *wp);
 void validate_botline(void);
+void validate_botline_win(win_T *wp);
 void invalidate_botline(void);
 void invalidate_botline_win(win_T *wp);
 void approximate_botline_win(win_T *wp);
index 072056759072657ec6d904848973e3d61d2eebe9..a4033fa48b3be4765fe5b94a14bfa6dc6ee9eaf4 100644 (file)
@@ -1358,4 +1358,24 @@ func Test_prop_block_insert()
   call prop_type_delete('test')
 endfunc
 
+" this was causing an ml_get error because w_botline was wrong
+func Test_prop_one_line_window()
+  enew
+  call range(2)->setline(1)
+  call prop_type_add('testprop', {})
+  call prop_add(1, 1, {'type': 'testprop'})
+  call popup_create('popup', {'textprop': 'testprop'})
+  $
+  new
+  wincmd _
+  call feedkeys("\r", 'xt')
+  redraw
+
+  call popup_clear()
+  call prop_type_delete('testprop')
+  close
+  bwipe!
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 5a18f6c734e07c41de818990c8a01302a22b1e23..b6cae70a85d80bd251c87aa68ead90d2cd5fea1d 100644 (file)
@@ -419,7 +419,7 @@ find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
     int                        i;
 
     // w_botline may not have been updated yet.
-    validate_botline();
+    validate_botline_win(wp);
     for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum)
     {
        count = get_text_props(wp->w_buffer, lnum, &props, FALSE);
index 493194f953f87db1a29dd45bbc7ceeea0d88aeb5..af89c9e305d6fc0d28374ee2c2b944c9d69240e5 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2198,
 /**/
     2197,
 /**/