Skip to content

Commit

Permalink
Fix scroll at topline
Browse files Browse the repository at this point in the history
After 8.2.1345, this is not shown correctly.

1. Open a new buffer.
2. `:20vsp`
   Set the width of the window to 20.
3. `:call setline(1, repeat('a', 21))`
   Set a line longer than the window width.
4. Type `O` to insert a new line.

The line should scroll down, but it doesn't.
This PR fixes it.
  • Loading branch information
k-takata committed Aug 19, 2020
1 parent 9b02d64 commit 43605d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/drawscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/testdir/dumps/Test_display_scroll_at_topline.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
> +0&#ffffff0@19
|a@19
@1| @18
|~+0#4040ff13&| @18
10 changes: 10 additions & 0 deletions src/testdir/test_display.vim
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,14 @@ 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)) | normal O\<CR>")

call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4})
call StopVimInTerminal(buf)
endfunc

" vim: shiftwidth=2 sts=2 expandtab

0 comments on commit 43605d1

Please sign in to comment.