]> granicus.if.org Git - vim/commitdiff
patch 9.0.0416: ml_get error when appending lines in popup window v9.0.0416
authorBram Moolenaar <Bram@vim.org>
Thu, 8 Sep 2022 12:43:10 +0000 (13:43 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 8 Sep 2022 12:43:10 +0000 (13:43 +0100)
Problem:    ml_get error when appending lines in popup window.
Solution:   Only update w_topline when w_buffer matches curbuf.
            (closes #11074)

src/evalbuffer.c
src/testdir/dumps/Test_term_popup_bufline.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 15ac58021af01f0c374403ba2916f4f9aab18202..3527737b9293d6b49dedaa601a8a407e9af15d1f 100644 (file)
@@ -254,7 +254,11 @@ set_buffer_lines(
                    && wp->w_cursor.lnum > append_lnum)
                wp->w_cursor.lnum += added;
        check_cursor_col();
-       update_topline();
+
+       // Only update the window view if w_buffer matches curbuf, otherwise
+       // the computations will be wrong.
+       if (curwin->w_buffer == curbuf)
+           update_topline();
     }
 
 done:
diff --git a/src/testdir/dumps/Test_term_popup_bufline.dump b/src/testdir/dumps/Test_term_popup_bufline.dump
new file mode 100644 (file)
index 0000000..50ba4a6
--- /dev/null
@@ -0,0 +1,15 @@
+|1+0&#ffffff0| @73
+|2| @73
+|3| @73
+|4| @73
+>5| @35|0+0#0000001#ffd7ff255| +0#0000000#ffffff0@36
+|~+0#4040ff13&| @35|1+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@36
+|!+2#ffffff16#00e0003|s|e|q| |1| |5| |[|f|i|n|i|s|h|e|d|]| @17|2+0#0000001#ffd7ff255| +2#ffffff16#00e0003@18|5|,|1| @11|A|l@1
+| +0#0000000#ffffff0@36|3+0#0000001#ffd7ff255| +0#0000000#ffffff0@36
+|~+0#4040ff13&| @35|4+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@36
+|~| @35| +0#0000001#ffd7ff255| +0#4040ff13#ffffff0@36
+|~| @73
+|~| @73
+|~| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+| +0&&@74
index 7cdd12865f1a416ae1623563637a2178abb6ec02..5230fa3e1d8b4dffef1c26c9e0204a20552b8bb9 100644 (file)
@@ -4174,5 +4174,28 @@ func Test_bufdel_skips_popupwin_buffer()
     call popup_close(id)
 endfunc
 
+func Test_term_popup_bufline()
+  " very specific situation where a non-existing buffer line is used, leading
+  " to an ml_get error
+  CheckScreendump
+
+  let lines =<< trim END
+      vim9script
+      &scrolloff = 5
+      term_start('seq 1 5', {term_finish: 'open'})
+      timer_start(50, (_) => {
+         set cpoptions&vim
+         var buf = popup_create([], {})->winbufnr()
+         appendbufline(buf, 0, range(5))
+      })
+  END
+  call writefile(lines, 'XtestTermPopup', 'D')
+  let buf = RunVimInTerminal('-S XtestTermPopup', #{rows: 15})
+  call VerifyScreenDump(buf, 'Test_term_popup_bufline', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
 
 " vim: shiftwidth=2 sts=2
index 28f7520f904a43f9d978c120e959536c26d01e8c..86924eddf05812e764202aab6ab7663e98752fce 100644 (file)
@@ -703,6 +703,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    416,
 /**/
     415,
 /**/