diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/extmark_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 56 | ||||
-rw-r--r-- | test/functional/lua/fs_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/plugin/man_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/terminal/edit_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/treesitter/highlight_spec.lua | 117 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 240 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 40 | ||||
-rw-r--r-- | test/unit/marktree_spec.lua | 106 |
10 files changed, 492 insertions, 117 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index a917432dab..c4449bc201 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -208,6 +208,23 @@ describe('API/extmarks', function() eq({}, get_extmarks(ns2, {0, 0}, {-1, -1})) end) + it('can undo with extmarks (#25147)', function() + feed('itest<esc>') + set_extmark(ns, 1, 0, 0) + set_extmark(ns, 2, 1, 0) + eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, {0, 0}, {-1, -1})) + feed('dd') + eq({ { 1, 1, 0 }, { 2, 1, 0 } }, get_extmarks(ns, {0, 0}, {-1, -1})) + curbufmeths.clear_namespace(ns, 0, -1) + eq({}, get_extmarks(ns, {0, 0}, {-1, -1})) + set_extmark(ns, 1, 0, 0, { right_gravity = false }) + set_extmark(ns, 2, 1, 0, { right_gravity = false }) + eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, {0, 0}, {-1, -1})) + feed('u') + eq({ { 1, 0, 0 }, { 2, 1, 0 } }, get_extmarks(ns, {0, 0}, {-1, -1})) + curbufmeths.clear_namespace(ns, 0, -1) + end) + it('querying for information and ranges', function() --marks = {1, 2, 3} --positions = {{0, 0,}, {0, 2}, {0, 3}} diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index c19891a794..51e4548edb 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -826,53 +826,53 @@ describe('lua: nvim_buf_attach on_bytes', function() feed("<esc>u") check_events { - { "test1", "bytes", 1, 8, 0, 0, 0, 0, 1, 1, 0, 4, 4 }, - { "test1", "bytes", 1, 8, 0, 0, 0, 0, 4, 4, 0, 0, 0 } + { "test1", "bytes", 1, 9, 0, 0, 0, 0, 1, 1, 0, 4, 4 }, + { "test1", "bytes", 1, 9, 0, 0, 0, 0, 4, 4, 0, 0, 0 } } -- in REPLACE mode feed("R<tab><tab>") check_events { - { "test1", "bytes", 1, 9, 0, 0, 0, 0, 1, 1, 0, 1, 1 }, - { "test1", "bytes", 1, 10, 0, 1, 1, 0, 0, 0, 0, 1, 1 }, - { "test1", "bytes", 1, 11, 0, 2, 2, 0, 1, 1, 0, 1, 1 }, - { "test1", "bytes", 1, 12, 0, 3, 3, 0, 0, 0, 0, 1, 1 }, - { "test1", "bytes", 1, 13, 0, 0, 0, 0, 4, 4, 0, 1, 1 }, + { "test1", "bytes", 1, 10, 0, 0, 0, 0, 1, 1, 0, 1, 1 }, + { "test1", "bytes", 1, 11, 0, 1, 1, 0, 0, 0, 0, 1, 1 }, + { "test1", "bytes", 1, 12, 0, 2, 2, 0, 1, 1, 0, 1, 1 }, + { "test1", "bytes", 1, 13, 0, 3, 3, 0, 0, 0, 0, 1, 1 }, + { "test1", "bytes", 1, 14, 0, 0, 0, 0, 4, 4, 0, 1, 1 }, } feed("<esc>u") check_events { - { "test1", "bytes", 1, 14, 0, 0, 0, 0, 1, 1, 0, 4, 4 }, - { "test1", "bytes", 1, 14, 0, 2, 2, 0, 2, 2, 0, 1, 1 }, - { "test1", "bytes", 1, 14, 0, 0, 0, 0, 2, 2, 0, 1, 1 } + { "test1", "bytes", 1, 16, 0, 0, 0, 0, 1, 1, 0, 4, 4 }, + { "test1", "bytes", 1, 16, 0, 2, 2, 0, 2, 2, 0, 1, 1 }, + { "test1", "bytes", 1, 16, 0, 0, 0, 0, 2, 2, 0, 1, 1 } } -- in VISUALREPLACE mode feed("gR<tab><tab>") check_events { - { "test1", "bytes", 1, 15, 0, 0, 0, 0, 1, 1, 0, 1, 1 }; - { "test1", "bytes", 1, 16, 0, 1, 1, 0, 1, 1, 0, 1, 1 }; - { "test1", "bytes", 1, 17, 0, 2, 2, 0, 1, 1, 0, 1, 1 }; - { "test1", "bytes", 1, 18, 0, 3, 3, 0, 1, 1, 0, 1, 1 }; - { "test1", "bytes", 1, 19, 0, 3, 3, 0, 1, 1, 0, 0, 0 }; - { "test1", "bytes", 1, 20, 0, 3, 3, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 22, 0, 2, 2, 0, 1, 1, 0, 0, 0 }; - { "test1", "bytes", 1, 23, 0, 2, 2, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 25, 0, 1, 1, 0, 1, 1, 0, 0, 0 }; - { "test1", "bytes", 1, 26, 0, 1, 1, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 28, 0, 0, 0, 0, 1, 1, 0, 0, 0 }; - { "test1", "bytes", 1, 29, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 31, 0, 0, 0, 0, 4, 4, 0, 1, 1 }; + { "test1", "bytes", 1, 17, 0, 0, 0, 0, 1, 1, 0, 1, 1 }; + { "test1", "bytes", 1, 18, 0, 1, 1, 0, 1, 1, 0, 1, 1 }; + { "test1", "bytes", 1, 19, 0, 2, 2, 0, 1, 1, 0, 1, 1 }; + { "test1", "bytes", 1, 20, 0, 3, 3, 0, 1, 1, 0, 1, 1 }; + { "test1", "bytes", 1, 21, 0, 3, 3, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 22, 0, 3, 3, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 24, 0, 2, 2, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 25, 0, 2, 2, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 27, 0, 1, 1, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 28, 0, 1, 1, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 30, 0, 0, 0, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 33, 0, 0, 0, 0, 4, 4, 0, 1, 1 }; } -- inserting tab after other tabs command("set sw=4") feed("<esc>0a<tab>") check_events { - { "test1", "bytes", 1, 32, 0, 1, 1, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 33, 0, 2, 2, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 34, 0, 3, 3, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 35, 0, 4, 4, 0, 0, 0, 0, 1, 1 }; - { "test1", "bytes", 1, 36, 0, 1, 1, 0, 4, 4, 0, 1, 1 }; + { "test1", "bytes", 1, 34, 0, 1, 1, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 35, 0, 2, 2, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 36, 0, 3, 3, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 37, 0, 4, 4, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 38, 0, 1, 1, 0, 4, 4, 0, 1, 1 }; } end) diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 2c7b3ff324..6bdb9ed79d 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -1,4 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) +local uv = require('luv') local clear = helpers.clear local exec_lua = helpers.exec_lua @@ -288,11 +289,12 @@ describe('vim.fs', function() eq('/', exec_lua [[ return vim.fs.normalize('/') ]]) end) it('works with ~', function() - eq( exec_lua([[ - local home = ... - return home .. '/src/foo' - ]], is_os('win') and vim.fs.normalize(os.getenv('USERPROFILE')) or os.getenv('HOME') - ) , exec_lua [[ return vim.fs.normalize('~/src/foo') ]]) + eq( + exec_lua([[ + local home = ... + return home .. '/src/foo' + ]], vim.fs.normalize(uv.os_homedir())), + exec_lua [[ return vim.fs.normalize('~/src/foo') ]]) end) it('works with environment variables', function() local xdg_config_home = test_build_dir .. '/.config' diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 9338e95d10..1dfb9a5e10 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2257,8 +2257,8 @@ describe('lua stdlib', function() end) end) -- vim.opt - describe('opt_local', function() - it('should be able to append to an array list type option', function() + describe('vim.opt_local', function() + it('appends into global value when changing local option value', function() eq({ "foo,bar,baz,qux" }, exec_lua [[ local result = {} @@ -2273,6 +2273,19 @@ describe('lua stdlib', function() end) end) + describe('vim.opt_global', function() + it('gets current global option value', function() + eq({ "yes" }, exec_lua [[ + local result = {} + + vim.cmd "setglobal signcolumn=yes" + table.insert(result, vim.opt_global.signcolumn:get()) + + return result + ]]) + end) + end) + it('vim.cmd', function() exec_lua [[ vim.cmd "autocmd BufNew * ++once lua BUF = vim.fn.expand('<abuf>')" diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index d5c1a78fc8..815ddbc523 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -9,6 +9,7 @@ local matches = helpers.matches local write_file = helpers.write_file local tmpname = helpers.tmpname local eq = helpers.eq +local pesc = helpers.pesc local skip = helpers.skip local is_ci = helpers.is_ci @@ -189,7 +190,7 @@ describe(':Man', function() write_file(actual_file, '') local args = {nvim_prog, '--headless', '+:Man ' .. actual_file, '+q'} matches(('Error detected while processing command line:\r\n' .. - 'man.lua: "no manual entry for %s"'):format(actual_file), + 'man.lua: "no manual entry for %s"'):format(pesc(actual_file)), funcs.system(args, {''})) os.remove(actual_file) end) diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index db5dba7374..29361bc0fa 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -36,7 +36,6 @@ describe(':edit term://*', function() end) it("runs TermOpen early enough to set buffer-local 'scrollback'", function() - if helpers.skip(helpers.is_os('win')) then return end local columns, lines = 20, 4 local scr = get_screen(columns, lines) local rep = 97 diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index 0528370e2a..0aa0cdd6d6 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -85,6 +85,56 @@ void ui_refresh(void) } }]] +local injection_text_c = [[ +int x = INT_MAX; +#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) +#define foo void main() { \ + return 42; \ + } +]] + +local injection_grid_c = [[ + int x = INT_MAX; | + #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) | + #define foo void main() { \ | + return 42; \ | + } | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | +]] + +local injection_grid_expected_c = [[ + {3:int} x = {5:INT_MAX}; | + #define {5:READ_STRING}(x, y) ({3:char} *)read_string((x), ({3:size_t})(y)) | + #define foo {3:void} main() { \ | + {4:return} {5:42}; \ | + } | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | +]] + describe('treesitter highlighting (C)', function() local screen @@ -411,34 +461,9 @@ describe('treesitter highlighting (C)', function() end) it("supports injected languages", function() - insert([[ - int x = INT_MAX; - #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) - #define foo void main() { \ - return 42; \ - } - ]]) + insert(injection_text_c) - screen:expect{grid=[[ - int x = INT_MAX; | - #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) | - #define foo void main() { \ | - return 42; \ | - } | - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]} + screen:expect{grid=injection_grid_c} exec_lua [[ local parser = vim.treesitter.get_parser(0, "c", { @@ -448,26 +473,24 @@ describe('treesitter highlighting (C)', function() test_hl = highlighter.new(parser, {queries = {c = hl_query}}) ]] - screen:expect{grid=[[ - {3:int} x = {5:INT_MAX}; | - #define {5:READ_STRING}(x, y) ({3:char} *)read_string((x), ({3:size_t})(y)) | - #define foo {3:void} main() { \ | - {4:return} {5:42}; \ | - } | - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]} + screen:expect{grid=injection_grid_expected_c} + end) + + it("supports injecting by ft name in metadata['injection.language']", function() + insert(injection_text_c) + + screen:expect{grid=injection_grid_c} + + exec_lua [[ + vim.treesitter.language.register("c", "foo") + local parser = vim.treesitter.get_parser(0, "c", { + injections = {c = '(preproc_def (preproc_arg) @injection.content (#set! injection.language "fOO")) (preproc_function_def value: (preproc_arg) @injection.content (#set! injection.language "fOO"))'} + }) + local highlighter = vim.treesitter.highlighter + test_hl = highlighter.new(parser, {queries = {c = hl_query}}) + ]] + + screen:expect{grid=injection_grid_expected_c} end) it("supports overriding queries, like ", function() diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4262f7ce77..daa4b4bdb3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -692,6 +692,11 @@ describe('extmark decorations', function() [34] = {background = Screen.colors.Yellow}; [35] = {background = Screen.colors.Yellow, bold = true, foreground = Screen.colors.Blue}; [36] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.Red}; + [37] = {background = Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}; + [38] = {background = Screen.colors.LightBlue}; + [39] = {foreground = Screen.colors.Blue1, background = Screen.colors.LightCyan1, bold = true}; + [40] = {reverse = true}; + [41] = {bold = true, reverse = true}; } ns = meths.create_namespace 'test' @@ -859,6 +864,104 @@ describe('extmark decorations', function() ]]} end) + it('overlay virtual text works with wrapped lines #25158', function() + screen:try_resize(50, 6) + insert(('ab'):rep(100)) + for i = 0, 9 do + meths.buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + end + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {4:89}abababababababababababababababababababa{4:012345678}| + {4:9}babababababababababababababababababababababababab| + ababababababababababababababababababababababababa^b| + {1:~ }| + | + ]]} + + command('set showbreak=++') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}{4:789}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababa^b | + | + ]]} + + feed('2gkvg0') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}^a{18:babab}ababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('o') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}{18:ababa}^bababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('gk') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}aba^b{18:ababababababababababababababababababababab}| + {1:++}{18:a}{4:89}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('o') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}aba{18:bababababababababababababababababababababab}| + {1:++}^a{4:89}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('<Esc>$') + command('set number showbreak=') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:0123}| + {2: }{4:456789}abababababababababababababababababababa{4:0}| + {2: }{4:123456789}babababababababababababababababababab| + {2: }ababababababababababababababababababababababab| + {2: }abababababababa^b | + | + ]]} + + command('set cpoptions+=n') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:0123}| + {4:456789}abababababababababababababababababababa{4:01234}| + {4:56789}babababababababababababababababababababababab| + ababababababababababababababababababababababababab| + aba^b | + | + ]]} + + feed('0g$hi<Tab>') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:01} | + {4:^23456789}abababababababababababababababababababa{4:0}| + {4:123456789}babababababababababababababababababababab| + ababababababababababababababababababababababababab| + abababab | + {24:-- INSERT --} | + ]]} + end) + it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() screen:try_resize(50, 3) command('set nowrap') @@ -1028,12 +1131,12 @@ describe('extmark decorations', function() it('can have virtual text of right_align and fixed win_col position', function() insert(example_text) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) -- empty virt_text should not change anything @@ -1191,40 +1294,78 @@ describe('extmark decorations', function() | ]]} - command 'set cpoptions-=n nonumber nowrap' + command 'set cpoptions-=n nowrap' screen:expect{grid=[[ - for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| - if | - hl_id_cell ~= nil then {4:Much} {4:MUCH}| - --^ -- -- -- -- -- -- --{4:Error}- -- -- h{4:ERROR}| - end | - for _ = 1, (count or 1) do | - local cell = line[colpos] | - {1:-} cell.text = text {1:-}| - cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 } --^ -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + {2: 13 }end | {1:~ }| | ]]} - feed '8zl' + feed '12zl' screen:expect{grid=[[ - em in ipairs(items) do | - l text, hl_id_cell, count = unp{4:Very}item) {4:VERY}| - | - ll ~= nil then {4:Much} {4:MUCH}| - --^ -- -- -- -- -- -- -- -- -- -{4:Error}hl_id = h{4:ERROR}| - | - _ = 1, (count or 1) do | - local cell = line[colpos] | - cell{1:-}text = text {1:-}| - cell.hl_id = hl_id | - colpos = colpos+1 | - | + {2: 1 }n ipairs(items) do | + {2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| + {2: 3 } | + {2: 4 }= nil then {4:Much} {4:MUCH}| + {2: 5 }^- -- -- -- -- -- -- -- -- -- --{4:Error}d = h{4:ERROR}| + {2: 6 } | + {2: 7 }1, (count or 1) do | + {2: 8 }l cell = line[colpos] | + {2: 9 }.tex{1:-} = text {1:-}| + {2: 10 }.hl_id = hl_id | + {2: 11 }os = colpos+1 | + {2: 12 } | + {2: 13 } | + {1:~ }| | + ]]} + + feed('fhi<Tab>') + screen:expect{grid=[[ + {2: 1 }n ipairs(items) do | + {2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| + {2: 3 } | + {2: 4 }= nil then {4:Much} {4:MUCH}| + {2: 5 }- -- -- -- -- -- -- -- -- -- --{4:Error}^hl_id{4:ERROR}| + {2: 6 } | + {2: 7 }1, (count or 1) do | + {2: 8 }l cell = line[colpos] | + {2: 9 }.tex{1:-} = text {1:-}| + {2: 10 }.hl_id = hl_id | + {2: 11 }os = colpos+1 | + {2: 12 } | + {2: 13 } | + {1:~ }| + {24:-- INSERT --} | + ]]} + + feed('<Esc>0') + screen:expect{grid=[[ + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 }^ -- -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + {2: 13 }end | {1:~ }| | ]]} @@ -1236,20 +1377,21 @@ describe('extmark decorations', function() 22222 33333]]) command('1,2fold') - command('set nowrap') screen:try_resize(50, 3) feed('zb') -- XXX: the behavior of overlay virtual text at non-zero column is strange: -- 1. With 'wrap' it is never shown. -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) + meths.buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 3333^3 | | ]]} + command('set nowrap') + screen:expect_unchanged() feed('zl') screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| @@ -1270,6 +1412,38 @@ describe('extmark decorations', function() ]]} end) + it('virtual text works below diff filler lines', function() + screen:try_resize(53, 8) + insert([[ + aaaaa + bbbbb + ccccc + ddddd + eeeee]]) + command('rightbelow vnew') + insert([[ + bbbbb + ccccc + ddddd + eeeee]]) + command('windo diffthis') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) + screen:expect{grid=[[ + {37: }{38:aaaaa }│{37: }{39:------------------------}| + {37: }bbbbb │{37: }{28:AA}bbb {28:BB} {28:CC}| + {37: }ccccc │{37: }ccccc | + {37: }ddddd │{37: }ddddd | + {37: }eeeee │{37: }eeee^e | + {1:~ }│{1:~ }| + {40:[No Name] [+] }{41:[No Name] [+] }| + | + ]]} + command('windo set wrap') + screen:expect_unchanged() + end) + it('can have virtual text which combines foreground and background groups', function() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 4e2cee391a..e37b3ccb5f 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -415,6 +415,46 @@ describe('float window', function() eq(winids, eval('winids')) end) + it("open does not trigger BufEnter #15300", function() + local res = exec_lua[[ + local times = {} + local buf = vim.api.nvim_create_buf(fasle, true) + vim.api.nvim_create_autocmd('BufEnter', { + callback = function(opt) + if opt.buf == buf then + times[#times + 1] = 1 + end + end + }) + local win_id + local fconfig = { + relative = 'editor', + row = 10, + col = 10, + width = 10, + height = 10, + } + --enter is false doesn't trigger + win_id = vim.api.nvim_open_win(buf, false, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 0 and true or nil + + --enter is true trigger + win_id = vim.api.nvim_open_win(buf, true, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 2 and true or nil + + --enter is true and fconfig.noautocmd is true doesn't trigger + fconfig.noautocmd = true + win_id = vim.api.nvim_open_win(buf, true, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 2 and true or nil + + return times + ]] + eq({true, 1, true}, res) + end) + it('no crash with bufpos and non-existent window', function() command('new') local closed_win = meths.get_current_win().id diff --git a/test/unit/marktree_spec.lua b/test/unit/marktree_spec.lua index 32300c167c..97b97b47bb 100644 --- a/test/unit/marktree_spec.lua +++ b/test/unit/marktree_spec.lua @@ -366,6 +366,68 @@ describe('marktree', function() eq(0, tree[0].n_keys) end) + itp('works with intersections and marktree_splice', function() + local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit + + for i = 1,1000 do + put(tree, 1, i, false, 2, 1000-i, false) + if i % 10 == 1 then + check_intersections(tree) + end + end + + check_intersections(tree) + eq(2000, tree[0].n_keys) + ok(tree[0].root.level >= 2) + + for _ = 1,10 do + lib.marktree_splice(tree, 0, 0, 0, 100, 0, 0) + check_intersections(tree) + end + end) + + itp('marktree_move should preserve key order', function() + local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit + local iter = ffi.new("MarkTreeIter[1]") + local ids = {} + + -- new index and old index look the same, but still have to move becase + -- pos will get updated + table.insert(ids, put(tree, 1, 1, false, 1, 3, false)) + table.insert(ids, put(tree, 1, 3, false, 1, 3, false)) + table.insert(ids, put(tree, 1, 3, false, 1, 3, false)) + table.insert(ids, put(tree, 1, 3, false, 1, 3, false)) + + lib.marktree_lookup_ns(tree, ns, ids[3], false, iter) + lib.marktree_move(tree, iter, 1, 2) + + check_intersections(tree) + end) + + itp('works with intersections and marktree_move', function() + local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit + + local ids = {} + + for i = 1,1000 do + table.insert(ids, put(tree, 1, i, false, 2, 1000-i, false)) + if i % 10 == 1 then + check_intersections(tree) + end + end + + local iter = ffi.new("MarkTreeIter[1]") + for i = 1,1000 do + local which = i%2 + lib.marktree_lookup_ns(tree, ns, ids[i], which, iter) + lib.marktree_move(tree, iter, 1+which, 500+i) + if i % 10 == 1 then + check_intersections(tree) + end + end + + end) + itp('works with intersections with a even bigger tree', function() local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit @@ -435,4 +497,48 @@ describe('marktree', function() eq(0, tree[0].n_keys) end) + + itp('works with intersections with a even bigger tree and splice', function() + local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit + + -- too much overhead on ASAN + local size_factor = helpers.is_asan() and 3 or 10 + + local at_row = {} + for i = 1, 10 do + at_row[i] = {} + end + + local size = 1000*size_factor + local k = 1 + while k <= size do + for row1 = 1,9 do + for row2 = row1,10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2 + if k > size then + break + end + local id = put(tree, row1, k, false, row2, size-k, false) + for i = row1+1, row2 do + table.insert(at_row[i], id) + end + --if tree[0].root.level == 4 then error("kk"..k) end + if k % 100*size_factor == 1 or (k < 2000 and k%100 == 1) then + check_intersections(tree) + end + k = k + 1 + end + end + end + + eq(2*size, tree[0].n_keys) + ok(tree[0].root.level >= 3) + check_intersections(tree) + + for _ = 1,10 do + for j = 3, 8 do + lib.marktree_splice(tree, j, 0, 0, 200, 0, 0) + check_intersections(tree) + end + end + end) end) |