blob: f034d3a230a4a92fbb4a85425e549c2c5d6d5899 [file] [log] [blame]
Bram Moolenaarf6196f42022-10-02 21:29:55 +01001" Test for reset 'scroll' and 'smoothscroll'
2
3source check.vim
4source screendump.vim
Bram Moolenaaraf2d20c2017-10-29 15:26:57 +01005
6func Test_reset_scroll()
7 let scr = &l:scroll
8
9 setlocal scroll=1
10 setlocal scroll&
11 call assert_equal(scr, &l:scroll)
12
13 setlocal scroll=1
14 setlocal scroll=0
15 call assert_equal(scr, &l:scroll)
16
17 try
18 execute 'setlocal scroll=' . (winheight(0) + 1)
19 " not reached
20 call assert_false(1)
21 catch
22 call assert_exception('E49:')
23 endtry
24
25 split
26
27 let scr = &l:scroll
28
29 setlocal scroll=1
30 setlocal scroll&
31 call assert_equal(scr, &l:scroll)
32
33 setlocal scroll=1
34 setlocal scroll=0
35 call assert_equal(scr, &l:scroll)
36
37 quit!
38endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020039
Bram Moolenaarf6196f42022-10-02 21:29:55 +010040func Test_smoothscroll_CtrlE_CtrlY()
41 CheckScreendump
42
43 let lines =<< trim END
44 vim9script
45 setline(1, [
46 'line one',
47 'word '->repeat(20),
48 'line three',
49 'long word '->repeat(7),
50 'line',
51 'line',
52 'line',
53 ])
54 set smoothscroll
55 :5
56 END
57 call writefile(lines, 'XSmoothScroll', 'D')
58 let buf = RunVimInTerminal('-S XSmoothScroll', #{rows: 12, cols: 40})
59
60 call term_sendkeys(buf, "\<C-E>")
61 call VerifyScreenDump(buf, 'Test_smoothscroll_1', {})
62 call term_sendkeys(buf, "\<C-E>")
63 call VerifyScreenDump(buf, 'Test_smoothscroll_2', {})
64 call term_sendkeys(buf, "\<C-E>")
65 call VerifyScreenDump(buf, 'Test_smoothscroll_3', {})
66 call term_sendkeys(buf, "\<C-E>")
67 call VerifyScreenDump(buf, 'Test_smoothscroll_4', {})
68
69 call term_sendkeys(buf, "\<C-Y>")
70 call VerifyScreenDump(buf, 'Test_smoothscroll_5', {})
71 call term_sendkeys(buf, "\<C-Y>")
72 call VerifyScreenDump(buf, 'Test_smoothscroll_6', {})
73 call term_sendkeys(buf, "\<C-Y>")
74 call VerifyScreenDump(buf, 'Test_smoothscroll_7', {})
75 call term_sendkeys(buf, "\<C-Y>")
76 call VerifyScreenDump(buf, 'Test_smoothscroll_8', {})
77
78 call StopVimInTerminal(buf)
79endfunc
80
81
82
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020083" vim: shiftwidth=2 sts=2 expandtab