summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_normal.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_normal.vim')
-rw-r--r--src/testdir/test_normal.vim93
1 files changed, 82 insertions, 11 deletions
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index b180637..4b7e5e6 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -130,7 +130,7 @@ func Test_normal01_keymodel()
call assert_equal([0, 1, 1, 0], getpos("'<"))
call assert_equal([0, 3, 1, 0], getpos("'>"))
call feedkeys("Gz\<CR>8|\<S-PageUp>y", 'xt')
- call assert_equal([0, 2, 1, 0], getpos("'<"))
+ call assert_equal([0, 3, 1, 0], getpos("'<"))
call assert_equal([0, 3, 8, 0], getpos("'>"))
" Test for <S-C-Home> and <S-C-End>
call cursor(2, 12)
@@ -912,12 +912,10 @@ func Test_normal14_page()
set scrolloff=0
100
exe "norm! $\<c-b>"
- call assert_equal('92', getline('.'))
call assert_equal([0, 92, 1, 0, 1], getcurpos())
100
set nostartofline
exe "norm! $\<c-b>"
- call assert_equal('92', getline('.'))
call assert_equal([0, 92, 2, 0, v:maxcol], getcurpos())
" cleanup
set startofline
@@ -1284,7 +1282,7 @@ func Test_vert_scroll_cmds()
exe "normal \<C-U>"
call assert_equal(36, line('.'))
exe "normal \<C-U>"
- call assert_equal(10, line('.'))
+ call assert_equal(1, line('.'))
exe "normal \<C-U>"
call assert_equal(1, line('.'))
set scroll&
@@ -3815,8 +3813,8 @@ func Test_normal_vert_scroll_longline()
call assert_equal(11, line('.'))
call assert_equal(1, winline())
exe "normal \<C-B>"
- call assert_equal(10, line('.'))
- call assert_equal(3, winline())
+ call assert_equal(11, line('.'))
+ call assert_equal(5, winline())
exe "normal \<C-B>\<C-B>"
call assert_equal(5, line('.'))
call assert_equal(5, winline())
@@ -4174,12 +4172,8 @@ endfunc
" Test for { and } paragraph movements in a single line
func Test_brace_single_line()
- let text =<< trim [DATA]
- foobar one two three
- [DATA]
-
new
- call setline(1, text)
+ call setline(1, ['foobar one two three'])
1
norm! 0}
@@ -4189,4 +4183,81 @@ func Test_brace_single_line()
bw!
endfunc
+" Test for Ctrl-B/Ctrl-U in buffer with a single line
+func Test_single_line_scroll()
+ CheckFeature textprop
+
+ new
+ call setline(1, ['foobar one two three'])
+ let vt = 'virt_above'
+ call prop_type_add(vt, {'highlight': 'IncSearch'})
+ call prop_add(1, 0, {'type': vt, 'text': '---', 'text_align': 'above'})
+ call cursor(1, 1)
+
+ " Ctrl-B/Ctrl-U scroll up with hidden "above" virtual text.
+ set smoothscroll
+ exe "normal \<C-E>"
+ call assert_notequal(0, winsaveview().skipcol)
+ exe "normal \<C-B>"
+ call assert_equal(0, winsaveview().skipcol)
+ exe "normal \<C-E>"
+ call assert_notequal(0, winsaveview().skipcol)
+ exe "normal \<C-U>"
+ call assert_equal(0, winsaveview().skipcol)
+
+ set smoothscroll&
+ bw!
+ call prop_type_delete(vt)
+endfunc
+
+" Test for zb in buffer with a single line and filler lines
+func Test_single_line_filler_zb()
+ call setline(1, ['', 'foobar one two three'])
+ diffthis
+ new
+ call setline(1, ['foobar one two three'])
+ diffthis
+
+ " zb scrolls to reveal filler lines at the start of the buffer.
+ exe "normal \<C-E>zb"
+ call assert_equal(1, winsaveview().topfill)
+
+ bw!
+endfunc
+
+" Test for Ctrl-U not getting stuck at end of buffer with 'scrolloff'.
+func Test_halfpage_scrolloff_eob()
+ set scrolloff=5
+
+ call setline(1, range(1, 100))
+ exe "norm! Gzz\<C-U>zz"
+ call assert_notequal(100, line('.'))
+
+ set scrolloff&
+ bwipe!
+endfunc
+
+" Test for Ctrl-U/D moving the cursor at the buffer boundaries.
+func Test_halfpage_cursor_startend()
+ call setline(1, range(1, 100))
+ exe "norm! jztj\<C-U>"
+ call assert_equal(1, line('.'))
+ exe "norm! G\<C-Y>k\<C-D>"
+ call assert_equal(100, line('.'))
+ bwipe!
+endfunc
+
+" Test for Ctrl-F/B moving the cursor to the window boundaries.
+func Test_page_cursor_topbot()
+ 10new
+ call setline(1, range(1, 100))
+ exe "norm! gg2\<C-F>"
+ call assert_equal(17, line('.'))
+ exe "norm! \<C-B>"
+ call assert_equal(18, line('.'))
+ exe "norm! \<C-B>\<C-F>"
+ call assert_equal(9, line('.'))
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable