Skip to content

Commit f8992d4

Browse files
committed
patch 8.2.1345: Redraw error when using visual block and scroll
Problem: Redraw error when using visual block and scroll. Solution: Add check for w_topline. ( closes #6597)
1 parent 2c79e9d commit f8992d4

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

src/drawscreen.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,10 +1659,13 @@ win_update(win_T *wp)
16591659
#endif
16601660
)
16611661
{
1662-
if (mod_top != 0 && wp->w_topline == mod_top)
1662+
if (mod_top != 0
1663+
&& wp->w_topline == mod_top
1664+
&& (!wp->w_lines[0].wl_valid
1665+
|| wp->w_topline == wp->w_lines[0].wl_lnum))
16631666
{
1664-
// w_topline is the first changed line, the scrolling will be done
1665-
// further down.
1667+
// w_topline is the first changed line and window is not scrolled,
1668+
// the scrolling from changed lines will be done further down.
16661669
}
16671670
else if (wp->w_lines[0].wl_valid
16681671
&& (wp->w_topline < wp->w_lines[0].wl_lnum
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
|{+0&#e0e0e08| | +0&#ffffff0@72
2+
|}+0&#e0e0e08| | +0&#ffffff0@72
3+
|{+0&#e0e0e08| | +0&#ffffff0@72
4+
|f+0&#e0e0e08| | +0&#ffffff0@72
5+
>g| +0&#e0e0e08| +0&#ffffff0@72
6+
|}| @73
7+
|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@29|7| @8|1@1|,|1| @9|B|o|t|

src/testdir/test_display.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,26 @@ func Test_unprintable_fileformats()
220220
call delete('Xmac.txt')
221221
call delete(filename)
222222
endfunc
223+
224+
" Test for scrolling that modifies buffer during visual block
225+
func Test_visual_block_scroll()
226+
CheckScreendump
227+
228+
let lines =<< trim END
229+
source $VIMRUNTIME/plugin/matchparen.vim
230+
set scrolloff=1
231+
call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'])
232+
call cursor(5, 1)
233+
END
234+
235+
let filename = 'Xvisualblockmodifiedscroll'
236+
call writefile(lines, filename)
237+
238+
let buf = RunVimInTerminal('-S '.filename, #{rows: 7})
239+
call term_sendkeys(buf, "V\<C-D>\<C-D>")
240+
241+
call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {})
242+
243+
call StopVimInTerminal(buf)
244+
call delete(filename)
245+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1345,
757759
/**/
758760
1344,
759761
/**/

0 commit comments

Comments
 (0)