robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #41114 from epithet/default-ruler-as-expressiondab5fab948

master
5.0 KiB164 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each, finally = t.describe, t.it, t.before_each, t.finally
6local clear = n.clear
7local exec = n.exec
8local feed = n.feed
9local api = n.api
10local eq = t.eq
11local fn = n.fn
12
13describe('normal', function()
14  local screen
15
16  before_each(function()
17    clear()
18    screen = Screen.new(40, 19)
19  end)
20
21  -- oldtest: Test_normal_j_below_botline()
22  it([[no skipped lines with "j" scrolling below botline and 'foldmethod' not "manual"]], function()
23    exec([[
24      set number foldmethod=diff scrolloff=0
25      call setline(1, map(range(1, 9), 'repeat(v:val, 200)'))
26      norm Lj
27    ]])
28    screen:expect([[
29      {8:  2 }222222222222222222222222222222222222|
30      {8:    }222222222222222222222222222222222222|*4
31      {8:    }22222222222222222222                |
32      {8:  3 }333333333333333333333333333333333333|
33      {8:    }333333333333333333333333333333333333|*4
34      {8:    }33333333333333333333                |
35      {8:  4 }^444444444444444444444444444444444444|
36      {8:    }444444444444444444444444444444444444|*4
37      {8:    }44444444444444444444                |
38                                              |
39    ]])
40  end)
41
42  -- oldtest: Test_single_line_scroll()
43  it('(Half)-page scroll up or down reveals virtual lines #19605, #27967', function()
44    fn.setline(1, 'foobar one two three')
45    exec('set smoothscroll')
46    local ns = api.nvim_create_namespace('')
47    api.nvim_buf_set_extmark(0, ns, 0, 0, {
48      virt_lines = { { { '---', 'IncSearch' } } },
49      virt_lines_above = true,
50    })
51    -- Nvim: not actually necessary to scroll down to hide the virtual line.
52    -- Check topfill instead of skipcol and show the screen state.
53    feed('<C-E>')
54    eq(0, fn.winsaveview().topfill)
55    local s1 = [[
56      ^foobar one two three                    |
57      {1:~                                       }|*17
58                                              |
59    ]]
60    screen:expect(s1)
61    feed('<C-B>')
62    eq(1, fn.winsaveview().topfill)
63    local s2 = [[
64      {2:---}                                     |
65      ^foobar one two three                    |
66      {1:~                                       }|*16
67                                              |
68    ]]
69    screen:expect(s2)
70    feed('<C-E>')
71    eq(0, fn.winsaveview().topfill)
72    screen:expect(s1)
73    feed('<C-U>')
74    eq(1, fn.winsaveview().topfill)
75    screen:expect(s2)
76
77    -- Nvim: also test virt_lines below the last line
78    feed('yy100pG<C-L>')
79    api.nvim_buf_set_extmark(0, ns, 100, 0, { virt_lines = { { { '---', 'IncSearch' } } } })
80    screen:expect({
81      grid = [[
82        foobar one two three                    |*17
83        ^foobar one two three                    |
84                                                |
85      ]],
86    })
87    feed('<C-F>')
88    screen:expect({
89      grid = [[
90        ^foobar one two three                    |
91        {2:---}                                     |
92        {1:~                                       }|*16
93                                                |
94      ]],
95    })
96    feed('ggG<C-D>')
97    screen:expect({
98      grid = [[
99        foobar one two three                    |*16
100        ^foobar one two three                    |
101        {2:---}                                     |
102                                                |
103      ]],
104    })
105  end)
106
107  -- oldtest: Test_normal_gm()
108  it('gm sets curswant correctly', function()
109    screen:try_resize(75, 10)
110    exec([[
111      call setline(1, repeat(["  abcd\tefgh\tij"], 10))
112      call cursor(1, 1)
113    ]])
114    feed('jVjzf')
115    -- gm
116    feed('gmk')
117    eq(18, fn.virtcol('.'))
118    -- g0
119    feed('gj0k')
120    eq(1, fn.virtcol('.'))
121    -- g^
122    feed('jg^k')
123    eq(3, fn.virtcol('.'))
124    exec('call cursor(10, 1)')
125    -- gm
126    feed('gmk')
127    eq(18, fn.virtcol('.'))
128    -- g0
129    feed('gj0k')
130    eq(1, fn.virtcol('.'))
131    -- g^
132    feed('jg^k')
133    eq(3, fn.virtcol('.'))
134  end)
135
136  -- oldtest: Test_pos_percentage_in_turkish_locale()
137  it('viewport position percentage in Turkish locale', function()
138    t.skip(not t.translations_enabled(), 'N/A: Nvim not built with ENABLE_TRANSLATIONS')
139    t.skip(not pcall(exec, 'lang tr_TR.UTF-8'), 'Turkish locale not available')
140
141    local build_dir = t.paths.test_build_dir
142    local locale_dir = build_dir .. '/share/locale/tr/LC_MESSAGES'
143
144    fn.mkdir(locale_dir, 'p')
145    fn.filecopy(build_dir .. '/src/nvim/po/tr.mo', locale_dir .. '/nvim.mo')
146    finally(function()
147      n.rmdir(vim.fs.dirname(locale_dir))
148    end)
149
150    clear({ env = { LANG = 'tr_TR.UTF-8' } })
151    screen = Screen.new(40, 5)
152    exec('set ruler')
153    exec('lang tr_TR.UTF-8')
154    exec('put =range(1,40)')
155    exec('5')
156    screen:expect([[
157      3                                       |
158      ^4                                       |
159      5                                       |
160      6                                       |
161      40 more lines         5,1             %8|
162    ]])
163  end)
164end)