aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-02 19:42:31 +0800
committerGitHub <noreply@github.com>2023-05-02 19:42:31 +0800
commit808752f1b09d2f03af5b58167602fef8320c11dc (patch)
tree0cf72ae00bd1b08053daee0ede8aa5495be704f0 /test
parentfba18a3b62310f4535d979a05288101b9af2ef50 (diff)
parent5b111a8f00f8dbe458a3d437c9f06c9419d24840 (diff)
downloadrneovim-808752f1b09d2f03af5b58167602fef8320c11dc.tar.gz
rneovim-808752f1b09d2f03af5b58167602fef8320c11dc.tar.bz2
rneovim-808752f1b09d2f03af5b58167602fef8320c11dc.zip
Merge pull request #23320 from luukvbaal/smoothscroll
feat(ui): add 'smoothscroll' option
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/display_spec.lua47
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua777
-rw-r--r--test/functional/ui/popupmenu_spec.lua2
-rw-r--r--test/old/testdir/test_alot.vim1
-rw-r--r--test/old/testdir/test_breakindent.vim44
-rw-r--r--test/old/testdir/test_diffmode.vim15
-rw-r--r--test/old/testdir/test_display.vim21
-rw-r--r--test/old/testdir/test_listlbr.vim2
-rw-r--r--test/old/testdir/test_listlbr_utf8.vim2
-rw-r--r--test/old/testdir/test_normal.vim40
-rw-r--r--test/old/testdir/test_number.vim2
-rw-r--r--test/old/testdir/test_options.vim104
-rw-r--r--test/old/testdir/test_scroll_opt.vim556
-rw-r--r--test/old/testdir/test_window_cmd.vim39
14 files changed, 1608 insertions, 44 deletions
diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua
index f9b78f5dcd..4952a5c4fe 100644
--- a/test/functional/legacy/display_spec.lua
+++ b/test/functional/legacy/display_spec.lua
@@ -194,4 +194,51 @@ describe('display', function()
it('display "lastline" works correctly with multibyte fillchar', function()
run_test_display_lastline(true)
end)
+
+ -- oldtest: Test_display_long_lastline
+ it('display "lastline" shows correct text when end of wrapped line is deleted', function()
+ local screen = Screen.new(35, 14)
+ screen:attach()
+ exec([[
+ set display=lastline scrolloff=5
+ call setline(1, [
+ \'aaaaa'->repeat(100),
+ \'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7)
+ \])
+ ]])
+ feed('482|')
+ screen:expect([[
+ <<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaa^aaaaaaaaa|
+ aaaaaaaaaa |
+ |
+ ]])
+ feed('D')
+ screen:expect([[
+ <<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ aaaaaaaaaaaaaaaaaaaaaaaaa^a |
+ bbbbb bbbbb bbbbb bbbbb bbbbb bb@@@|
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
new file mode 100644
index 0000000000..b00ff0bc7a
--- /dev/null
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -0,0 +1,777 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear = helpers.clear
+local exec = helpers.exec
+local feed = helpers.feed
+
+before_each(clear)
+
+describe('smoothscroll', function()
+ local screen
+
+ before_each(function()
+ screen = Screen.new(40, 12)
+ screen:attach()
+ end)
+
+ -- oldtest: Test_CtrlE_CtrlY_stop_at_end()
+ it('disabled does not break <C-E> and <C-Y> stop at end', function()
+ exec([[
+ enew
+ call setline(1, ['one', 'two'])
+ set number
+ ]])
+ feed('<C-Y>')
+ screen:expect({any = " 1 ^one"})
+ feed('<C-E><C-E><C-E>')
+ screen:expect({any = " 2 ^two"})
+ end)
+
+ -- oldtest: Test_smoothscroll_CtrlE_CtrlY()
+ it('works with <C-E> and <C-E>', function()
+ exec([[
+ call setline(1, [ 'line one', 'word '->repeat(20), 'line three', 'long word '->repeat(7), 'line', 'line', 'line', ])
+ set smoothscroll scrolloff=5
+ :5
+ ]])
+ local s1 = [[
+ word word word word word word word word |
+ word word word word word word word word |
+ word word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ ^line |
+ line |
+ line |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s2 = [[
+ <<<d word word word word word word word |
+ word word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ ^line |
+ line |
+ line |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s3 = [[
+ <<<d word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ ^line |
+ line |
+ line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s4 = [[
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ line |
+ line |
+ ^line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s5 = [[
+ <<<d word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ line |
+ line |
+ ^line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s6 = [[
+ <<<d word word word word word word word |
+ word word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ line |
+ line |
+ ^line |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s7 = [[
+ word word word word word word word word |
+ word word word word word word word word |
+ word word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ line |
+ line |
+ ^line |
+ ~ |
+ ~ |
+ |
+ ]]
+ local s8 = [[
+ line one |
+ word word word word word word word word |
+ word word word word word word word word |
+ word word word word |
+ line three |
+ long word long word long word long word |
+ long word long word long word |
+ line |
+ line |
+ ^line |
+ ~ |
+ |
+ ]]
+ feed('<C-E>')
+ screen:expect(s1)
+ feed('<C-E>')
+ screen:expect(s2)
+ feed('<C-E>')
+ screen:expect(s3)
+ feed('<C-E>')
+ screen:expect(s4)
+ feed('<C-Y>')
+ screen:expect(s5)
+ feed('<C-Y>')
+ screen:expect(s6)
+ feed('<C-Y>')
+ screen:expect(s7)
+ feed('<C-Y>')
+ screen:expect(s8)
+ exec('set foldmethod=indent')
+ -- move the cursor so we can reuse the same dumps
+ feed('5G<C-E>')
+ screen:expect(s1)
+ feed('<C-E>')
+ screen:expect(s2)
+ feed('7G<C-Y>')
+ screen:expect(s7)
+ feed('<C-Y>')
+ screen:expect(s8)
+ end)
+
+ -- oldtest: Test_smoothscroll_number()
+ it("works 'number' and 'cpo'+=n", function()
+ exec([[
+ call setline(1, [ 'one ' .. 'word '->repeat(20), 'two ' .. 'long word '->repeat(7), 'line', 'line', 'line', ])
+ set smoothscroll scrolloff=5
+ set number cpo+=n
+ :3
+ func g:DoRel()
+ set number relativenumber scrolloff=0
+ :%del
+ call setline(1, [ 'one', 'very long text '->repeat(12), 'three', ])
+ exe "normal 2Gzt\<C-E>"
+ endfunc
+ ]])
+ screen:expect([[
+ 1 one word word word word word word wo|
+ rd word word word word word word word wo|
+ rd word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long word |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ <<<word word word word word word word wo|
+ rd word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long word |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ <<<word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long word |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ exec('set cpo-=n')
+ screen:expect([[
+ <<< d word word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long wor|
+ d |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('<C-Y>')
+ screen:expect([[
+ <<< rd word word word word word word wor|
+ d word word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long wor|
+ d |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('<C-Y>')
+ screen:expect([[
+ 1 one word word word word word word wo|
+ rd word word word word word word wor|
+ d word word word word word word |
+ 2 two long word long word long word lo|
+ ng word long word long word long wor|
+ d |
+ 3 ^line |
+ 4 line |
+ 5 line |
+ ~ |
+ ~ |
+ |
+ ]])
+ exec('call DoRel()')
+ screen:expect([[
+ 2<<<^ong text very long text very long te|
+ xt very long text very long text ver|
+ y long text very long text very long|
+ text very long text very long text |
+ 1 three |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ --No lines in buffer-- |
+ ]])
+ end)
+
+ -- oldtest: Test_smoothscroll_list()
+ it("works with list mode", function()
+ screen:try_resize(40, 8)
+ exec([[
+ set smoothscroll scrolloff=0
+ set list
+ call setline(1, [ 'one', 'very long text '->repeat(12), 'three', ])
+ exe "normal 2Gzt\<C-E>"
+ ]])
+ screen:expect([[
+ <<<t very long text very long text very |
+ ^long text very long text very long text |
+ very long text very long text very long |
+ text very long text- |
+ three |
+ ~ |
+ ~ |
+ |
+ ]])
+ exec('set listchars+=precedes:#')
+ screen:expect([[
+ #ext very long text very long text very |
+ ^long text very long text very long text |
+ very long text very long text very long |
+ text very long text- |
+ three |
+ ~ |
+ ~ |
+ |
+ ]])
+ end)
+
+ -- oldtest: Test_smoothscroll_diff_mode()
+ it("works with diff mode", function()
+ screen:try_resize(40, 8)
+ exec([[
+ let text = 'just some text here'
+ call setline(1, text)
+ set smoothscroll
+ diffthis
+ new
+ call setline(1, text)
+ set smoothscroll
+ diffthis
+ ]])
+ screen:expect([[
+ - ^just some text here |
+ ~ |
+ ~ |
+ [No Name] [+] |
+ - just some text here |
+ ~ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('<C-Y>')
+ screen:expect_unchanged()
+ feed('<C-E>')
+ screen:expect_unchanged()
+ end)
+
+ -- oldtest: Test_smoothscroll_wrap_scrolloff_zero()
+ it("works with zero 'scrolloff'", function()
+ screen:try_resize(40, 8)
+ exec([[
+ call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0 display=
+ :3
+ ]])
+ screen:expect([[
+ <<<h some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ ^Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ |
+ ]])
+ feed('j')
+ screen:expect_unchanged()
+ -- moving cursor down - whole bottom line shows
+ feed('<C-E>j')
+ screen:expect_unchanged()
+ feed('G')
+ screen:expect_unchanged()
+ -- moving cursor up right after the >>> marker - no need to show whole line
+ feed('2gj3l2k')
+ screen:expect([[
+ <<<^h some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ |
+ ]])
+ -- moving cursor up where the >>> marker is - whole top line shows
+ feed('2j02k')
+ screen:expect([[
+ ^Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ @ |
+ |
+ ]])
+ end)
+
+ -- oldtest: Test_smoothscroll_wrap_long_line()
+ it("adjusts the cursor position in a long line", function()
+ screen:try_resize(40, 6)
+ exec([[
+ call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30)) .. ' end', 'four'])
+ set smoothscroll scrolloff=0
+ normal 3G10|zt
+ ]])
+ -- scrolling up, cursor moves screen line down
+ screen:expect([[
+ Line with^ lots of text with lots of text|
+ with lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text with lots of te|
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ <<<th lot^s of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text with lots of te|
+ xt with lots of text with lots of text w|
+ |
+ ]])
+ feed('5<C-E>')
+ screen:expect([[
+ <<< lots ^of text with lots of text with |
+ lots of text with lots of text with lots|
+ of text with lots of text with lots of |
+ text with lots of text with lots of text|
+ with lots of text with lots of text wit|
+ |
+ ]])
+ -- scrolling down, cursor moves screen line up
+ feed('5<C-Y>')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text with lots of te|
+ xt with l^ots of text with lots of text w|
+ |
+ ]])
+ feed('<C-Y>')
+ screen:expect([[
+ Line with lots of text with lots of text|
+ with lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text wi^th lots of text with lots of te|
+ |
+ ]])
+ -- 'scrolloff' set to 1, scrolling up, cursor moves screen line down
+ exec('set scrolloff=1')
+ feed('10|<C-E>')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of^ text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text with lots of te|
+ xt with lots of text with lots of text w|
+ |
+ ]])
+ -- 'scrolloff' set to 1, scrolling down, cursor moves screen line up
+ feed('<C-E>gjgj<C-Y>')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text wi^th lots of text with lots of te|
+ xt with lots of text with lots of text w|
+ |
+ ]])
+ -- 'scrolloff' set to 2, scrolling up, cursor moves screen line down
+ exec('set scrolloff=2')
+ feed('10|<C-E>')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of tex^t with lots of text with lots o|
+ f text with lots of text with lots of te|
+ xt with lots of text with lots of text w|
+ |
+ ]])
+ -- 'scrolloff' set to 2, scrolling down, cursor moves screen line up
+ feed('<C-E>gj<C-Y>')
+ screen:expect_unchanged()
+ -- 'scrolloff' set to 0, move cursor down one line. Cursor should move properly,
+ -- and since this is a really long line, it will be put on top of the screen.
+ exec('set scrolloff=0')
+ feed('0j')
+ screen:expect([[
+ <<<of text with lots of text with lots o|
+ f text with lots of text end |
+ ^four |
+ ~ |
+ ~ |
+ |
+ ]])
+ -- Test zt/zz/zb that they work properly when a long line is above it
+ feed('zb')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text end |
+ ^four |
+ |
+ ]])
+ feed('zz')
+ screen:expect([[
+ <<<of text with lots of text with lots o|
+ f text with lots of text end |
+ ^four |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('zt')
+ screen:expect([[
+ ^four |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ -- Repeat the step and move the cursor down again.
+ -- This time, use a shorter long line that is barely long enough to span more
+ -- than one window. Note that the cursor is at the bottom this time because
+ -- Vim prefers to do so if we are scrolling a few lines only.
+ exec("call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])")
+ feed('3Gztj')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text end |
+ ^four |
+ |
+ ]])
+ -- Repeat the step but this time start it when the line is smooth-scrolled by
+ -- one line. This tests that the offset calculation is still correct and
+ -- still end up scrolling down to the next line with cursor at bottom of
+ -- screen.
+ feed('3Gzt<C-E>j')
+ screen:expect([[
+ <<<th lots of text with lots of text wit|
+ h lots of text with lots of text with lo|
+ ts of text with lots of text with lots o|
+ f text with lots of text end |
+ fou^r |
+ |
+ ]])
+ end)
+
+ -- oldtest: Test_smoothscroll_one_long_line()
+ it("scrolls correctly when moving the cursor", function()
+ screen:try_resize(40, 6)
+ exec([[
+ call setline(1, 'with lots of text '->repeat(7))
+ set smoothscroll scrolloff=0
+ ]])
+ local s1 = [[
+ ^with lots of text with lots of text with|
+ lots of text with lots of text with lot|
+ s of text with lots of text with lots of|
+ text |
+ ~ |
+ |
+ ]]
+ screen:expect(s1)
+ feed('<C-E>')
+ screen:expect([[
+ <<<ts of text with lots of text with lot|
+ ^s of text with lots of text with lots of|
+ text |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed('0')
+ screen:expect(s1)
+ end)
+
+ -- oldtest: Test_smoothscroll_long_line_showbreak()
+ it("cursor is not one screen line too far down", function()
+ screen:try_resize(40, 6)
+ -- a line that spans four screen lines
+ exec("call setline(1, 'with lots of text in one line '->repeat(6))")
+ exec('set smoothscroll scrolloff=0 showbreak=+++\\ ')
+ local s1 = [[
+ ^with lots of text in one line with lots |
+ +++ of text in one line with lots of tex|
+ +++ t in one line with lots of text in o|
+ +++ ne line with lots of text in one lin|
+ +++ e with lots of text in one line |
+ |
+ ]]
+ screen:expect(s1)
+ feed('<C-E>')
+ screen:expect([[
+ +++ ^of text in one line with lots of tex|
+ +++ t in one line with lots of text in o|
+ +++ ne line with lots of text in one lin|
+ +++ e with lots of text in one line |
+ ~ |
+ |
+ ]])
+ feed('0')
+ screen:expect(s1)
+ end)
+
+ -- oldtest: Test_smoothscroll_zero_width()
+ it("does not divide by zero with a narrow window", function()
+ screen:try_resize(12, 2)
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.Brown},
+ [2] = {foreground = Screen.colors.Blue1, bold = true},
+ })
+ exec([[
+ call setline(1, ['a'->repeat(100)])
+ set wrap smoothscroll number laststatus=0
+ wincmd v
+ wincmd v
+ wincmd v
+ wincmd v
+ ]])
+ screen:expect([[
+ {1: 1^ }│{1: }│{1: }│{1: }│{1: }|
+ |
+ ]])
+ feed('llllllllll<C-W>o')
+ screen:expect([[
+ {2:<<<}{1: }aa^aaaaaa|
+ |
+ ]])
+ end)
+
+ it("works with virt_lines above and below", function()
+ screen:try_resize(55, 7)
+ exec([=[
+ call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(3))
+ set smoothscroll
+ let ns = nvim_create_namespace('')
+ call nvim_buf_set_extmark(0, ns, 0, 0, {'virt_lines':[[['virt_below1']]]})
+ call nvim_buf_set_extmark(0, ns, 1, 0, {'virt_lines':[[['virt_above1']]],'virt_lines_above':1})
+ call nvim_buf_set_extmark(0, ns, 1, 0, {'virt_lines':[[['virt_below2']]]})
+ call nvim_buf_set_extmark(0, ns, 2, 0, {'virt_lines':[[['virt_above2']]],'virt_lines_above':1})
+ norm ggL
+ ]=])
+ screen:expect([[
+ Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ virt_below1 |
+ virt_above1 |
+ ^Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ <<<e text with some text with some text with some text |
+ virt_below1 |
+ virt_above1 |
+ ^Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ virt_below2 |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ virt_below1 |
+ virt_above1 |
+ ^Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ virt_below2 |
+ virt_above2 |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ virt_above1 |
+ ^Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ virt_below2 |
+ virt_above2 |
+ Line with some text with some text with some text wi@@@|
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ ^Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ virt_below2 |
+ virt_above2 |
+ Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ |
+ ]])
+ feed('<C-E>')
+ screen:expect([[
+ <<<e text with some text with some text with some tex^t |
+ virt_below2 |
+ virt_above2 |
+ Line with some text with some text with some text with |
+ some text with some text with some text with some text |
+ ~ |
+ |
+ ]])
+ end)
+
+ it('<<< marker shows with tabline, winbar and splits', function()
+ screen:try_resize(40, 12)
+ exec([[
+ call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0
+ norm sj
+ ]])
+ screen:expect([[
+ <<<e text with some text with some text |
+ with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ [No Name] [+] |
+ <<<e text with some text with some text |
+ ^with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some te@@@|
+ [No Name] [+] |
+ |
+ ]])
+ exec('set showtabline=2')
+ feed('<C-E>')
+ screen:expect([[
+ 2+ [No Name] |
+ <<<e text with some text with some text |
+ with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ [No Name] [+] |
+ <<<e text with some text with some text |
+ ^with some text with some text |
+ Line with some text with some text wi@@@|
+ [No Name] [+] |
+ |
+ ]])
+ exec('set winbar=winbar')
+ feed('<C-w>k<C-E>')
+ screen:expect([[
+ 2+ [No Name] |
+ winbar |
+ <<<e text with some text with some text |
+ ^with some text with some text |
+ Line with some text with some text with |
+ some text with some text with some te@@@|
+ [No Name] [+] |
+ winbar |
+ <<<e text with some text with some text |
+ with some text with some text |
+ [No Name] [+] |
+ |
+ ]])
+ end)
+end)
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 0b71e12b6f..6c26c8ea39 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -2396,7 +2396,7 @@ describe('builtin popupmenu', function()
-- can't draw the pum, but check we don't crash
screen:try_resize(12,2)
screen:expect([[
- text^ |
+ {1:<<<}t^ |
{2:-- INSERT -} |
]])
diff --git a/test/old/testdir/test_alot.vim b/test/old/testdir/test_alot.vim
index 4a22315b9f..2a959f0834 100644
--- a/test/old/testdir/test_alot.vim
+++ b/test/old/testdir/test_alot.vim
@@ -17,7 +17,6 @@ source test_global.vim
source test_move.vim
source test_put.vim
source test_reltime.vim
-source test_scroll_opt.vim
source test_searchpos.vim
source test_set.vim
source test_shift.vim
diff --git a/test/old/testdir/test_breakindent.vim b/test/old/testdir/test_breakindent.vim
index 0d1753182e..f6c0e32adf 100644
--- a/test/old/testdir/test_breakindent.vim
+++ b/test/old/testdir/test_breakindent.vim
@@ -87,7 +87,7 @@ func Test_breakindent02_vartabs()
endif
" simple breakindent test with showbreak set
call s:test_windows('setl briopt=min:0 sbr=>> vts=4')
- let lines = s:screen_lines(line('.'),8)
+ let lines = s:screen_lines(line('.'), 8)
let expect = [
\ " abcd",
\ " >>qr",
@@ -100,7 +100,7 @@ endfunc
func Test_breakindent03()
" simple breakindent test with showbreak set and briopt including sbr
call s:test_windows('setl briopt=sbr,min:0 sbr=++')
- let lines = s:screen_lines(line('.'),8)
+ let lines = s:screen_lines(line('.'), 8)
let expect=[
\ " abcd",
\ "++ qrst",
@@ -117,7 +117,7 @@ func Test_breakindent03_vartabs()
return
endif
call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4')
- let lines = s:screen_lines(line('.'),8)
+ let lines = s:screen_lines(line('.'), 8)
let expect = [
\ " abcd",
\ "++ qrst",
@@ -132,7 +132,7 @@ func Test_breakindent04()
" breakindent set with min width 18
set sbr=<<<
call s:test_windows('setl sbr=NONE briopt=min:18')
- let lines = s:screen_lines(line('.'),8)
+ let lines = s:screen_lines(line('.'), 8)
let expect = [
\ " abcd",
\ " qrstuv",
@@ -150,7 +150,7 @@ func Test_breakindent04_vartabs()
return
endif
call s:test_windows('setl sbr= briopt=min:18 vts=4')
- let lines = s:screen_lines(line('.'),8)
+ let lines = s:screen_lines(line('.'), 8)
let expect = [
\ " abcd",
\ " qrstuv",
@@ -583,7 +583,7 @@ func Test_breakindent16()
redraw!
let lines = s:screen_lines(1,10)
let expect = [
- \ " 789012",
+ \ "<<< 789012",
\ " 345678",
\ " 901234",
\ ]
@@ -611,7 +611,7 @@ func Test_breakindent16_vartabs()
redraw!
let lines = s:screen_lines(1,10)
let expect = [
- \ " 789012",
+ \ "<<< 789012",
\ " 345678",
\ " 901234",
\ ]
@@ -711,25 +711,25 @@ endfunc
func Test_breakindent20_cpo_n_nextpage()
let s:input = ""
call s:test_windows('setl breakindent briopt=min:14 cpo+=n number')
- call setline(1, repeat('a', 200))
+ call setline(1, repeat('abcdefghijklmnopqrst', 10))
norm! 1gg
redraw!
let lines = s:screen_lines(1, 20)
let expect = [
- \ " 1 aaaaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaaaa",
+ \ " 1 abcdefghijklmnop",
+ \ " qrstabcdefghijkl",
+ \ " mnopqrstabcdefgh",
\ ]
call s:compare_lines(expect, lines)
" Scroll down one screen line
setl scrolloff=5
- norm! 5gj
+ norm! 6gj
redraw!
let lines = s:screen_lines(1, 20)
let expect = [
- \ "--1 aaaaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaaaa",
+ \ "<<< qrstabcdefghijkl",
+ \ " mnopqrstabcdefgh",
+ \ " ijklmnopqrstabcd",
\ ]
call s:compare_lines(expect, lines)
@@ -737,18 +737,18 @@ func Test_breakindent20_cpo_n_nextpage()
norm! 1gg
let lines = s:screen_lines(1, 20)
let expect = [
- \ " 1 aaaaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaa",
+ \ " 1 abcdefghijklmnop",
+ \ " qrstabcdefghij",
+ \ " klmnopqrstabcd",
\ ]
call s:compare_lines(expect, lines)
" Scroll down one screen line
- norm! 5gj
+ norm! 6gj
let lines = s:screen_lines(1, 20)
let expect = [
- \ "--1 aaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaa",
- \ " aaaaaaaaaaaaaa",
+ \ "<<< qrstabcdefghij",
+ \ " klmnopqrstabcd",
+ \ " efghijklmnopqr",
\ ]
call s:compare_lines(expect, lines)
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index 0049398776..ac90aaaa02 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -1605,6 +1605,21 @@ func Test_diff_scroll()
call delete('Xright')
endfunc
+" This was scrolling too many lines.
+func Test_diff_scroll_wrap_on()
+ 20new
+ 40vsplit
+ call setline(1, map(range(1, 9), 'repeat(v:val, 200)'))
+ setlocal number diff so=0
+ redraw
+ normal! jj
+ call assert_equal(1, winsaveview().topline)
+ normal! j
+ call assert_equal(2, winsaveview().topline)
+ bwipe!
+ bwipe!
+endfunc
+
" This was trying to update diffs for a buffer being closed
func Test_diff_only()
silent! lfile
diff --git a/test/old/testdir/test_display.vim b/test/old/testdir/test_display.vim
index b642f39c9f..f27a8362a9 100644
--- a/test/old/testdir/test_display.vim
+++ b/test/old/testdir/test_display.vim
@@ -478,5 +478,26 @@ func Test_display_lastline()
call assert_fails(':set fillchars=lastline:〇', 'E474:')
endfunc
+func Test_display_long_lastline()
+ CheckScreendump
+
+ let lines =<< trim END
+ set display=lastline
+ call setline(1, [
+ \'aaaaa'->repeat(100),
+ \'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7)
+ \])
+ END
+
+ call writefile(lines, 'XdispLongline', 'D')
+ let buf = RunVimInTerminal('-S XdispLongline', #{rows: 14, cols: 35})
+
+ call term_sendkeys(buf, "482|")
+ call VerifyScreenDump(buf, 'Test_display_long_line_1', {})
+ call term_sendkeys(buf, "D")
+ call VerifyScreenDump(buf, 'Test_display_long_line_2', {})
+
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_listlbr.vim b/test/old/testdir/test_listlbr.vim
index a746779e73..2e66fd4ccb 100644
--- a/test/old/testdir/test_listlbr.vim
+++ b/test/old/testdir/test_listlbr.vim
@@ -223,7 +223,7 @@ func Test_virtual_block_and_vbA()
exe "norm! $3B\<C-v>eAx\<Esc>"
let lines = s:screen_lines([1, 10], winwidth(0))
let expect = [
-\ "foobar foobar ",
+\ "<<<bar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
diff --git a/test/old/testdir/test_listlbr_utf8.vim b/test/old/testdir/test_listlbr_utf8.vim
index df1ed78119..15b248964f 100644
--- a/test/old/testdir/test_listlbr_utf8.vim
+++ b/test/old/testdir/test_listlbr_utf8.vim
@@ -266,7 +266,7 @@ func Test_chinese_char_on_wrap_column()
norm! $
redraw!
let expect=[
-\ '中aaaaaaaaaaaaaaaaa>',
+\ '<<<aaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index fe8611d527..600e58848b 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -3738,15 +3738,45 @@ endfunc
" Test for 'scrolloff' with a long line that doesn't fit in the screen
func Test_normal_scroloff()
10new
- 80vnew
- call setline(1, repeat('a', 1000))
+ 60vnew
+ call setline(1, ' 1 ' .. repeat('a', 57)
+ \ .. ' 2 ' .. repeat('b', 57)
+ \ .. ' 3 ' .. repeat('c', 57)
+ \ .. ' 4 ' .. repeat('d', 57)
+ \ .. ' 5 ' .. repeat('e', 57)
+ \ .. ' 6 ' .. repeat('f', 57)
+ \ .. ' 7 ' .. repeat('g', 57)
+ \ .. ' 8 ' .. repeat('h', 57)
+ \ .. ' 9 ' .. repeat('i', 57)
+ \ .. '10 ' .. repeat('j', 57)
+ \ .. '11 ' .. repeat('k', 57)
+ \ .. '12 ' .. repeat('l', 57)
+ \ .. '13 ' .. repeat('m', 57)
+ \ .. '14 ' .. repeat('n', 57)
+ \ .. '15 ' .. repeat('o', 57)
+ \ .. '16 ' .. repeat('p', 57)
+ \ .. '17 ' .. repeat('q', 57)
+ \ .. '18 ' .. repeat('r', 57)
+ \ .. '19 ' .. repeat('s', 57)
+ \ .. '20 ' .. repeat('t', 57)
+ \ .. '21 ' .. repeat('u', 57)
+ \ .. '22 ' .. repeat('v', 57)
+ \ .. '23 ' .. repeat('w', 57)
+ \ .. '24 ' .. repeat('x', 57)
+ \ .. '25 ' .. repeat('y', 57)
+ \ .. '26 ' .. repeat('z', 57)
+ \ )
set scrolloff=10
normal gg10gj
- call assert_equal(8, winline())
+ call assert_equal(6, winline())
normal 10gj
- call assert_equal(10, winline())
+ call assert_equal(6, winline())
normal 10gk
- call assert_equal(3, winline())
+ call assert_equal(6, winline())
+ normal 0
+ call assert_equal(1, winline())
+ normal $
+ call assert_equal(10, winline())
set scrolloff&
close!
endfunc
diff --git a/test/old/testdir/test_number.vim b/test/old/testdir/test_number.vim
index 521b0cf706..cf777fd918 100644
--- a/test/old/testdir/test_number.vim
+++ b/test/old/testdir/test_number.vim
@@ -138,7 +138,7 @@ func Test_number_with_linewrap1()
call s:validate_cursor()
let lines = s:screen_lines(1, 3)
let expect = [
-\ "--1 aaaa",
+\ "<<< aaaa",
\ " aaaa",
\ " aaaa",
\ ]
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index f101f550d1..8fc86a99e3 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -721,7 +721,7 @@ func Test_backupskip()
let &backupskip = backupskip
endfunc
-func Test_copy_winopt()
+func Test_buf_copy_winopt()
set hidden
" Test copy option from current buffer in window
@@ -775,6 +775,108 @@ func Test_copy_winopt()
set hidden&
endfunc
+func Test_split_copy_options()
+ let values = [
+ \['cursorbind', 1, 0],
+ \['fillchars', '"vert:-"', '"' .. &fillchars .. '"'],
+ \['list', 1, 0],
+ \['listchars', '"space:-"', '"' .. &listchars .. '"'],
+ \['number', 1, 0],
+ \['relativenumber', 1, 0],
+ \['scrollbind', 1, 0],
+ \['smoothscroll', 1, 0],
+ \['virtualedit', '"block"', '"' .. &virtualedit .. '"'],
+ "\ ['wincolor', '"Search"', '"' .. &wincolor .. '"'],
+ \['wrap', 0, 1],
+ \]
+ if has('linebreak')
+ let values += [
+ \['breakindent', 1, 0],
+ \['breakindentopt', '"min:5"', '"' .. &breakindentopt .. '"'],
+ \['linebreak', 1, 0],
+ \['numberwidth', 7, 4],
+ \['showbreak', '"++"', '"' .. &showbreak .. '"'],
+ \]
+ endif
+ if has('rightleft')
+ let values += [
+ \['rightleft', 1, 0],
+ \['rightleftcmd', '"search"', '"' .. &rightleftcmd .. '"'],
+ \]
+ endif
+ if has('statusline')
+ let values += [
+ \['statusline', '"---%f---"', '"' .. &statusline .. '"'],
+ \]
+ endif
+ if has('spell')
+ let values += [
+ \['spell', 1, 0],
+ \]
+ endif
+ if has('syntax')
+ let values += [
+ \['cursorcolumn', 1, 0],
+ \['cursorline', 1, 0],
+ \['cursorlineopt', '"screenline"', '"' .. &cursorlineopt .. '"'],
+ \['colorcolumn', '"+1"', '"' .. &colorcolumn .. '"'],
+ \]
+ endif
+ if has('diff')
+ let values += [
+ \['diff', 1, 0],
+ \]
+ endif
+ if has('conceal')
+ let values += [
+ \['concealcursor', '"nv"', '"' .. &concealcursor .. '"'],
+ \['conceallevel', '3', &conceallevel],
+ \]
+ endif
+ if has('terminal')
+ let values += [
+ \['termwinkey', '"<C-X>"', '"' .. &termwinkey .. '"'],
+ \['termwinsize', '"10x20"', '"' .. &termwinsize .. '"'],
+ \]
+ endif
+ if has('folding')
+ let values += [
+ \['foldcolumn', '"5"', &foldcolumn],
+ \['foldenable', 0, 1],
+ \['foldexpr', '"2 + 3"', '"' .. &foldexpr .. '"'],
+ \['foldignore', '"+="', '"' .. &foldignore .. '"'],
+ \['foldlevel', 4, &foldlevel],
+ \['foldmarker', '">>,<<"', '"' .. &foldmarker .. '"'],
+ \['foldmethod', '"marker"', '"' .. &foldmethod .. '"'],
+ \['foldminlines', 3, &foldminlines],
+ \['foldnestmax', 17, &foldnestmax],
+ \['foldtext', '"closed"', '"' .. &foldtext .. '"'],
+ \]
+ endif
+ if has('signs')
+ let values += [
+ \['signcolumn', '"number"', '"' .. &signcolumn .. '"'],
+ \]
+ endif
+
+ " set options to non-default value
+ for item in values
+ exe $"let &{item[0]} = {item[1]}"
+ endfor
+
+ " check values are set in new window
+ split
+ for item in values
+ exe $'call assert_equal({item[1]}, &{item[0]}, "{item[0]}")'
+ endfor
+
+ " restore
+ close
+ for item in values
+ exe $"let &{item[0]} = {item[1]}"
+ endfor
+endfunc
+
func Test_shortmess_F()
new
call assert_match('\[No Name\]', execute('file'))
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index 64f4ced470..4ed54591af 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -1,4 +1,8 @@
-" Test for reset 'scroll'
+" Test for reset 'scroll' and 'smoothscroll'
+
+source check.vim
+source screendump.vim
+source mouse.vim
func Test_reset_scroll()
let scr = &l:scroll
@@ -51,4 +55,554 @@ func Test_scolloff_even_line_count()
bwipe!
endfunc
+func Test_CtrlE_CtrlY_stop_at_end()
+ enew
+ call setline(1, ['one', 'two'])
+ set number
+ exe "normal \<C-Y>"
+ call assert_equal([" 1 one "], ScreenLines(1, 10))
+ exe "normal \<C-E>\<C-E>\<C-E>"
+ call assert_equal([" 2 two "], ScreenLines(1, 10))
+
+ bwipe!
+ set nonumber
+endfunc
+
+func Test_smoothscroll_CtrlE_CtrlY()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, [
+ 'line one',
+ 'word '->repeat(20),
+ 'line three',
+ 'long word '->repeat(7),
+ 'line',
+ 'line',
+ 'line',
+ ])
+ set smoothscroll
+ :5
+ END
+ call writefile(lines, 'XSmoothScroll', 'D')
+ let buf = RunVimInTerminal('-S XSmoothScroll', #{rows: 12, cols: 40})
+
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_1', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_2', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_3', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_4', {})
+
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_5', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_6', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_7', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_8', {})
+
+ if has('folding')
+ call term_sendkeys(buf, ":set foldmethod=indent\<CR>")
+ " move the cursor so we can reuse the same dumps
+ call term_sendkeys(buf, "5G")
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_1', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_2', {})
+ call term_sendkeys(buf, "7G")
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_7', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_8', {})
+ endif
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_number()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, [
+ 'one ' .. 'word '->repeat(20),
+ 'two ' .. 'long word '->repeat(7),
+ 'line',
+ 'line',
+ 'line',
+ ])
+ set smoothscroll
+ set number cpo+=n
+ :3
+
+ def g:DoRel()
+ set number relativenumber scrolloff=0
+ :%del
+ setline(1, [
+ 'one',
+ 'very long text '->repeat(12),
+ 'three',
+ ])
+ exe "normal 2Gzt\<C-E>"
+ enddef
+ END
+ call writefile(lines, 'XSmoothNumber', 'D')
+ let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40})
+
+ call VerifyScreenDump(buf, 'Test_smooth_number_1', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_2', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_3', {})
+
+ call term_sendkeys(buf, ":set cpo-=n\<CR>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_4', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_5', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_6', {})
+
+ call term_sendkeys(buf, ":call DoRel()\<CR>")
+ call VerifyScreenDump(buf, 'Test_smooth_number_7', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_list()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ set smoothscroll scrolloff=0
+ set list
+ setline(1, [
+ 'one',
+ 'very long text '->repeat(12),
+ 'three',
+ ])
+ exe "normal 2Gzt\<C-E>"
+ END
+ call writefile(lines, 'XSmoothList', 'D')
+ let buf = RunVimInTerminal('-S XSmoothList', #{rows: 8, cols: 40})
+
+ call VerifyScreenDump(buf, 'Test_smooth_list_1', {})
+
+ call term_sendkeys(buf, ":set listchars+=precedes:#\<CR>")
+ call VerifyScreenDump(buf, 'Test_smooth_list_2', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_diff_mode()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ var text = 'just some text here'
+ setline(1, text)
+ set smoothscroll
+ diffthis
+ new
+ setline(1, text)
+ set smoothscroll
+ diffthis
+ END
+ call writefile(lines, 'XSmoothDiff', 'D')
+ let buf = RunVimInTerminal('-S XSmoothDiff', #{rows: 8})
+
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_wrap_scrolloff_zero()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0
+ :3
+ END
+ call writefile(lines, 'XSmoothWrap', 'D')
+ let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 8, cols: 40})
+
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
+
+ " moving cursor down - whole bottom line shows
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
+
+ call term_sendkeys(buf, "\<C-E>j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_3', {})
+
+ call term_sendkeys(buf, "G")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
+
+ " moving cursor up right after the >>> marker - no need to show whole line
+ call term_sendkeys(buf, "2gj3l2k")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {})
+
+ " moving cursor up where the >>> marker is - whole top line shows
+ call term_sendkeys(buf, "2j02k")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_6', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_wrap_long_line()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30)) .. ' end', 'four'])
+ set smoothscroll scrolloff=0
+ normal 3G10|zt
+ END
+ call writefile(lines, 'XSmoothWrap', 'D')
+ let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 6, cols: 40})
+ call VerifyScreenDump(buf, 'Test_smooth_long_1', {})
+
+ " scrolling up, cursor moves screen line down
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_2', {})
+ call term_sendkeys(buf, "5\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_3', {})
+
+ " scrolling down, cursor moves screen line up
+ call term_sendkeys(buf, "5\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_4', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_5', {})
+
+ " 'scrolloff' set to 1, scrolling up, cursor moves screen line down
+ call term_sendkeys(buf, ":set scrolloff=1\<CR>")
+ call term_sendkeys(buf, "10|\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_6', {})
+
+ " 'scrolloff' set to 1, scrolling down, cursor moves screen line up
+ call term_sendkeys(buf, "\<C-E>")
+ call term_sendkeys(buf, "gjgj")
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_7', {})
+
+ " 'scrolloff' set to 2, scrolling up, cursor moves screen line down
+ call term_sendkeys(buf, ":set scrolloff=2\<CR>")
+ call term_sendkeys(buf, "10|\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_8', {})
+
+ " 'scrolloff' set to 2, scrolling down, cursor moves screen line up
+ call term_sendkeys(buf, "\<C-E>")
+ call term_sendkeys(buf, "gj")
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_9', {})
+
+ " 'scrolloff' set to 0, move cursor down one line.
+ " Cursor should move properly, and since this is a really long line, it will
+ " be put on top of the screen.
+ call term_sendkeys(buf, ":set scrolloff=0\<CR>")
+ call term_sendkeys(buf, "0j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_10', {})
+
+ " Test zt/zz/zb that they work properly when a long line is above it
+ call term_sendkeys(buf, "zb")
+ call VerifyScreenDump(buf, 'Test_smooth_long_11', {})
+ call term_sendkeys(buf, "zz")
+ call VerifyScreenDump(buf, 'Test_smooth_long_12', {})
+ call term_sendkeys(buf, "zt")
+ call VerifyScreenDump(buf, 'Test_smooth_long_13', {})
+
+ " Repeat the step and move the cursor down again.
+ " This time, use a shorter long line that is barely long enough to span more
+ " than one window. Note that the cursor is at the bottom this time because
+ " Vim prefers to do so if we are scrolling a few lines only.
+ call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])\<CR>")
+ call term_sendkeys(buf, "3Gzt")
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_14', {})
+
+ " Repeat the step but this time start it when the line is smooth-scrolled by
+ " one line. This tests that the offset calculation is still correct and
+ " still end up scrolling down to the next line with cursor at bottom of
+ " screen.
+ call term_sendkeys(buf, "3Gzt")
+ call term_sendkeys(buf, "\<C-E>j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_15', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_one_long_line()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, 'with lots of text '->repeat(7))
+ set smoothscroll scrolloff=0
+ END
+ call writefile(lines, 'XSmoothOneLong', 'D')
+ let buf = RunVimInTerminal('-S XSmoothOneLong', #{rows: 6, cols: 40})
+ call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {})
+
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_one_long_2', {})
+
+ call term_sendkeys(buf, "0")
+ call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_smoothscroll_long_line_showbreak()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ # a line that spans four screen lines
+ setline(1, 'with lots of text in one line '->repeat(6))
+ set smoothscroll scrolloff=0 showbreak=+++\
+ END
+ call writefile(lines, 'XSmoothLongShowbreak', 'D')
+ let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40})
+ call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {})
+
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {})
+
+ call term_sendkeys(buf, "0")
+ call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func s:check_col_calc(win_col, win_line, buf_col)
+ call assert_equal(a:win_col, wincol())
+ call assert_equal(a:win_line, winline())
+ call assert_equal(a:buf_col, col('.'))
+endfunc
+
+" Test that if the current cursor is on a smooth scrolled line, we correctly
+" reposition it. Also check that we don't miscalculate the values by checking
+" the consistency between wincol() and col('.') as they are calculated
+" separately in code.
+func Test_smoothscroll_cursor_position()
+ call NewWindow(10, 20)
+ setl smoothscroll wrap
+ call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
+
+ call s:check_col_calc(1, 1, 1)
+ exe "normal \<C-E>"
+
+ " Move down another line to avoid blocking the <<< display
+ call s:check_col_calc(1, 2, 41)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(1, 3, 41)
+
+ normal gg3l
+ exe "normal \<C-E>"
+
+ " Move down only 1 line when we are out of the range of the <<< display
+ call s:check_col_calc(4, 1, 24)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(4, 2, 24)
+ normal ggg$
+ exe "normal \<C-E>"
+ call s:check_col_calc(20, 1, 40)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(20, 2, 40)
+ normal gg
+
+ " Test number, where we have indented lines
+ setl number
+ call s:check_col_calc(5, 1, 1)
+ exe "normal \<C-E>"
+
+ " Move down only 1 line when the <<< display is on the number column
+ call s:check_col_calc(5, 1, 17)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(5, 2, 17)
+ normal ggg$
+ exe "normal \<C-E>"
+ call s:check_col_calc(20, 1, 32)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(20, 2, 32)
+ normal gg
+
+ setl numberwidth=1
+
+ " Move down another line when numberwidth is too short to cover the whole
+ " <<< display
+ call s:check_col_calc(3, 1, 1)
+ exe "normal \<C-E>"
+ call s:check_col_calc(3, 2, 37)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(3, 3, 37)
+ normal ggl
+
+ " Only move 1 line down when we are just past the <<< display
+ call s:check_col_calc(4, 1, 2)
+ exe "normal \<C-E>"
+ call s:check_col_calc(4, 1, 20)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(4, 2, 20)
+ normal gg
+ setl numberwidth&
+
+ " Test number + showbreak, so test that the additional indentation works
+ setl number showbreak=+++
+ call s:check_col_calc(5, 1, 1)
+ exe "normal \<C-E>"
+ call s:check_col_calc(8, 1, 17)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(8, 2, 17)
+ normal gg
+
+ " Test number + cpo+=n mode, where wrapped lines aren't indented
+ setl number cpo+=n showbreak=
+ call s:check_col_calc(5, 1, 1)
+ exe "normal \<C-E>"
+ call s:check_col_calc(1, 2, 37)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(1, 3, 37)
+ normal gg
+
+ bwipe!
+endfunc
+
+func Test_smoothscroll_cursor_scrolloff()
+ call NewWindow(10, 20)
+ setl smoothscroll wrap
+ setl scrolloff=3
+
+ " 120 chars are 6 screen lines
+ call setline(1, "abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST")
+ call setline(2, "below")
+
+ call s:check_col_calc(1, 1, 1)
+
+ " CTRL-E shows "<<<DEFG...", cursor move four lines down
+ exe "normal \<C-E>"
+ call s:check_col_calc(1, 4, 81)
+
+ " cursor on start of second line, "gk" moves into first line, skipcol doesn't
+ " change
+ exe "normal G0gk"
+ call s:check_col_calc(1, 5, 101)
+
+ " move cursor left one window width worth, scrolls one screen line
+ exe "normal 20h"
+ call s:check_col_calc(1, 5, 81)
+
+ " move cursor left one window width worth, scrolls one screen line
+ exe "normal 20h"
+ call s:check_col_calc(1, 4, 61)
+
+ " cursor on last line, "gk" should not cause a scroll
+ set scrolloff=0
+ normal G0
+ call s:check_col_calc(1, 7, 1)
+ normal gk
+ call s:check_col_calc(1, 6, 101)
+
+ bwipe!
+endfunc
+
+
+" Test that mouse picking is still accurate when we have smooth scrolled lines
+func Test_smoothscroll_mouse_pos()
+ CheckNotGui
+ CheckUnix
+
+ let save_mouse = &mouse
+ "let save_term = &term
+ "let save_ttymouse = &ttymouse
+ set mouse=a "term=xterm ttymouse=xterm2
+
+ call NewWindow(10, 20)
+ setl smoothscroll wrap
+ " First line will wrap to 3 physical lines. 2nd/3rd lines are short lines.
+ call setline(1, ["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "line 2", "line 3"])
+
+ func s:check_mouse_click(row, col, buf_row, buf_col)
+ call MouseLeftClick(a:row, a:col)
+
+ call assert_equal(a:col, wincol())
+ call assert_equal(a:row, winline())
+ call assert_equal(a:buf_row, line('.'))
+ call assert_equal(a:buf_col, col('.'))
+ endfunc
+
+ " Check that clicking without scroll works first.
+ call s:check_mouse_click(3, 5, 1, 45)
+ call s:check_mouse_click(4, 1, 2, 1)
+ call s:check_mouse_click(4, 6, 2, 6)
+ call s:check_mouse_click(5, 1, 3, 1)
+ call s:check_mouse_click(5, 6, 3, 6)
+
+ " Smooth scroll, and checks that this didn't mess up mouse clicking
+ exe "normal \<C-E>"
+ call s:check_mouse_click(2, 5, 1, 45)
+ call s:check_mouse_click(3, 1, 2, 1)
+ call s:check_mouse_click(3, 6, 2, 6)
+ call s:check_mouse_click(4, 1, 3, 1)
+ call s:check_mouse_click(4, 6, 3, 6)
+
+ exe "normal \<C-E>"
+ call s:check_mouse_click(1, 5, 1, 45)
+ call s:check_mouse_click(2, 1, 2, 1)
+ call s:check_mouse_click(2, 6, 2, 6)
+ call s:check_mouse_click(3, 1, 3, 1)
+ call s:check_mouse_click(3, 6, 3, 6)
+
+ " Make a new first line 11 physical lines tall so it's taller than window
+ " height, to test overflow calculations with really long lines wrapping.
+ normal gg
+ call setline(1, "12345678901234567890"->repeat(11))
+ exe "normal 6\<C-E>"
+ call s:check_mouse_click(5, 1, 1, 201)
+ call s:check_mouse_click(6, 1, 2, 1)
+ call s:check_mouse_click(7, 1, 3, 1)
+
+ let &mouse = save_mouse
+ "let &term = save_term
+ "let &ttymouse = save_ttymouse
+endfunc
+
+" this was dividing by zero
+func Test_smoothscrol_zero_width()
+ CheckScreendump
+
+ let lines =<< trim END
+ winsize 0 0
+ vsplit
+ vsplit
+ vsplit
+ vsplit
+ vsplit
+ sil norm H
+ set wrap
+ set smoothscroll
+ set number
+ END
+ call writefile(lines, 'XSmoothScrollZero', 'D')
+ let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XSmoothScrollZero', #{rows: 6, cols: 60, wait_for_ruler: 0})
+ call TermWait(buf, 3000)
+ call VerifyScreenDump(buf, 'Test_smoothscroll_zero_1', {})
+
+ call term_sendkeys(buf, ":sil norm \<C-V>\<C-W>\<C-V>\<C-N>\<CR>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_zero_2', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index f938203736..f18d1719c0 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -1734,7 +1734,7 @@ func Test_splitkeep_options()
" let &t_WS = save_WS
endfunc
-function Test_splitkeep_cmdwin_cursor_position()
+func Test_splitkeep_cmdwin_cursor_position()
set splitkeep=screen
call setline(1, range(&lines))
@@ -1759,9 +1759,9 @@ function Test_splitkeep_cmdwin_cursor_position()
%bwipeout!
set splitkeep&
-endfunction
+endfunc
-function Test_splitkeep_misc()
+func Test_splitkeep_misc()
set splitkeep=screen
set splitbelow
@@ -1794,7 +1794,7 @@ function Test_splitkeep_misc()
set splitkeep&
endfunc
-function Test_splitkeep_callback()
+func Test_splitkeep_callback()
CheckScreendump
let lines =<< trim END
set splitkeep=screen
@@ -1827,7 +1827,7 @@ function Test_splitkeep_callback()
call StopVimInTerminal(buf)
endfunc
-function Test_splitkeep_fold()
+func Test_splitkeep_fold()
CheckScreendump
let lines =<< trim END
@@ -1857,9 +1857,9 @@ function Test_splitkeep_fold()
call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {})
call StopVimInTerminal(buf)
-endfunction
+endfunc
-function Test_splitkeep_status()
+func Test_splitkeep_status()
CheckScreendump
let lines =<< trim END
@@ -1877,9 +1877,9 @@ function Test_splitkeep_status()
call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {})
call StopVimInTerminal(buf)
-endfunction
+endfunc
-function Test_new_help_window_on_error()
+func Test_new_help_window_on_error()
help change.txt
execute "normal! /CTRL-@\<CR>"
silent! execute "normal! \<C-W>]"
@@ -1889,7 +1889,26 @@ function Test_new_help_window_on_error()
call assert_equal(wincount, winnr('$'))
call assert_equal(expand("<cword>"), "'mod'")
-endfunction
+endfunc
+
+func Test_smoothscroll_in_zero_width_window()
+ let save_lines = &lines
+ let save_columns = &columns
+
+ winsize 0 24
+ set cpo+=n
+ exe "noremap 0 \<C-W>n\<C-W>L"
+ norm 000000
+ set number smoothscroll
+ exe "norm \<C-Y>"
+
+ only!
+ let &lines = save_lines
+ let &columns = save_columns
+ set cpo-=n
+ unmap 0
+ set nonumber nosmoothscroll
+endfunc
" vim: shiftwidth=2 sts=2 expandtab