diff options
Diffstat (limited to 'test/functional')
25 files changed, 971 insertions, 114 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index df9092fa14..bf9e952319 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -630,19 +630,19 @@ describe('api/buf', function() eq('Index out of bounds', pcall_err(get_offset, 6)) eq('Index out of bounds', pcall_err(get_offset, -1)) - meths.set_option_value('eol', false, {buf=0}) - meths.set_option_value('fixeol', false, {buf=0}) + meths.set_option_value('eol', false, {}) + meths.set_option_value('fixeol', false, {}) eq(28, get_offset(5)) -- fileformat is ignored - meths.set_option_value('fileformat', 'dos', {buf=0}) + meths.set_option_value('fileformat', 'dos', {}) eq(0, get_offset(0)) eq(6, get_offset(1)) eq(15, get_offset(2)) eq(16, get_offset(3)) eq(24, get_offset(4)) eq(28, get_offset(5)) - meths.set_option_value('eol', true, {buf=0}) + meths.set_option_value('eol', true, {}) eq(29, get_offset(5)) command("set hidden") @@ -699,9 +699,9 @@ describe('api/buf', function() describe('nvim_get_option_value, nvim_set_option_value', function() it('works', function() - eq(8, nvim('get_option_value', 'shiftwidth', {buf = 0})) - nvim('set_option_value', 'shiftwidth', 4, {buf=0}) - eq(4, nvim('get_option_value', 'shiftwidth', {buf = 0})) + eq(8, nvim('get_option_value', 'shiftwidth', {})) + nvim('set_option_value', 'shiftwidth', 4, {}) + eq(4, nvim('get_option_value', 'shiftwidth', {})) -- global-local option nvim('set_option_value', 'define', 'test', {buf = 0}) eq('test', nvim('get_option_value', 'define', {buf = 0})) diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 0960e910f1..675c8332de 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1401,7 +1401,7 @@ describe('API/extmarks', function() it('in read-only buffer', function() command("view! runtime/doc/help.txt") - eq(true, meths.get_option_value('ro', {buf=0})) + eq(true, meths.get_option_value('ro', {})) local id = set_extmark(ns, 0, 0, 2) eq({{id, 0, 2}}, get_extmarks(ns,0, -1)) end) @@ -1474,7 +1474,7 @@ describe('API/extmarks', function() it('in prompt buffer', function() feed('dd') local id = set_extmark(ns, marks[1], 0, 0, {}) - meths.set_option_value('buftype', 'prompt', {buf = 0}) + meths.set_option_value('buftype', 'prompt', {}) feed('i<esc>') eq({{id, 0, 2}}, get_extmarks(ns, 0, -1)) end) diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 1601184e1b..d3a79327ae 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -596,4 +596,9 @@ describe('API: get highlight', function() eq({}, data["@foobar.hubbabubba"]) eq(nil, data["@foobar"]) end) + + it('should return default flag', function() + meths.set_hl(0, 'Tried', { fg = "#00ff00", default = true }) + eq({ fg = tonumber('00ff00', 16), default = true }, meths.get_hl(0, { name = 'Tried' })) + end) end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 5b8b52a559..040c26e058 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1397,7 +1397,7 @@ describe('API', function() it('works to set global value of local options', function() nvim('set_option_value', 'lisp', true, {scope='global'}) eq(true, nvim('get_option_value', 'lisp', {scope='global'})) - eq(false, nvim('get_option_value', 'lisp', {buf=0})) + eq(false, nvim('get_option_value', 'lisp', {})) eq(nil, nvim('command_output', 'setglobal lisp?'):match('nolisp')) eq('nolisp', nvim('command_output', 'setlocal lisp?'):match('nolisp')) nvim('set_option_value', 'shiftwidth', 20, {scope='global'}) @@ -1493,7 +1493,7 @@ describe('API', function() end) it('set window options', function() - nvim('set_option_value', 'colorcolumn', '4,3', {win=0}) + nvim('set_option_value', 'colorcolumn', '4,3', {}) eq('4,3', nvim('get_option_value', 'colorcolumn', {scope = 'local'})) command("set modified hidden") command("enew") -- edit new buffer, window option is preserved diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 660fa4731e..a6d1807961 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -365,11 +365,11 @@ describe('API/win', function() describe('nvim_get_option_value, nvim_set_option_value', function() it('works', function() - nvim('set_option_value', 'colorcolumn', '4,3', {win=0}) - eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0})) + nvim('set_option_value', 'colorcolumn', '4,3', {}) + eq('4,3', nvim('get_option_value', 'colorcolumn', {})) command("set modified hidden") command("enew") -- edit new buffer, window option is preserved - eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0})) + eq('4,3', nvim('get_option_value', 'colorcolumn', {})) -- global-local option nvim('set_option_value', 'statusline', 'window-status', {win=0}) diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua index e3a39384a6..4134eed87e 100644 --- a/test/functional/ex_cmds/append_spec.lua +++ b/test/functional/ex_cmds/append_spec.lua @@ -43,7 +43,7 @@ local cmdtest = function(cmd, prep, ret1) eq(hisline, funcs.histget(':', -2)) eq(cmd, funcs.histget(':')) -- Test that command-line window was launched - eq('nofile', meths.get_option_value('buftype', {buf=0})) + eq('nofile', meths.get_option_value('buftype', {})) eq('n', funcs.mode(1)) feed('<CR>') eq('c', funcs.mode(1)) diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index f51e7c62cb..7522d4a99c 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -81,7 +81,7 @@ describe(':mksession', function() local buf_count = #meths.list_bufs() eq(2, buf_count) - eq('terminal', meths.get_option_value('buftype', { buf = 0 })) + eq('terminal', meths.get_option_value('buftype', {})) test_terminal_session_disabled(2) @@ -112,7 +112,7 @@ describe(':mksession', function() it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function() command('terminal') - eq('terminal', meths.get_option_value('buftype', { buf = 0 })) + eq('terminal', meths.get_option_value('buftype', {})) local buf_count = #meths.list_bufs() eq(1, buf_count) @@ -120,7 +120,7 @@ describe(':mksession', function() test_terminal_session_disabled(1) -- no terminal should be set - eq('', meths.get_option_value('buftype', { buf = 0 })) + eq('', meths.get_option_value('buftype', {})) end) it('restores tab-local working directories', function() diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua index f44ba10f7f..25d0dcb81e 100644 --- a/test/functional/legacy/012_directory_spec.lua +++ b/test/functional/legacy/012_directory_spec.lua @@ -58,7 +58,7 @@ describe("'directory' option", function() end of testfile]]) meths.set_option_value('swapfile', true, {}) - meths.set_option_value('swapfile', true, {buf=0}) + meths.set_option_value('swapfile', true, {}) meths.set_option_value('directory', '.', {}) -- sanity check: files should not exist yet. @@ -83,7 +83,7 @@ describe("'directory' option", function() meths.set_option_value('directory', 'Xtest.je', {}) command('bdelete') command('edit Xtest2/Xtest3') - eq(true, meths.get_option_value('swapfile', {buf=0})) + eq(true, meths.get_option_value('swapfile', {})) poke_eventloop() eq({ "Xtest3" }, ls_dir_sorted("Xtest2")) diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 64cb524e99..d415b708be 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -415,7 +415,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('opening lines', function() local check_events = setup_eventcheck(verify, origlines) - -- meths.set_option_value('autoindent', true, { buf = 0 }) + -- meths.set_option_value('autoindent', true, {}) feed 'Go' check_events { { "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 1 }; @@ -428,7 +428,7 @@ describe('lua: nvim_buf_attach on_bytes', function() it('opening lines with autoindent', function() local check_events = setup_eventcheck(verify, origlines) - meths.set_option_value('autoindent', true, { buf = 0 }) + meths.set_option_value('autoindent', true, {}) feed 'Go' check_events { { "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 5 }; @@ -462,8 +462,8 @@ describe('lua: nvim_buf_attach on_bytes', function() it('continuing comments with fo=or', function() local check_events = setup_eventcheck(verify, {'// Comment'}) - meths.set_option_value('formatoptions', 'ro', { buf = 0 }) - meths.set_option_value('filetype', 'c', { buf = 0 }) + meths.set_option_value('formatoptions', 'ro', {}) + meths.set_option_value('filetype', 'c', {}) feed 'A<CR>' check_events { { "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 }; diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua index 4ea94796bc..b3d95e1c7f 100644 --- a/test/functional/lua/filetype_spec.lua +++ b/test/functional/lua/filetype_spec.lua @@ -134,6 +134,6 @@ end) describe('filetype.lua', function() it('does not override user autocommands that set filetype #20333', function() clear({args={'--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md'}}) - eq('notmarkdown', meths.get_option_value('filetype', { buf = 0 })) + eq('notmarkdown', meths.get_option_value('filetype', {})) end) end) diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua index 31da5db1df..dfbd2fb18b 100644 --- a/test/functional/lua/luaeval_spec.lua +++ b/test/functional/lua/luaeval_spec.lua @@ -514,7 +514,7 @@ describe('v:lua', function() [5] = {bold = true, foreground = Screen.colors.SeaGreen4}, }) screen:attach() - meths.set_option_value('omnifunc', 'v:lua.mymod.omni', { buf = 0 }) + meths.set_option_value('omnifunc', 'v:lua.mymod.omni', {}) feed('isome st<c-x><c-o>') screen:expect{grid=[[ some stuff^ | diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua index 72c99ac1f3..cd19ea4e49 100644 --- a/test/functional/lua/runtime_spec.lua +++ b/test/functional/lua/runtime_spec.lua @@ -61,6 +61,38 @@ describe('runtime:', function() eq('vim', eval('g:colorscheme')) end) + + it("loads lua colorscheme in 'rtp' if vim version only exists in 'pp' #23724", function() + local pack_dir = 'Test_Pack' + mkdir_p(pack_dir) + finally(function() + rmdir(pack_dir) + end) + exec('set pp+=' .. pack_dir) + + local pack_opt_dir = pack_dir .. sep .. 'pack' .. sep .. 'some_name' .. sep .. 'opt' + local colors_opt_dir = pack_opt_dir .. sep .. 'some_pack' .. sep .. 'colors' + mkdir_p(colors_opt_dir) + + local rtp_colorscheme_file = colorscheme_folder .. sep .. 'new_colorscheme' + local pp_opt_colorscheme_file = colors_opt_dir .. sep .. 'new_colorscheme' + + write_file(pp_opt_colorscheme_file .. '.lua', [[vim.g.colorscheme = 'lua_pp']]) + exec('colorscheme new_colorscheme') + eq('lua_pp', eval('g:colorscheme')) + + write_file(pp_opt_colorscheme_file .. '.vim', [[let g:colorscheme = 'vim_pp']]) + exec('colorscheme new_colorscheme') + eq('vim_pp', eval('g:colorscheme')) + + write_file(rtp_colorscheme_file .. '.lua', [[vim.g.colorscheme = 'lua_rtp']]) + exec('colorscheme new_colorscheme') + eq('lua_rtp', eval('g:colorscheme')) + + write_file(rtp_colorscheme_file .. '.vim', [[let g:colorscheme = 'vim_rtp']]) + exec('colorscheme new_colorscheme') + eq('vim_rtp', eval('g:colorscheme')) + end) end) describe('compiler', function() diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua index 9a6292a6c6..fc20a06390 100644 --- a/test/functional/lua/secure_spec.lua +++ b/test/functional/lua/secure_spec.lua @@ -160,7 +160,7 @@ describe('vim.secure', function() -- Cannot write file pcall_err(command, 'write') - eq(true, meths.get_option_value('readonly', {buf=0})) + eq(true, meths.get_option_value('readonly', {})) end) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 9a7654d610..978a4fe0b6 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1496,7 +1496,7 @@ describe('lua stdlib', function() it('vim.bo', function() eq('', funcs.luaeval "vim.bo.filetype") exec_lua [[ - vim.api.nvim_set_option_value("filetype", "markdown", {buf = 0}) + vim.api.nvim_set_option_value("filetype", "markdown", {}) BUF = vim.api.nvim_create_buf(false, true) vim.api.nvim_set_option_value("modifiable", false, {buf = BUF}) ]] @@ -1519,9 +1519,9 @@ describe('lua stdlib', function() it('vim.wo', function() exec_lua [[ - vim.api.nvim_set_option_value("cole", 2, {win=0}) + vim.api.nvim_set_option_value("cole", 2, {}) vim.cmd "split" - vim.api.nvim_set_option_value("cole", 2, {win=0}) + vim.api.nvim_set_option_value("cole", 2, {}) ]] eq(2, funcs.luaeval "vim.wo.cole") exec_lua [[ diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua index 1dca464d74..724b3efb97 100644 --- a/test/functional/plugin/lsp/incremental_sync_spec.lua +++ b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -21,7 +21,7 @@ before_each(function () -- ["mac"] = '\r', -- } - -- local line_ending = format_line_ending[vim.api.nvim_get_option_value('fileformat', {buf=0})] + -- local line_ending = format_line_ending[vim.api.nvim_get_option_value('fileformat', {})] function test_register(bufnr, id, offset_encoding, line_ending) diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua index 43222f1904..8d37100607 100644 --- a/test/functional/plugin/shada_spec.lua +++ b/test/functional/plugin/shada_spec.lua @@ -2181,8 +2181,8 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "a"', }, nvim_eval('getline(1, "$")')) - eq(false, nvim('get_option_value', 'modified', {buf=0})) - eq('shada', nvim('get_option_value', 'filetype', {buf=0})) + eq(false, nvim('get_option_value', 'modified', {})) + eq('shada', nvim('get_option_value', 'filetype', {})) nvim_command('edit ' .. fname_tmp) eq({ 'History entry with timestamp ' .. epoch .. ':', @@ -2191,8 +2191,8 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "b"', }, nvim_eval('getline(1, "$")')) - eq(false, nvim('get_option_value', 'modified', {buf=0})) - eq('shada', nvim('get_option_value', 'filetype', {buf=0})) + eq(false, nvim('get_option_value', 'modified', {})) + eq('shada', nvim('get_option_value', 'filetype', {})) eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname)) neq({ 'History entry with timestamp ' .. epoch .. ':', @@ -2201,7 +2201,7 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "a"', }, nvim_eval('getline(1, "$")')) - neq(true, nvim('get_option_value', 'modified', {buf=0})) + neq(true, nvim('get_option_value', 'modified', {})) end) it('event FileReadCmd', function() @@ -2217,8 +2217,8 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "a"', }, nvim_eval('getline(1, "$")')) - eq(true, nvim('get_option_value', 'modified', {buf=0})) - neq('shada', nvim('get_option_value', 'filetype', {buf=0})) + eq(true, nvim('get_option_value', 'modified', {})) + neq('shada', nvim('get_option_value', 'filetype', {})) nvim_command('1,$read ' .. fname_tmp) eq({ '', @@ -2233,9 +2233,9 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "b"', }, nvim_eval('getline(1, "$")')) - eq(true, nvim('get_option_value', 'modified', {buf=0})) - neq('shada', nvim('get_option_value', 'filetype', {buf=0})) - nvim('set_option_value', 'modified', false, {buf=0}) + eq(true, nvim('get_option_value', 'modified', {})) + neq('shada', nvim('get_option_value', 'filetype', {})) + nvim('set_option_value', 'modified', false, {}) eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname)) eq({ '', @@ -2250,7 +2250,7 @@ describe('plugin/shada.vim', function() ' - contents "ab"', ' - "b"', }, nvim_eval('getline(1, "$")')) - neq(true, nvim('get_option_value', 'modified', {buf=0})) + neq(true, nvim('get_option_value', 'modified', {})) end) it('event BufWriteCmd', function() @@ -2517,10 +2517,10 @@ describe('ftplugin/shada.vim', function() it('sets options correctly', function() nvim_command('filetype plugin indent on') nvim_command('setlocal filetype=shada') - eq(true, nvim('get_option_value', 'expandtab', {buf=0})) - eq(2, nvim('get_option_value', 'tabstop', {buf=0})) - eq(2, nvim('get_option_value', 'softtabstop', {buf=0})) - eq(2, nvim('get_option_value', 'shiftwidth', {buf=0})) + eq(true, nvim('get_option_value', 'expandtab', {})) + eq(2, nvim('get_option_value', 'tabstop', {})) + eq(2, nvim('get_option_value', 'softtabstop', {})) + eq(2, nvim('get_option_value', 'shiftwidth', {})) end) it('sets indentkeys correctly', function() diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua index bc7261895d..8049f0f3e2 100644 --- a/test/functional/provider/perl_spec.lua +++ b/test/functional/provider/perl_spec.lua @@ -45,7 +45,7 @@ describe('legacy perl provider', function() -- :perldo 1; doesn't change $_, -- the buffer should not be changed command('normal :perldo 1;') - eq(false, meths.get_option_value('modified', {buf=0})) + eq(false, meths.get_option_value('modified', {})) -- insert some text insert('abc\ndef\nghi') expect([[ diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua index 40ace28c4e..d3b967dfbe 100644 --- a/test/functional/provider/ruby_spec.lua +++ b/test/functional/provider/ruby_spec.lua @@ -97,7 +97,7 @@ describe(':rubydo command', function() it('does not modify the buffer if no changes are made', function() command('normal :rubydo 42') - eq(false, meths.get_option_value('modified', {buf=0})) + eq(false, meths.get_option_value('modified', {})) end) end) diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index 2740eeeca6..b1c4ded541 100644 --- a/test/functional/shada/buffers_spec.lua +++ b/test/functional/shada/buffers_spec.lua @@ -48,7 +48,7 @@ describe('shada support code', function() reset('set shada+=%') nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename_2) - meths.set_option_value('buflisted', false, {buf=0}) + meths.set_option_value('buflisted', false, {}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) @@ -60,7 +60,7 @@ describe('shada support code', function() reset('set shada+=%') nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename_2) - meths.set_option_value('buftype', 'quickfix', {buf=0}) + meths.set_option_value('buftype', 'quickfix', {}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 48a9fa7171..5d3e55d898 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -401,7 +401,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, "['sh']", 30) end - meths.set_option_value('scrollback', 0, {buf = 0}) + meths.set_option_value('scrollback', 0, {}) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) screen:expect{any='30: line '} retry(nil, nil, function() expect_lines(7) end) @@ -417,7 +417,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, "['sh']", 30) end - meths.set_option_value('scrollback', 200, {buf=0}) + meths.set_option_value('scrollback', 200, {}) -- Wait for prompt. screen:expect{any='%$'} @@ -426,10 +426,10 @@ describe("'scrollback' option", function() screen:expect{any='30: line '} retry(nil, nil, function() expect_lines(33, 2) end) - meths.set_option_value('scrollback', 10, {buf=0}) + meths.set_option_value('scrollback', 10, {}) poke_eventloop() retry(nil, nil, function() expect_lines(16) end) - meths.set_option_value('scrollback', 10000, {buf=0}) + meths.set_option_value('scrollback', 10000, {}) retry(nil, nil, function() expect_lines(16) end) -- Terminal job data is received asynchronously, may happen before the -- 'scrollback' option is synchronized with the internal sb_buffer. @@ -484,18 +484,18 @@ describe("'scrollback' option", function() ]]) local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial - local scrollback = meths.get_option_value('scrollback', {buf=0}) + local scrollback = meths.get_option_value('scrollback', {}) eq(scrollback + term_height, eval('line("$")')) -- Reduction scrollback = scrollback - 2 - meths.set_option_value('scrollback', scrollback, {buf=0}) + meths.set_option_value('scrollback', scrollback, {}) eq(scrollback + term_height, eval('line("$")')) end) it('defaults to 10000 in :terminal buffers', function() set_fake_shell() command('terminal') - eq(10000, meths.get_option_value('scrollback', {buf=0})) + eq(10000, meths.get_option_value('scrollback', {})) end) it('error if set to invalid value', function() @@ -507,7 +507,7 @@ describe("'scrollback' option", function() it('defaults to -1 on normal buffers', function() command('new') - eq(-1, meths.get_option_value('scrollback', {buf=0})) + eq(-1, meths.get_option_value('scrollback', {})) end) it(':setlocal in a :terminal buffer', function() @@ -516,45 +516,45 @@ describe("'scrollback' option", function() -- _Global_ scrollback=-1 defaults :terminal to 10_000. command('setglobal scrollback=-1') command('terminal') - eq(10000, meths.get_option_value('scrollback', {buf=0})) + eq(10000, meths.get_option_value('scrollback', {})) -- _Local_ scrollback=-1 in :terminal forces the _maximum_. command('setlocal scrollback=-1') retry(nil, nil, function() -- Fixup happens on refresh, not immediately. - eq(100000, meths.get_option_value('scrollback', {buf=0})) + eq(100000, meths.get_option_value('scrollback', {})) end) -- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605 command('setglobal scrollback=-1') command('autocmd TermOpen * setlocal scrollback=-1') command('terminal') - eq(100000, meths.get_option_value('scrollback', {buf=0})) + eq(100000, meths.get_option_value('scrollback', {})) end) it(':setlocal in a normal buffer', function() command('new') -- :setlocal to -1. command('setlocal scrollback=-1') - eq(-1, meths.get_option_value('scrollback', {buf=0})) + eq(-1, meths.get_option_value('scrollback', {})) -- :setlocal to anything except -1. Currently, this just has no effect. command('setlocal scrollback=42') - eq(42, meths.get_option_value('scrollback', {buf=0})) + eq(42, meths.get_option_value('scrollback', {})) end) it(':set updates local value and global default', function() set_fake_shell() command('set scrollback=42') -- set global value - eq(42, meths.get_option_value('scrollback', {buf=0})) + eq(42, meths.get_option_value('scrollback', {})) command('terminal') - eq(42, meths.get_option_value('scrollback', {buf=0})) -- inherits global default + eq(42, meths.get_option_value('scrollback', {})) -- inherits global default command('setlocal scrollback=99') - eq(99, meths.get_option_value('scrollback', {buf=0})) + eq(99, meths.get_option_value('scrollback', {})) command('set scrollback<') -- reset to global default - eq(42, meths.get_option_value('scrollback', {buf=0})) + eq(42, meths.get_option_value('scrollback', {})) command('setglobal scrollback=734') -- new global default - eq(42, meths.get_option_value('scrollback', {buf=0})) -- local value did not change + eq(42, meths.get_option_value('scrollback', {})) -- local value did not change command('terminal') - eq(734, meths.get_option_value('scrollback', {buf=0})) + eq(734, meths.get_option_value('scrollback', {})) end) end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 3cfd222336..1b65c1cddc 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1458,8 +1458,8 @@ describe('TUI', function() it('allows grid to assume wider ambiguous-width characters than host terminal #19686', function() child_session:request('nvim_buf_set_lines', 0, 0, -1, true, { ('℃'):rep(60), ('℃'):rep(60) }) - child_session:request('nvim_set_option_value', 'cursorline', true, {win=0}) - child_session:request('nvim_set_option_value', 'list', true, {win=0}) + child_session:request('nvim_set_option_value', 'cursorline', true, {}) + child_session:request('nvim_set_option_value', 'list', true, {}) child_session:request('nvim_set_option_value', 'listchars', 'eol:$', {win=0}) feed_data('gg') local singlewidth_screen = [[ diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index 3e1520e5fd..da14531fa2 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -71,7 +71,7 @@ describe(':terminal', function() end) it('does not change size if updated when not visible in any window #19665', function() - local channel = meths.get_option_value('channel', { buf = 0 }) + local channel = meths.get_option_value('channel', {}) command('enew') sleep(100) meths.chan_send(channel, 'foo') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 324362a865..e430865df6 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -611,6 +611,20 @@ describe('decorations providers', function() end) end) +local example_text = [[ +for _,item in ipairs(items) do + local text, hl_id_cell, count = unpack(item) + if hl_id_cell ~= nil then + hl_id = hl_id_cell + end + for _ = 1, (count or 1) do + local cell = line[colpos] + cell.text = text + cell.hl_id = hl_id + colpos = colpos+1 + end +end]] + describe('extmark decorations', function() local screen, ns before_each( function() @@ -650,20 +664,6 @@ describe('extmark decorations', function() ns = meths.create_namespace 'test' end) - local example_text = [[ -for _,item in ipairs(items) do - local text, hl_id_cell, count = unpack(item) - if hl_id_cell ~= nil then - hl_id = hl_id_cell - end - for _ = 1, (count or 1) do - local cell = line[colpos] - cell.text = text - cell.hl_id = hl_id - colpos = colpos+1 - end -end]] - it('empty virtual text at eol should not break colorcolumn #17860', function() insert(example_text) feed('gg') @@ -704,14 +704,14 @@ end]] -- can "float" beyond end of line meths.buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- bound check: right edge of window - meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork '}, {'bork bork bork', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) -- empty virt_text should not change anything meths.buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | {2:|} local text, hl_id_cell, count = unpack(item) | - {2:|} if hl_id_cell ~= nil tbork bork bork {4:bork bork}| + {2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork}| {2:|} {1:|} hl_id = hl_id_cell | {2:|} end | {2:|} for _ = 1, (count or 1) {4:loopy} | @@ -726,7 +726,6 @@ end]] | ]]} - -- handles broken lines screen:try_resize(22, 25) screen:expect{grid=[[ @@ -736,7 +735,7 @@ end]] cell, count = unpack(i| tem) | {2:|} if hl_id_cell ~= n| - il tbork bork bork {4:bor}| + il tbork bork bork{4: bor}| {2:|} {1:|} hl_id = hl_id_| cell | {2:|} end | @@ -756,6 +755,75 @@ end]] {1:~ }| | ]]} + + -- truncating in the middle of a char leaves a space + meths.buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) + meths.buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) + meths.buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + screen:expect{grid=[[ + ^for _,item in ipairs(i| + tems) do -- {4:A}AA 古 | + {2:|} local text, hl_id_| + cell, count = unpack(i| + tem) | + {2:|} if hl_id_cell ~= n| + il tbork bork bork{4: bor}| + {2:|} {1:|} hl_id = hl_id_| + cell | + {2:|} end | + {2:|} for _ = 1, (count | + or 1) {4:loopy} | + {2:|} {1:|} local cell = l| + ine[colpos] | + {2:|} {1:|} cell.text = te| + xt | + {2:|} {1:|} cell.hl_id = h| + l_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpo| + s+1 | + end -- ???????{4:口 }| + end -- {4:口口} 古古{4:口口 }| + {1:~ }| + {1:~ }| + | + ]]} + + screen:try_resize(82, 13) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do -- {4:A}AA 古 | + {2:|} local text, hl_id_cell, count = unpack(item) | + {2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork bork bork bork bork bork bork b}| + {2:|} {1:|} hl_id = hl_id_cell | + {2:|} end | + {2:|} for _ = 1, (count or 1) {4:loopy} | + {2:|} {1:|} local cell = line[colpos] | + {2:|} {1:|} cell.text = text | + {2:|} {1:|} cell.hl_id = hl_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | + end -- ???????{4:口口口} | + end -- {4:口口} 古古{4:口口口} | + | + ]]} + + meths.buf_clear_namespace(0, ns, 0, -1) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do -- 古古古 | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end -- ?????????? | + end -- ?古古古古?古古 | + | + ]]} end) it('can have virtual text of overlay position and styling', function() @@ -1165,7 +1233,744 @@ end]] meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) screen:expect_unchanged(true) end) +end) + +describe('decorations: inline virtual text', function() + local screen, ns + before_each( function() + clear() + screen = Screen.new(50, 10) + screen:attach() + screen:set_default_attr_ids { + [1] = {bold=true, foreground=Screen.colors.Blue}; + [2] = {foreground = Screen.colors.Brown}; + [3] = {bold = true, foreground = Screen.colors.SeaGreen}; + [4] = {background = Screen.colors.Red1, foreground = Screen.colors.Gray100}; + [5] = {background = Screen.colors.Red1, bold = true}; + [6] = {foreground = Screen.colors.DarkCyan}; + [7] = {background = Screen.colors.LightGrey}; + [8] = {bold = true}; + [9] = {background = Screen.colors.Plum1}; + [10] = {foreground = Screen.colors.SlateBlue}; + [11] = {blend = 30, background = Screen.colors.Red1}; + [12] = {background = Screen.colors.Yellow1}; + [13] = {reverse = true}; + [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; + [15] = {bold = true, reverse = true}; + } + + ns = meths.create_namespace 'test' + end) + + + it('works', function() + insert(example_text) + feed 'gg' + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + | + ]]} + + meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{10:: }{3:string}, hl_id_cell, count = unpack| + (item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + | + ]]} + + screen:try_resize(55, 10) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{10:: }{3:string}, hl_id_cell, count = unpack(item| + ) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + | + ]]} + + screen:try_resize(56, 10) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{10:: }{3:string}, hl_id_cell, count = unpack(item)| + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + | + ]]} + end) + + it('cursor positions are correct with multiple inline virtual text', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + feed '^' + feed '4l' + screen:expect { grid = [[ + 1234{10: virtual text virtual text }^5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('adjusts cursor location correctly when inserting around inline virtual text', function() + insert('12345678') + feed '$' + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + + screen:expect { grid = [[ + 1234{10: virtual text }567^8 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('has correct highlighting with multi-byte characters', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + + screen:expect { grid = [[ + 1234{10:múlti-byté chñröcters 修补}567^8 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('has correct cursor position when inserting around virtual text', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed '^' + feed '3l' + feed 'a' + screen:expect { grid = [[ + 1234{10:^virtual text}5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + feed '<ESC>' + screen:expect{grid=[[ + 123^4{10:virtual text}5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed '^' + feed '4l' + feed 'i' + screen:expect { grid = [[ + 1234{10:^virtual text}5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + end) + + it('has correct cursor position with virtual text on an empty line', function() + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + {10:^virtual text} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('text is drawn correctly when inserting a wrapping virtual text on an empty line', function() + feed('o<esc>') + insert([[aaaaaaa + +bbbbbbb]]) + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, + { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + feed('gg0') + screen:expect { grid = [[ + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + aaaaaaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + ^aaaaaaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + aaaaaaa | + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + aaaaaaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + ^bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('cursor position is correct with virtual text attached to hard tabs', function() + command('set noexpandtab') + feed('i') + feed('<TAB>') + feed('<TAB>') + feed('test') + feed('<ESC>') + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('0') + screen:expect { grid = [[ + ^ {10:virtual text} test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {10:virtual text} ^ test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {10:virtual text} ^test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {10:virtual text} t^est | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {10:virtual text} te^st | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('cursor position is correct with virtual text on an empty line', function() + command('set linebreak') + insert('one twoword') + feed('0') + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + ^one{10:: virtual text} twoword | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('search highlight is correct', function() + insert('foo foo foo foo') + feed('0') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + ^foo foo {10:virtual text}foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('/foo') + screen:expect { grid = [[ + {12:foo} {13:foo} {10:virtual text}{12:foo} {12:foo} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /foo^ | + ]]} + end) + + it('visual select highlight is correct', function() + insert('foo foo foo foo') + feed('0') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('8l') + screen:expect { grid = [[ + foo foo {10:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('v') + feed('2h') + screen:expect { grid = [[ + foo fo^o{7: }{10:virtual text}{7:f}oo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL --} | + ]]} + end) + + it('cursor position is correct when inserting around a virtual text with right gravity set to false', function() + insert('foo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('0') + feed('8l') + screen:expect { grid = [[ + foo foo {10:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('i') + screen:expect { grid = [[ + foo foo {10:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + end) + + it('cursor position is correct when inserting around virtual texts with both left and right gravity ', function() + insert('foo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + feed('08l') + screen:expect{ grid = [[ + foo foo {10:>><<}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('i') + screen:expect { grid = [[ + foo foo {10:>>^<<}foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + end) + + it('draws correctly with no wrap multiple virtual text, where one is hidden', function() + insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 50, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('$') + screen:expect { grid = [[ + opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('draws correctly with no wrap and a long virtual text', function() + insert('abcdefghi') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('$') + screen:expect { grid = [[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('tabs are the correct length with no wrap following virtual text', function() + command('set nowrap') + feed('itest<TAB>a<ESC>') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('gg$') + screen:expect { grid = [[ + {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('highlighting does not extend when no wrap is enabled with a long virtual text', function() + insert('abcdef') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + feed('$') + screen:expect { grid = [[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('highlighting is correct when virtual text wraps with number', function() + insert([[ + test + test]]) + command('set number') + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('gg0') + screen:expect { grid = [[ + {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {2: }{10:XXXXXXXXXX}est | + {2: 2 }test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('highlighting is correct when virtual text is proceeded with a match', function() + insert([[test]]) + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('gg0') + command('match ErrorMsg /e/') + screen:expect { grid = [[ + ^t{4:e}{10:virtual text}st | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + command('match ErrorMsg /s/') + screen:expect { grid = [[ + ^te{10:virtual text}{4:s}t | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('in diff mode is highlighted correct', function() + insert([[ + 9000 + 0009 + 0009 + 9000 + 0009 + ]]) + command("set diff") + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + command("vnew") + insert([[ + 000 + 000 + 000 + 000 + 000 + ]]) + command("set diff") + feed('gg0') + screen:expect { grid = [[ + {9:^000 }│{5:9}{14:test}{9:000 }| + {9:000 }│{9:000}{5:9}{9: }| + {9:000 }│{9:000}{5:9}{9: }| + {9:000 }│{5:9}{9:000 }| + {9:000 }│{9:000}{5:9}{9: }| + │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {15:[No Name] [+] }{13:[No Name] [+] }| + | + ]]} + end) + + it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() + command('set nowrap') + insert('a') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('$') + screen:expect { grid = [[ + {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('correctly draws when overflowing virtual text is followed by tab with no wrap', function() + command('set nowrap') + feed('i<TAB>test<ESC>') + meths.buf_set_extmark( + 0, + ns, + 0, + 0, + { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' } + ) + feed('0') + screen:expect({ + grid = [[ + {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], + }) + end) end) describe('decorations: virtual lines', function() @@ -1189,7 +1994,7 @@ describe('decorations: virtual lines', function() ns = meths.create_namespace 'test' end) - local example_text = [[ + local example_text2 = [[ if (h->n_buckets < new_n_buckets) { // expand khkey_t *new_keys = (khkey_t *)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); h->keys = new_keys; @@ -1200,7 +2005,7 @@ if (h->n_buckets < new_n_buckets) { // expand }]] it('works with one line', function() - insert(example_text) + insert(example_text2) feed 'gg' meths.buf_set_extmark(0, ns, 1, 33, { virt_lines={ {{">> ", "NonText"}, {"krealloc", "Identifier"}, {": change the size of an allocation"}}}; @@ -1309,7 +2114,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with text at the beginning of the buffer', function() - insert(example_text) + insert(example_text2) feed 'gg' screen:expect{grid=[[ @@ -1370,7 +2175,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with text at the end of the buffer', function() - insert(example_text) + insert(example_text2) feed 'G' screen:expect{grid=[[ @@ -1489,7 +2294,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works beyond end of the buffer with virt_lines_above', function() - insert(example_text) + insert(example_text2) feed 'G' screen:expect{grid=[[ @@ -1760,7 +2565,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with sign and numbercolumns', function() - insert(example_text) + insert(example_text2) feed 'gg' command 'set number signcolumn=yes' screen:expect{grid=[[ @@ -1826,7 +2631,7 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with hard tabs', function() - insert(example_text) + insert(example_text2) feed 'gg' meths.buf_set_extmark(0, ns, 1, 0, { virt_lines={ {{">>", "NonText"}, {"\tvery\ttabby", "Identifier"}, {"text\twith\ttabs"}}}; @@ -1910,10 +2715,10 @@ describe('decorations: signs', function() } ns = meths.create_namespace 'test' - meths.set_option_value('signcolumn', 'auto:9', {win = 0}) + meths.set_option_value('signcolumn', 'auto:9', {}) end) - local example_text = [[ + local example_test3 = [[ l1 l2 l3 @@ -1922,7 +2727,7 @@ l5 ]] it('can add a single sign (no end row)', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) @@ -1943,7 +2748,7 @@ l5 end) it('can add a single sign (with end row)', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) @@ -1965,7 +2770,7 @@ l5 it('can add multiple signs (single extmark)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) @@ -1987,7 +2792,7 @@ l5 it('can add multiple signs (multiple extmarks)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) @@ -2009,7 +2814,7 @@ l5 end) it('can add multiple signs (multiple extmarks) 2', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) @@ -2049,7 +2854,7 @@ l5 it('can add multiple signs (multiple extmarks) 3', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) @@ -2070,7 +2875,7 @@ l5 end) it('can add multiple signs (multiple extmarks) 4', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) @@ -2091,7 +2896,7 @@ l5 end) it('works with old signs', function() - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=x') @@ -2118,7 +2923,7 @@ l5 it('works with old signs (with range)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=x') @@ -2147,7 +2952,7 @@ l5 it('can add a ranged sign (with start out of view)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) command 'set signcolumn=yes:2' feed 'gg' feed '2<C-e>' @@ -2204,7 +3009,7 @@ l5 it('works with priority #19716', function() screen:try_resize(20, 3) - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=O3') @@ -2222,7 +3027,7 @@ l5 ]]} -- Check truncation works too - meths.set_option_value('signcolumn', 'auto', {win = 0}) + meths.set_option_value('signcolumn', 'auto', {}) screen:expect{grid=[[ S5^l1 | @@ -2233,8 +3038,8 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) - meths.set_option_value('signcolumn', 'auto', {win = 0}) - insert(example_text) + meths.set_option_value('signcolumn', 'auto', {}) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) screen:expect{grid=[[ diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 15819aef40..0f553d4a9b 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -254,4 +254,19 @@ describe("'spell'", function() ]]) end) + it('and syntax does not clear extmark highlighting at the start of a word', function() + screen:try_resize(43, 3) + command([[ + set spell + syntax match Constant "^.*$" + call setline(1, "This is some text without any spell errors.") + ]]) + local ns = meths.create_namespace("spell") + curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) + screen:expect([[ + {6:^This is some text without any spell errors.}| + {0:~ }| + | + ]]) + end) end) diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 2d6d4b8e04..2a5720fbd7 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -268,7 +268,7 @@ describe('setbufvar() function', function() end) it('may set options, including window-local and global values', function() local buf1 = meths.get_current_buf() - eq(false, meths.get_option_value('number', {win=0})) + eq(false, meths.get_option_value('number', {})) command('split') command('new') eq(2, bufmeths.get_number(curwinmeths.get_buf())) |