]> granicus.if.org Git - vim/commitdiff
patch 8.2.1488: text does not scroll when inserting above first line v8.2.1488
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Aug 2020 18:19:48 +0000 (20:19 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Aug 2020 18:19:48 +0000 (20:19 +0200)
Problem:    Text does not scroll when inserting above first line.
Solution:   Adjust off-by-one error. (Ken Takata, closes #6739)

src/drawscreen.c
src/testdir/dumps/Test_display_scroll_at_topline.dump [new file with mode: 0644]
src/testdir/test_display.vim
src/version.c

index 7afcf0975427c0796eb7d9e84b7cfab9be66c44b..0cddff39a49ac66f0c61898213c4eedbe07ab39d 100644 (file)
@@ -1662,7 +1662,7 @@ win_update(win_T *wp)
        if (mod_top != 0
                && wp->w_topline == mod_top
                && (!wp->w_lines[0].wl_valid
-                   || wp->w_topline == wp->w_lines[0].wl_lnum))
+                   || wp->w_topline <= wp->w_lines[0].wl_lnum))
        {
            // w_topline is the first changed line and window is not scrolled,
            // the scrolling from changed lines will be done further down.
diff --git a/src/testdir/dumps/Test_display_scroll_at_topline.dump b/src/testdir/dumps/Test_display_scroll_at_topline.dump
new file mode 100644 (file)
index 0000000..9c843c0
--- /dev/null
@@ -0,0 +1,4 @@
+> +0&#ffffff0@19
+|a@19
+@1| @18
+|~+0#4040ff13&| @18
index 97b0a9e88924be388ad105e65aa0e1344c932d91..49d0d8c04602d821d2b8fc39201a01eb6b0c6714 100644 (file)
@@ -245,4 +245,16 @@ func Test_visual_block_scroll()
   call delete(filename)
 endfunc
 
+func Test_display_scroll_at_topline()
+  CheckScreendump
+
+  let buf = RunVimInTerminal('', #{cols: 20})
+  call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\<CR>")
+  call term_wait(buf)
+  call term_sendkeys(buf, "O\<Esc>")
+  call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 51b87ce2597018437be289dfa0ada7e043ce8ff7..d6d197303a148f60bd59536014769116a8bb710f 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1488,
 /**/
     1487,
 /**/