blob: 5dfc69762dd51e1701cd57475b9c62850fb7279a [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 Moolenaar8df97482022-10-03 12:11:13 +010040func Test_CtrlE_CtrlY_stop_at_end()
41 enew
42 call setline(1, ['one', 'two'])
43 set number
44 exe "normal \<C-Y>"
45 call assert_equal([" 1 one "], ScreenLines(1, 10))
46 exe "normal \<C-E>\<C-E>\<C-E>"
47 call assert_equal([" 2 two "], ScreenLines(1, 10))
48
49 bwipe!
50 set nonumber
51endfunc
52
Bram Moolenaarf6196f42022-10-02 21:29:55 +010053func Test_smoothscroll_CtrlE_CtrlY()
54 CheckScreendump
55
56 let lines =<< trim END
57 vim9script
58 setline(1, [
59 'line one',
60 'word '->repeat(20),
61 'line three',
62 'long word '->repeat(7),
63 'line',
64 'line',
65 'line',
66 ])
67 set smoothscroll
68 :5
69 END
70 call writefile(lines, 'XSmoothScroll', 'D')
71 let buf = RunVimInTerminal('-S XSmoothScroll', #{rows: 12, cols: 40})
72
73 call term_sendkeys(buf, "\<C-E>")
74 call VerifyScreenDump(buf, 'Test_smoothscroll_1', {})
75 call term_sendkeys(buf, "\<C-E>")
76 call VerifyScreenDump(buf, 'Test_smoothscroll_2', {})
77 call term_sendkeys(buf, "\<C-E>")
78 call VerifyScreenDump(buf, 'Test_smoothscroll_3', {})
79 call term_sendkeys(buf, "\<C-E>")
80 call VerifyScreenDump(buf, 'Test_smoothscroll_4', {})
81
82 call term_sendkeys(buf, "\<C-Y>")
83 call VerifyScreenDump(buf, 'Test_smoothscroll_5', {})
84 call term_sendkeys(buf, "\<C-Y>")
85 call VerifyScreenDump(buf, 'Test_smoothscroll_6', {})
86 call term_sendkeys(buf, "\<C-Y>")
87 call VerifyScreenDump(buf, 'Test_smoothscroll_7', {})
88 call term_sendkeys(buf, "\<C-Y>")
89 call VerifyScreenDump(buf, 'Test_smoothscroll_8', {})
90
Bram Moolenaar6b2d4ff2022-10-03 14:06:02 +010091 if has('folding')
92 call term_sendkeys(buf, ":set foldmethod=indent\<CR>")
93 " move the cursor so we can reuse the same dumps
94 call term_sendkeys(buf, "5G")
95 call term_sendkeys(buf, "\<C-E>")
96 call VerifyScreenDump(buf, 'Test_smoothscroll_1', {})
97 call term_sendkeys(buf, "\<C-E>")
98 call VerifyScreenDump(buf, 'Test_smoothscroll_2', {})
99 call term_sendkeys(buf, "7G")
100 call term_sendkeys(buf, "\<C-Y>")
101 call VerifyScreenDump(buf, 'Test_smoothscroll_7', {})
102 call term_sendkeys(buf, "\<C-Y>")
103 call VerifyScreenDump(buf, 'Test_smoothscroll_8', {})
104 endif
105
Bram Moolenaarf6196f42022-10-02 21:29:55 +0100106 call StopVimInTerminal(buf)
107endfunc
108
Bram Moolenaarb6aab8f2022-10-03 20:01:16 +0100109func Test_smoothscroll_number()
110 CheckScreendump
111
112 let lines =<< trim END
113 vim9script
114 setline(1, [
115 'one ' .. 'word '->repeat(20),
116 'two ' .. 'long word '->repeat(7),
117 'line',
118 'line',
119 'line',
120 ])
121 set smoothscroll
122 set number cpo+=n
123 :3
124 END
125 call writefile(lines, 'XSmoothNumber', 'D')
126 let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40})
127
128 call VerifyScreenDump(buf, 'Test_smooth_number_1', {})
129 call term_sendkeys(buf, "\<C-E>")
130 call VerifyScreenDump(buf, 'Test_smooth_number_2', {})
131 call term_sendkeys(buf, "\<C-E>")
132 call VerifyScreenDump(buf, 'Test_smooth_number_3', {})
133
134 call term_sendkeys(buf, ":set cpo-=n\<CR>")
135 call VerifyScreenDump(buf, 'Test_smooth_number_4', {})
136 call term_sendkeys(buf, "\<C-Y>")
137 call VerifyScreenDump(buf, 'Test_smooth_number_5', {})
138 call term_sendkeys(buf, "\<C-Y>")
139 call VerifyScreenDump(buf, 'Test_smooth_number_6', {})
140
141 call StopVimInTerminal(buf)
142endfunc
143
Bram Moolenaarf6196f42022-10-02 21:29:55 +0100144
145
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200146" vim: shiftwidth=2 sts=2 expandtab