diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
tree | cd08258054db80bb9a11b1061bb091c70b76926a /test/functional/vimscript/screenpos_spec.lua | |
parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.gz rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.bz2 rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/vimscript/screenpos_spec.lua')
-rw-r--r-- | test/functional/vimscript/screenpos_spec.lua | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua index 75e5c02298..8b8276457d 100644 --- a/test/functional/vimscript/screenpos_spec.lua +++ b/test/functional/vimscript/screenpos_spec.lua @@ -1,12 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths local command, funcs = helpers.command, helpers.funcs +local feed = helpers.feed before_each(clear) describe('screenpos() function', function() it('works in floating window with border', function() - local bufnr = meths.create_buf(false, true) local opts = { relative='editor', height=8, @@ -18,34 +18,56 @@ describe('screenpos() function', function() border='none', focusable=1 } - local float = meths.open_win(bufnr, false, opts) + local float = meths.open_win(meths.create_buf(false, true), false, opts) command('redraw') - local pos = funcs.screenpos(bufnr, 1, 1) - eq(7, pos.row) - eq(9, pos.col) + eq({row = 7, col = 9, endcol = 9, curscol = 9}, funcs.screenpos(float, 1, 1)) -- only left border opts.border = {'', '', '', '', '', '', '', '|'} meths.win_set_config(float, opts) command('redraw') - pos = funcs.screenpos(bufnr, 1, 1) - eq(7, pos.row) - eq(10, pos.col) + eq({row = 7, col = 10, endcol = 10, curscol = 10}, funcs.screenpos(float, 1, 1)) -- only top border opts.border = {'', '_', '', '', '', '', '', ''} meths.win_set_config(float, opts) command('redraw') - pos = funcs.screenpos(bufnr, 1, 1) - eq(8, pos.row) - eq(9, pos.col) + eq({row = 8, col = 9, endcol = 9, curscol = 9}, funcs.screenpos(float, 1, 1)) -- both left and top border opts.border = 'single' meths.win_set_config(float, opts) command('redraw') - pos = funcs.screenpos(bufnr, 1, 1) - eq(8, pos.row) - eq(10, pos.col) + eq({row = 8, col = 10, endcol = 10, curscol = 10}, funcs.screenpos(float, 1, 1)) + end) + + it('works for folded line with virt_lines attached to line above', function() + meths.buf_set_lines(0, 0, -1, true, {'aaa', 'bbb', 'ccc', 'ddd'}) + local ns = meths.create_namespace('') + meths.buf_set_extmark(0, ns, 0, 0, { virt_lines = {{{'abb'}}, {{'acc'}}, {{'add'}}} }) + command('2,3fold') + eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1)) + eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1)) + eq({row = 6, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1)) + + feed('<C-E>') + eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1)) + eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1)) + eq({row = 5, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1)) + + feed('<C-E>') + eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1)) + eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1)) + eq({row = 4, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1)) + + feed('<C-E>') + eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1)) + eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1)) + eq({row = 3, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1)) + + feed('<C-E>') + eq({row = 1, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 2, 1)) + eq({row = 1, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 3, 1)) + eq({row = 2, col = 1, endcol = 1, curscol = 1}, funcs.screenpos(0, 4, 1)) end) end) |