aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/extmark_spec.lua12
-rw-r--r--test/functional/api/highlight_spec.lua20
-rw-r--r--test/functional/api/vim_spec.lua43
-rw-r--r--test/functional/autocmd/focus_spec.lua2
-rw-r--r--test/functional/editor/meta_key_spec.lua16
-rw-r--r--test/functional/editor/mode_insert_spec.lua53
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua15
-rw-r--r--test/functional/ex_cmds/script_spec.lua2
-rw-r--r--test/functional/fixtures/autoload/provider/python3.vim (renamed from test/functional/fixtures/autoload/provider/python.vim)2
-rw-r--r--test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua1
-rw-r--r--test/functional/legacy/003_cindent_spec.lua4774
-rw-r--r--test/functional/legacy/expand_spec.lua129
-rw-r--r--test/functional/legacy/listchars_spec.lua81
-rw-r--r--test/functional/legacy/search_stat_spec.lua121
-rw-r--r--test/functional/legacy/visual_mode_spec.lua44
-rw-r--r--test/functional/lua/luaeval_spec.lua1
-rw-r--r--test/functional/lua/uri_spec.lua2
-rw-r--r--test/functional/lua/vim_spec.lua80
-rw-r--r--test/functional/lua/xdiff_spec.lua42
-rw-r--r--test/functional/plugin/health_spec.lua11
-rw-r--r--test/functional/provider/provider_spec.lua4
-rw-r--r--test/functional/provider/python3_spec.lua43
-rw-r--r--test/functional/provider/python_spec.lua123
-rw-r--r--test/functional/treesitter/parser_spec.lua15
-rw-r--r--test/functional/ui/bufhl_spec.lua2
-rw-r--r--test/functional/ui/input_spec.lua2
-rw-r--r--test/functional/ui/popupmenu_spec.lua91
-rw-r--r--test/functional/ui/screen_basic_spec.lua58
-rw-r--r--test/functional/vimscript/eval_spec.lua2
-rw-r--r--test/functional/vimscript/functions_spec.lua2
-rw-r--r--test/helpers.lua2
-rw-r--r--test/unit/buffer_spec.lua141
-rw-r--r--test/unit/path_spec.lua16
33 files changed, 834 insertions, 5118 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 3f79515949..3f96efd4ef 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1446,13 +1446,20 @@ describe('API/extmarks', function()
end_col = 0,
end_line = 1
})
- eq({ {1, 0, 0, { end_col = 0, end_row = 1 }} }, get_extmarks(ns, 0, -1, {details=true}))
+ eq({ {1, 0, 0, {
+ end_col = 0,
+ end_row = 1,
+ right_gravity = true,
+ end_right_gravity = false,
+ }} }, get_extmarks(ns, 0, -1, {details=true}))
end)
it('can get details', function()
set_extmark(ns, marks[1], 0, 0, {
end_col = 0,
end_row = 1,
+ right_gravity = false,
+ end_right_gravity = true,
priority = 0,
hl_eol = true,
hl_mode = "blend",
@@ -1472,6 +1479,8 @@ describe('API/extmarks', function()
eq({0, 0, {
end_col = 0,
end_row = 1,
+ right_gravity = false,
+ end_right_gravity = true,
priority = 0,
hl_eol = true,
hl_mode = "blend",
@@ -1484,6 +1493,7 @@ describe('API/extmarks', function()
virt_lines_leftcol = true,
} }, get_extmark_by_id(ns, marks[1], { details = true }))
eq({0, 0, {
+ right_gravity = true,
priority = 0,
virt_text = { { "text", "Statement" } },
virt_text_hide = false,
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 21e3094f8e..a74da6073a 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -3,6 +3,7 @@ local clear, nvim = helpers.clear, helpers.nvim
local Screen = require('test.functional.ui.screen')
local eq, eval = helpers.eq, helpers.eval
local command = helpers.command
+local exec_capture = helpers.exec_capture
local meths = helpers.meths
local funcs = helpers.funcs
local pcall_err = helpers.pcall_err
@@ -252,4 +253,23 @@ describe("API: set highlight", function()
eq(highlight3_result_gui, meths.get_hl_by_name('Test_hl', true))
eq(highlight3_result_cterm, meths.get_hl_by_name('Test_hl', false))
end)
+
+ it ("can set a highlight in the global namespace", function()
+ meths.set_hl(0, 'Test_hl', highlight2_config)
+ eq('Test_hl xxx cterm=underline,reverse ctermfg=8 ctermbg=15 gui=underline,reverse',
+ exec_capture('highlight Test_hl'))
+
+ meths.set_hl(0, 'Test_hl', { background = highlight_color.bg })
+ eq('Test_hl xxx guibg=#0032aa',
+ exec_capture('highlight Test_hl'))
+
+ meths.set_hl(0, 'Test_hl2', highlight3_config)
+ eq('Test_hl2 xxx cterm=undercurl,italic,reverse ctermfg=8 ctermbg=15 gui=bold,underline,undercurl,italic,reverse guifg=#ff0000 guibg=#0032aa',
+ exec_capture('highlight Test_hl2'))
+
+ -- Colors are stored exactly as they are defined.
+ meths.set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue'})
+ eq('Test_hl3 xxx guifg=bLue guibg=reD',
+ exec_capture('highlight Test_hl3'))
+ end)
end)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 201ba45803..937b6559de 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -333,6 +333,7 @@ describe('API', function()
describe('nvim_command_output', function()
it('does not induce hit-enter prompt', function()
+ nvim("ui_attach", 80, 20, {})
-- Induce a hit-enter prompt use nvim_input (non-blocking).
nvim('command', 'set cmdheight=1')
nvim('input', [[:echo "hi\nhi2"<CR>]])
@@ -1093,7 +1094,20 @@ describe('API', function()
eq({mode='n', blocking=false}, nvim("get_mode"))
end)
+ it("during press-enter prompt without UI returns blocking=false", function()
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ command("echom 'msg1'")
+ command("echom 'msg2'")
+ command("echom 'msg3'")
+ command("echom 'msg4'")
+ command("echom 'msg5'")
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ nvim("input", ":messages<CR>")
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end)
+
it("during press-enter prompt returns blocking=true", function()
+ nvim("ui_attach", 80, 20, {})
eq({mode='n', blocking=false}, nvim("get_mode"))
command("echom 'msg1'")
command("echom 'msg2'")
@@ -1117,6 +1131,7 @@ describe('API', function()
-- TODO: bug #6247#issuecomment-286403810
it("batched with input", function()
+ nvim("ui_attach", 80, 20, {})
eq({mode='n', blocking=false}, nvim("get_mode"))
command("echom 'msg1'")
command("echom 'msg2'")
@@ -2551,6 +2566,34 @@ describe('API', function()
'Should be truncated%<',
{ maxwidth = 15 }))
end)
+ it('supports ASCII fillchar', function()
+ eq({ str = 'a~~~b', width = 5 },
+ meths.eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 }))
+ end)
+ it('supports single-width multibyte fillchar', function()
+ eq({ str = 'a━━━b', width = 5 },
+ meths.eval_statusline('a%=b', { fillchar = '━', maxwidth = 5 }))
+ end)
+ it('rejects double-width fillchar', function()
+ eq('fillchar must be a single-width character',
+ pcall_err(meths.eval_statusline, '', { fillchar = '哦' }))
+ end)
+ it('rejects control character fillchar', function()
+ eq('fillchar must be a single-width character',
+ pcall_err(meths.eval_statusline, '', { fillchar = '\a' }))
+ end)
+ it('rejects multiple-character fillchar', function()
+ eq('fillchar must be a single-width character',
+ pcall_err(meths.eval_statusline, '', { fillchar = 'aa' }))
+ end)
+ it('rejects empty string fillchar', function()
+ eq('fillchar must be a single-width character',
+ pcall_err(meths.eval_statusline, '', { fillchar = '' }))
+ end)
+ it('rejects non-string fillchar', function()
+ eq('fillchar must be a single-width character',
+ pcall_err(meths.eval_statusline, '', { fillchar = 1 }))
+ end)
describe('highlight parsing', function()
it('works', function()
eq({
diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua
index 3f9a0ad09b..e3c9e1f9ee 100644
--- a/test/functional/autocmd/focus_spec.lua
+++ b/test/functional/autocmd/focus_spec.lua
@@ -56,7 +56,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
line 3 |
line 4 |
{5:xtest-foo }|
- "xtest-foo" 4L, 28C |
+ "xtest-foo" 4L, 28B |
{3:-- TERMINAL --} |
]]}
end)
diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua
index f811b8ae8d..8efcc81616 100644
--- a/test/functional/editor/meta_key_spec.lua
+++ b/test/functional/editor/meta_key_spec.lua
@@ -104,4 +104,20 @@ describe('meta-keys #8226 #13042', function()
eq({ 0, 2, 1, 0, }, funcs.getpos('.'))
eq('nt', eval('mode(1)'))
end)
+
+ it('ALT/META when recording a macro #13235', function()
+ feed('ifoo<CR>bar<CR>baz<Esc>gg0')
+ -- <M-"> is reinterpreted as <Esc>"
+ feed('qrviw"ayC// This is some text: <M-">apq')
+ expect([[
+ // This is some text: foo
+ bar
+ baz]])
+ -- Should not insert an extra double quote when replaying
+ feed('j0@rj0@@')
+ expect([[
+ // This is some text: foo
+ // This is some text: bar
+ // This is some text: baz]])
+ end)
end)
diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua
index f03508035d..528e228121 100644
--- a/test/functional/editor/mode_insert_spec.lua
+++ b/test/functional/editor/mode_insert_spec.lua
@@ -75,4 +75,57 @@ describe('insert-mode', function()
expect('hello oooworld')
end)
end)
+
+ describe('Ctrl-V', function()
+ it('supports entering the decimal value of a character', function()
+ feed('i<C-V>076<C-V>167')
+ expect('L§')
+ end)
+
+ it('supports entering the octal value of a character with "o"', function()
+ feed('i<C-V>o114<C-V>o247<Esc>')
+ expect('L§')
+ end)
+
+ it('supports entering the octal value of a character with "O"', function()
+ feed('i<C-V>O114<C-V>O247<Esc>')
+ expect('L§')
+ end)
+
+ it('supports entering the hexadecimal value of a character with "x"', function()
+ feed('i<C-V>x4c<C-V>xA7<Esc>')
+ expect('L§')
+ end)
+
+ it('supports entering the hexadecimal value of a character with "X"', function()
+ feed('i<C-V>X4c<C-V>XA7<Esc>')
+ expect('L§')
+ end)
+
+ it('supports entering the hexadecimal value of a character with "u"', function()
+ feed('i<C-V>u25ba<C-V>u25C7<Esc>')
+ expect('►◇')
+ end)
+
+ it('supports entering the hexadecimal value of a character with "U"', function()
+ feed('i<C-V>U0001f600<C-V>U0001F601<Esc>')
+ expect('😀😁')
+ end)
+
+ it('entering character by value is interrupted by invalid character', function()
+ feed('i<C-V>76c<C-V>76<C-F2><C-V>u3c0j<C-V>u3c0<M-F3><C-V>U1f600j<C-V>U1f600<D-F4><Esc>')
+ expect('LcL<C-F2>πjπ<M-F3>😀j😀<D-F4>')
+ end)
+
+ it('shows o, O, u, U, x, X, and digits with modifiers', function()
+ feed('i<C-V><M-o><C-V><D-o><C-V><M-O><C-V><D-O><Esc>')
+ expect('<M-o><D-o><M-O><D-O>')
+ feed('cc<C-V><M-u><C-V><D-u><C-V><M-U><C-V><D-U><Esc>')
+ expect('<M-u><D-u><M-U><D-U>')
+ feed('cc<C-V><M-x><C-V><D-x><C-V><M-X><C-V><D-X><Esc>')
+ expect('<M-x><D-x><M-X><D-X>')
+ feed('cc<C-V><M-1><C-V><D-2><C-V><M-7><C-V><D-8><Esc>')
+ expect('<M-1><D-2><M-7><D-8>')
+ end)
+ end)
end)
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 09eaa36686..aefcc53cab 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -5,6 +5,7 @@ local clear = helpers.clear
local command = helpers.command
local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
+local neq = helpers.neq
local funcs = helpers.funcs
local matches = helpers.matches
local pesc = helpers.pesc
@@ -30,7 +31,8 @@ describe(':mksession', function()
-- If the same :terminal is displayed in multiple windows, :mksession
-- should restore it as such.
- -- Create two windows showing the same :terminal buffer.
+ -- Create three windows: first two from top show same terminal, third -
+ -- another one (created earlier).
command('terminal')
command('split')
command('terminal')
@@ -43,8 +45,8 @@ describe(':mksession', function()
-- Restore session.
command('source '..session_file)
- eq({2,2,4},
- {funcs.winbufnr(1), funcs.winbufnr(2), funcs.winbufnr(3)})
+ eq(funcs.winbufnr(1), funcs.winbufnr(2))
+ neq(funcs.winbufnr(1), funcs.winbufnr(3))
end)
it('restores tab-local working directories', function()
@@ -91,12 +93,7 @@ describe(':mksession', function()
command('tabnext 1')
eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '1', funcs.expand('%:p'))
command('tabnext 2')
- -- :mksession stores paths using unix slashes, but Nvim doesn't adjust these
- -- for absolute paths in all cases yet. Absolute paths are used in the
- -- session file after :tcd, so we need to expect unix slashes here for now
- -- eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', funcs.expand('%:p'))
- eq(cwd_dir:gsub([[\]], '/') .. '/' .. tmpfile_base .. '2',
- funcs.expand('%:p'))
+ eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', funcs.expand('%:p'))
end)
it('restores CWD for :terminal buffers #11288', function()
diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua
index 0a772c559b..f249b9ba7c 100644
--- a/test/functional/ex_cmds/script_spec.lua
+++ b/test/functional/ex_cmds/script_spec.lua
@@ -62,10 +62,10 @@ describe('script_get-based command', function()
-- Provider-based scripts
test_garbage_exec('ruby', not missing_provider('ruby'))
- test_garbage_exec('python', not missing_provider('python'))
test_garbage_exec('python3', not missing_provider('python3'))
-- Missing scripts
+ test_garbage_exec('python', false)
test_garbage_exec('tcl', false)
test_garbage_exec('mzscheme', false)
test_garbage_exec('perl', false)
diff --git a/test/functional/fixtures/autoload/provider/python.vim b/test/functional/fixtures/autoload/provider/python3.vim
index d68360ac30..8ed4330a35 100644
--- a/test/functional/fixtures/autoload/provider/python.vim
+++ b/test/functional/fixtures/autoload/provider/python3.vim
@@ -1,6 +1,6 @@
" Dummy test provider, missing this required variable:
" let g:loaded_brokenenabled_provider = 0
-function! provider#python#Call(method, args)
+function! provider#python3#Call(method, args)
return 42
endfunction
diff --git a/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua b/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua
new file mode 100644
index 0000000000..c1c33d787e
--- /dev/null
+++ b/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua
@@ -0,0 +1 @@
+return {doit=function() return 9004 end}
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
deleted file mode 100644
index 061904c42f..0000000000
--- a/test/functional/legacy/003_cindent_spec.lua
+++ /dev/null
@@ -1,4774 +0,0 @@
--- Test for 'cindent'.
--- For new tests, consider putting them in test_cindent.vim.
---
--- There are 50+ test command blocks (the stuff between STARTTEST and ENDTEST)
--- in the original test. These have been converted to "it" test cases here.
-
-local helpers = require('test.functional.helpers')(after_each)
-local feed, insert = helpers.feed, helpers.insert
-local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
-
--- Inserts text as usual, and additionally positions the cursor on line 1 and
--- sets 'cindent' and tab settings. (In the original "test3.in" the modeline at
--- the top of the file takes care of this.)
-local function insert_(content)
- insert(content)
- feed_command('1', 'set cin ts=4 sw=4')
-end
-
--- luacheck: ignore 621 (Indentation)
--- luacheck: ignore 613 (Trailing whitespace in a string)
-describe('cindent', function()
- before_each(clear)
-
- it('1 is working', function()
- insert_([=[
-
- /* start of AUTO matically checked vim: set ts=4 : */
- {
- if (test)
- cmd1;
- cmd2;
- }
-
- {
- if (test)
- cmd1;
- else
- cmd2;
- }
-
- {
- if (test)
- {
- cmd1;
- cmd2;
- }
- }
-
- {
- if (test)
- {
- cmd1;
- else
- }
- }
-
- {
- while (this)
- if (test)
- cmd1;
- cmd2;
- }
-
- {
- while (this)
- if (test)
- cmd1;
- else
- cmd2;
- }
-
- {
- if (test)
- {
- cmd;
- }
-
- if (test)
- cmd;
- }
-
- {
- if (test) {
- cmd;
- }
-
- if (test) cmd;
- }
-
- {
- cmd1;
- for (blah)
- while (this)
- if (test)
- cmd2;
- cmd3;
- }
-
- {
- cmd1;
- for (blah)
- while (this)
- if (test)
- cmd2;
- cmd3;
-
- if (test)
- {
- cmd1;
- cmd2;
- cmd3;
- }
- }
-
-
- /* Test for 'cindent' do/while mixed with if/else: */
-
- {
- do
- if (asdf)
- asdfasd;
- while (cond);
-
- do
- if (asdf)
- while (asdf)
- asdf;
- while (asdf);
- }
-
- /* Test for 'cindent' with two ) on a continuation line */
- {
- if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
- aal;sdkjf ( ;asldfkja;sldfk
- al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
- line up here;
- }
-
-
- /* C++ tests: */
-
- // foo() these three lines should remain in column 0
- // {
- // }
-
- /* Test for continuation and unterminated lines: */
- {
- i = 99 + 14325 +
- 21345 +
- 21345 +
- 21345 + ( 21345 +
- 21345) +
- 2345 +
- 1234;
- c = 1;
- }
-
- /*
- testje for indent with empty line
-
- here */
-
- {
- if (testing &&
- not a joke ||
- line up here)
- hay;
- if (testing &&
- (not a joke || testing
- )line up here)
- hay;
- if (testing &&
- (not a joke || testing
- line up here))
- hay;
- }
-
-
- {
- switch (c)
- {
- case xx:
- do
- if (asdf)
- do
- asdfasdf;
- while (asdf);
- else
- asdfasdf;
- while (cond);
- case yy:
- case xx:
- case zz:
- testing;
- }
- }
-
- {
- if (cond) {
- foo;
- }
- else
- {
- bar;
- }
- }
-
- {
- if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
- alsdkfj (asldk;fj
- awith cino=(0 ;lf this one goes to below the paren with ==
- ;laksjfd ;lsakdjf ;alskdf asd)
- asdfasdf;)))
- asdfasdf;
- }
-
- int
- func(a, b)
- int a;
- int c;
- {
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3)
- )
- }
-
- {
- while (asd)
- {
- if (asdf)
- if (test)
- if (that)
- {
- if (asdf)
- do
- cdasd;
- while (as
- df);
- }
- else
- if (asdf)
- asdf;
- else
- asdf;
- asdf;
- }
- }
-
- {
- s = "/*"; b = ';'
- s = "/*"; b = ';';
- a = b;
- }
-
- {
- switch (a)
- {
- case a:
- switch (t)
- {
- case 1:
- cmd;
- break;
- case 2:
- cmd;
- break;
- }
- cmd;
- break;
- case b:
- {
- int i;
- cmd;
- }
- break;
- case c: {
- int i;
- cmd;
- }
- case d: if (cond &&
- test) { /* this line doesn't work right */
- int i;
- cmd;
- }
- break;
- }
- }
-
- {
- if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
- (bp_to->b_p_initialized ||
- (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
- return;
- label :
- asdf = asdf ?
- asdf : asdf;
- asdf = asdf ?
- asdf: asdf;
- }
-
- /* Special Comments : This function has the added complexity (compared */
- /* : to addtolist) of having to check for a detail */
- /* : texture and add that to the list first. */
-
- char *(array[100]) = {
- "testje",
- "foo",
- "bar",
- }
-
- enum soppie
- {
- yes = 0,
- no,
- maybe
- };
-
- typedef enum soppie
- {
- yes = 0,
- no,
- maybe
- };
-
- static enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- public static enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- static private enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- {
- int a,
- b;
- }
-
- {
- struct Type
- {
- int i;
- char *str;
- } var[] =
- {
- 0, "zero",
- 1, "one",
- 2, "two",
- 3, "three"
- };
-
- float matrix[3][3] =
- {
- {
- 0,
- 1,
- 2
- },
- {
- 3,
- 4,
- 5
- },
- {
- 6,
- 7,
- 8
- }
- };
- }
-
- {
- /* blah ( blah */
- /* where does this go? */
-
- /* blah ( blah */
- cmd;
-
- func(arg1,
- /* comment */
- arg2);
- a;
- {
- b;
- {
- c; /* Hey, NOW it indents?! */
- }
- }
-
- {
- func(arg1,
- arg2,
- arg3);
- /* Hey, what am I doing here? Is this coz of the ","? */
- }
- }
-
- main ()
- {
- if (cond)
- {
- a = b;
- }
- if (cond) {
- a = c;
- }
- if (cond)
- a = d;
- return;
- }
-
- {
- case 2: if (asdf &&
- asdfasdf)
- aasdf;
- a = 9;
- case 3: if (asdf)
- aasdf;
- a = 9;
- case 4: x = 1;
- y = 2;
-
- label: if (asdf)
- here;
-
- label: if (asdf &&
- asdfasdf)
- {
- }
-
- label: if (asdf &&
- asdfasdf) {
- there;
- }
-
- label: if (asdf &&
- asdfasdf)
- there;
- }
-
- {
- /*
- hello with ":set comments= cino=c5"
- */
-
- /*
- hello with ":set comments= cino="
- */
- }
-
-
- {
- if (a < b) {
- a = a + 1;
- } else
- a = a + 2;
-
- if (a)
- do {
- testing;
- } while (asdfasdf);
- a = b + 1;
- asdfasdf
- }
-
- {
- for ( int i = 0;
- i < 10; i++ )
- {
- }
- i = 0;
- }
-
- class bob
- {
- int foo() {return 1;}
- int bar;
- }
-
- main()
- {
- while(1)
- if (foo)
- {
- bar;
- }
- else {
- asdf;
- }
- misplacedline;
- }
-
- {
- if (clipboard.state == SELECT_DONE
- && ((row == clipboard.start.lnum
- && col >= clipboard.start.col)
- || row > clipboard.start.lnum))
- }
-
- {
- if (1) {i += 4;}
- where_am_i;
- return 0;
- }
-
- {
- {
- } // sdf(asdf
- if (asdf)
- asd;
- }
-
- {
- label1:
- label2:
- }
-
- {
- int fooRet = foo(pBar1, false /*fKB*/,
- true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
- f() {
- for ( i = 0;
- i < m;
- /* c */ i++ ) {
- a = b;
- }
- }
- }
-
- {
- f1(/*comment*/);
- f2();
- }
-
- {
- do {
- if (foo) {
- } else
- ;
- } while (foo);
- foo(); // was wrong
- }
-
- int x; // no extra indent because of the ;
- void func()
- {
- }
-
- char *tab[] = {"aaa",
- "};", /* }; */ NULL}
- int indented;
- {}
-
- char *a[] = {"aaa", "bbb",
- "ccc", NULL};
- // here
-
- char *tab[] = {"aaa",
- "xx", /* xx */}; /* asdf */
- int not_indented;
-
- {
- do {
- switch (bla)
- {
- case 1: if (foo)
- bar;
- }
- } while (boo);
- wrong;
- }
-
- int foo,
- bar;
- int foo;
-
- #if defined(foo) \
- && defined(bar)
- char * xx = "asdf\
- foo\
- bor";
- int x;
-
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
-
- void f()
- {
- #if defined(foo) \
- && defined(bar)
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
- {
- int i;
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
- }
- #endif
- }
- #endif
-
- int y; // comment
- // comment
-
- // comment
-
- {
- Constructor(int a,
- int b ) : BaseClass(a)
- {
- }
- }
-
- void foo()
- {
- char one,
- two;
- struct bla piet,
- jan;
- enum foo kees,
- jannie;
- static unsigned sdf,
- krap;
- unsigned int piet,
- jan;
- int
- kees,
- jan;
- }
-
- {
- t(int f,
- int d); // )
- d();
- }
-
- Constructor::Constructor(int a,
- int b
- ) :
- BaseClass(a,
- b,
- c),
- mMember(b),
- {
- }
-
- Constructor::Constructor(int a,
- int b ) :
- BaseClass(a)
- {
- }
-
- Constructor::Constructor(int a,
- int b ) /*x*/ : /*x*/ BaseClass(a),
- member(b)
- {
- }
-
- A::A(int a, int b)
- : aa(a),
- bb(b),
- cc(c)
- {
- }
-
- class CAbc :
- public BaseClass1,
- protected BaseClass2
- {
- int Test() { return FALSE; }
- int Test1() { return TRUE; }
-
- CAbc(int a, int b ) :
- BaseClass(a)
- {
- switch(xxx)
- {
- case abc:
- asdf();
- break;
-
- case 999:
- baer();
- break;
- }
- }
-
- public: // <-- this was incoreectly indented before!!
- void testfall();
- protected:
- void testfall();
- };
-
- class CAbc : public BaseClass1,
- protected BaseClass2
- {
- };
-
- static struct
- {
- int a;
- int b;
- } variable[COUNT] =
- {
- {
- 123,
- 456
- },
- {
- 123,
- 456
- }
- };
-
- static struct
- {
- int a;
- int b;
- } variable[COUNT] =
- {
- { 123, 456 },
- { 123, 456 }
- };
-
- void asdf() /* ind_maxparen may cause trouble here */
- {
- if ((0
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1)) break;
- }
-
- foo()
- {
- a = cond ? foo() : asdf
- + asdf;
-
- a = cond ?
- foo() : asdf
- + asdf;
- }
-
- int main(void)
- {
- if (a)
- if (b)
- 2;
- else 3;
- next_line_of_code();
- }
-
- barry()
- {
- Foo::Foo (int one,
- int two)
- : something(4)
- {}
- }
-
- barry()
- {
- Foo::Foo (int one, int two)
- : something(4)
- {}
- }
-
- Constructor::Constructor(int a,
- int b
- ) :
- BaseClass(a,
- b,
- c),
- mMember(b)
- {
- }
- int main ()
- {
- if (lala)
- do
- ++(*lolo);
- while (lili
- && lele);
- lulu;
- }
-
- int main ()
- {
- switch (c)
- {
- case 'c': if (cond)
- {
- }
- }
- }
-
- main()
- {
- (void) MyFancyFuasdfadsfnction(
- argument);
- }
-
- main()
- {
- char foo[] = "/*";
- /* as
- df */
- hello
- }
-
- /* valid namespaces with normal indent */
- namespace
- {
- {
- 111111111111;
- }
- }
- namespace /* test */
- {
- 11111111111111111;
- }
- namespace // test
- {
- 111111111111111111;
- }
- namespace
- {
- 111111111111111111;
- }
- namespace test
- {
- 111111111111111111;
- }
- namespace{
- 111111111111111111;
- }
- namespace test{
- 111111111111111111;
- }
- namespace {
- 111111111111111111;
- }
- namespace test {
- 111111111111111111;
- namespace test2 {
- 22222222222222222;
- }
- }
-
- /* invalid namespaces use block indent */
- namespace test test2 {
- 111111111111111111111;
- }
- namespace11111111111 {
- 111111111111;
- }
- namespace() {
- 1111111111111;
- }
- namespace()
- {
- 111111111111111111;
- }
- namespace test test2
- {
- 1111111111111111111;
- }
- namespace111111111
- {
- 111111111111111111;
- }
- void getstring() {
- /* Raw strings */
- const char* s = R"(
- test {
- # comment
- field: 123
- }
- )";
- }
- void getstring() {
- const char* s = R"foo(
- test {
- # comment
- field: 123
- }
- )foo";
- }
-
- {
- int a[4] = {
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 3,
- };
- }
-
- {
- a = b[2]
- + 3;
- }
-
- {
- if (1)
- /* aaaaa
- * bbbbb
- */
- a = 1;
- }
-
- void func()
- {
- switch (foo)
- {
- case (bar):
- if (baz())
- quux();
- break;
- case (shmoo):
- if (!bar)
- {
- }
- case (foo1):
- switch (bar)
- {
- case baz:
- baz_f();
- break;
- }
- break;
- default:
- baz();
- baz();
- break;
- }
- }
-
- /* end of AUTO */
- ]=])
-
- feed_command('/start of AUTO')
- feed('=/end of AUTO<cr>')
-
- expect([=[
-
- /* start of AUTO matically checked vim: set ts=4 : */
- {
- if (test)
- cmd1;
- cmd2;
- }
-
- {
- if (test)
- cmd1;
- else
- cmd2;
- }
-
- {
- if (test)
- {
- cmd1;
- cmd2;
- }
- }
-
- {
- if (test)
- {
- cmd1;
- else
- }
- }
-
- {
- while (this)
- if (test)
- cmd1;
- cmd2;
- }
-
- {
- while (this)
- if (test)
- cmd1;
- else
- cmd2;
- }
-
- {
- if (test)
- {
- cmd;
- }
-
- if (test)
- cmd;
- }
-
- {
- if (test) {
- cmd;
- }
-
- if (test) cmd;
- }
-
- {
- cmd1;
- for (blah)
- while (this)
- if (test)
- cmd2;
- cmd3;
- }
-
- {
- cmd1;
- for (blah)
- while (this)
- if (test)
- cmd2;
- cmd3;
-
- if (test)
- {
- cmd1;
- cmd2;
- cmd3;
- }
- }
-
-
- /* Test for 'cindent' do/while mixed with if/else: */
-
- {
- do
- if (asdf)
- asdfasd;
- while (cond);
-
- do
- if (asdf)
- while (asdf)
- asdf;
- while (asdf);
- }
-
- /* Test for 'cindent' with two ) on a continuation line */
- {
- if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
- aal;sdkjf ( ;asldfkja;sldfk
- al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
- line up here;
- }
-
-
- /* C++ tests: */
-
- // foo() these three lines should remain in column 0
- // {
- // }
-
- /* Test for continuation and unterminated lines: */
- {
- i = 99 + 14325 +
- 21345 +
- 21345 +
- 21345 + ( 21345 +
- 21345) +
- 2345 +
- 1234;
- c = 1;
- }
-
- /*
- testje for indent with empty line
-
- here */
-
- {
- if (testing &&
- not a joke ||
- line up here)
- hay;
- if (testing &&
- (not a joke || testing
- )line up here)
- hay;
- if (testing &&
- (not a joke || testing
- line up here))
- hay;
- }
-
-
- {
- switch (c)
- {
- case xx:
- do
- if (asdf)
- do
- asdfasdf;
- while (asdf);
- else
- asdfasdf;
- while (cond);
- case yy:
- case xx:
- case zz:
- testing;
- }
- }
-
- {
- if (cond) {
- foo;
- }
- else
- {
- bar;
- }
- }
-
- {
- if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
- alsdkfj (asldk;fj
- awith cino=(0 ;lf this one goes to below the paren with ==
- ;laksjfd ;lsakdjf ;alskdf asd)
- asdfasdf;)))
- asdfasdf;
- }
-
- int
- func(a, b)
- int a;
- int c;
- {
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3)
- )
- }
-
- {
- while (asd)
- {
- if (asdf)
- if (test)
- if (that)
- {
- if (asdf)
- do
- cdasd;
- while (as
- df);
- }
- else
- if (asdf)
- asdf;
- else
- asdf;
- asdf;
- }
- }
-
- {
- s = "/*"; b = ';'
- s = "/*"; b = ';';
- a = b;
- }
-
- {
- switch (a)
- {
- case a:
- switch (t)
- {
- case 1:
- cmd;
- break;
- case 2:
- cmd;
- break;
- }
- cmd;
- break;
- case b:
- {
- int i;
- cmd;
- }
- break;
- case c: {
- int i;
- cmd;
- }
- case d: if (cond &&
- test) { /* this line doesn't work right */
- int i;
- cmd;
- }
- break;
- }
- }
-
- {
- if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
- (bp_to->b_p_initialized ||
- (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
- return;
- label :
- asdf = asdf ?
- asdf : asdf;
- asdf = asdf ?
- asdf: asdf;
- }
-
- /* Special Comments : This function has the added complexity (compared */
- /* : to addtolist) of having to check for a detail */
- /* : texture and add that to the list first. */
-
- char *(array[100]) = {
- "testje",
- "foo",
- "bar",
- }
-
- enum soppie
- {
- yes = 0,
- no,
- maybe
- };
-
- typedef enum soppie
- {
- yes = 0,
- no,
- maybe
- };
-
- static enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- public static enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- static private enum
- {
- yes = 0,
- no,
- maybe
- } soppie;
-
- {
- int a,
- b;
- }
-
- {
- struct Type
- {
- int i;
- char *str;
- } var[] =
- {
- 0, "zero",
- 1, "one",
- 2, "two",
- 3, "three"
- };
-
- float matrix[3][3] =
- {
- {
- 0,
- 1,
- 2
- },
- {
- 3,
- 4,
- 5
- },
- {
- 6,
- 7,
- 8
- }
- };
- }
-
- {
- /* blah ( blah */
- /* where does this go? */
-
- /* blah ( blah */
- cmd;
-
- func(arg1,
- /* comment */
- arg2);
- a;
- {
- b;
- {
- c; /* Hey, NOW it indents?! */
- }
- }
-
- {
- func(arg1,
- arg2,
- arg3);
- /* Hey, what am I doing here? Is this coz of the ","? */
- }
- }
-
- main ()
- {
- if (cond)
- {
- a = b;
- }
- if (cond) {
- a = c;
- }
- if (cond)
- a = d;
- return;
- }
-
- {
- case 2: if (asdf &&
- asdfasdf)
- aasdf;
- a = 9;
- case 3: if (asdf)
- aasdf;
- a = 9;
- case 4: x = 1;
- y = 2;
-
- label: if (asdf)
- here;
-
- label: if (asdf &&
- asdfasdf)
- {
- }
-
- label: if (asdf &&
- asdfasdf) {
- there;
- }
-
- label: if (asdf &&
- asdfasdf)
- there;
- }
-
- {
- /*
- hello with ":set comments= cino=c5"
- */
-
- /*
- hello with ":set comments= cino="
- */
- }
-
-
- {
- if (a < b) {
- a = a + 1;
- } else
- a = a + 2;
-
- if (a)
- do {
- testing;
- } while (asdfasdf);
- a = b + 1;
- asdfasdf
- }
-
- {
- for ( int i = 0;
- i < 10; i++ )
- {
- }
- i = 0;
- }
-
- class bob
- {
- int foo() {return 1;}
- int bar;
- }
-
- main()
- {
- while(1)
- if (foo)
- {
- bar;
- }
- else {
- asdf;
- }
- misplacedline;
- }
-
- {
- if (clipboard.state == SELECT_DONE
- && ((row == clipboard.start.lnum
- && col >= clipboard.start.col)
- || row > clipboard.start.lnum))
- }
-
- {
- if (1) {i += 4;}
- where_am_i;
- return 0;
- }
-
- {
- {
- } // sdf(asdf
- if (asdf)
- asd;
- }
-
- {
- label1:
- label2:
- }
-
- {
- int fooRet = foo(pBar1, false /*fKB*/,
- true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
- f() {
- for ( i = 0;
- i < m;
- /* c */ i++ ) {
- a = b;
- }
- }
- }
-
- {
- f1(/*comment*/);
- f2();
- }
-
- {
- do {
- if (foo) {
- } else
- ;
- } while (foo);
- foo(); // was wrong
- }
-
- int x; // no extra indent because of the ;
- void func()
- {
- }
-
- char *tab[] = {"aaa",
- "};", /* }; */ NULL}
- int indented;
- {}
-
- char *a[] = {"aaa", "bbb",
- "ccc", NULL};
- // here
-
- char *tab[] = {"aaa",
- "xx", /* xx */}; /* asdf */
- int not_indented;
-
- {
- do {
- switch (bla)
- {
- case 1: if (foo)
- bar;
- }
- } while (boo);
- wrong;
- }
-
- int foo,
- bar;
- int foo;
-
- #if defined(foo) \
- && defined(bar)
- char * xx = "asdf\
- foo\
- bor";
- int x;
-
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
-
- void f()
- {
- #if defined(foo) \
- && defined(bar)
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
- {
- int i;
- char *foo = "asdf\
- asdf\
- asdf",
- *bar;
- }
- #endif
- }
- #endif
-
- int y; // comment
- // comment
-
- // comment
-
- {
- Constructor(int a,
- int b ) : BaseClass(a)
- {
- }
- }
-
- void foo()
- {
- char one,
- two;
- struct bla piet,
- jan;
- enum foo kees,
- jannie;
- static unsigned sdf,
- krap;
- unsigned int piet,
- jan;
- int
- kees,
- jan;
- }
-
- {
- t(int f,
- int d); // )
- d();
- }
-
- Constructor::Constructor(int a,
- int b
- ) :
- BaseClass(a,
- b,
- c),
- mMember(b),
- {
- }
-
- Constructor::Constructor(int a,
- int b ) :
- BaseClass(a)
- {
- }
-
- Constructor::Constructor(int a,
- int b ) /*x*/ : /*x*/ BaseClass(a),
- member(b)
- {
- }
-
- A::A(int a, int b)
- : aa(a),
- bb(b),
- cc(c)
- {
- }
-
- class CAbc :
- public BaseClass1,
- protected BaseClass2
- {
- int Test() { return FALSE; }
- int Test1() { return TRUE; }
-
- CAbc(int a, int b ) :
- BaseClass(a)
- {
- switch(xxx)
- {
- case abc:
- asdf();
- break;
-
- case 999:
- baer();
- break;
- }
- }
-
- public: // <-- this was incoreectly indented before!!
- void testfall();
- protected:
- void testfall();
- };
-
- class CAbc : public BaseClass1,
- protected BaseClass2
- {
- };
-
- static struct
- {
- int a;
- int b;
- } variable[COUNT] =
- {
- {
- 123,
- 456
- },
- {
- 123,
- 456
- }
- };
-
- static struct
- {
- int a;
- int b;
- } variable[COUNT] =
- {
- { 123, 456 },
- { 123, 456 }
- };
-
- void asdf() /* ind_maxparen may cause trouble here */
- {
- if ((0
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1
- && 1)) break;
- }
-
- foo()
- {
- a = cond ? foo() : asdf
- + asdf;
-
- a = cond ?
- foo() : asdf
- + asdf;
- }
-
- int main(void)
- {
- if (a)
- if (b)
- 2;
- else 3;
- next_line_of_code();
- }
-
- barry()
- {
- Foo::Foo (int one,
- int two)
- : something(4)
- {}
- }
-
- barry()
- {
- Foo::Foo (int one, int two)
- : something(4)
- {}
- }
-
- Constructor::Constructor(int a,
- int b
- ) :
- BaseClass(a,
- b,
- c),
- mMember(b)
- {
- }
- int main ()
- {
- if (lala)
- do
- ++(*lolo);
- while (lili
- && lele);
- lulu;
- }
-
- int main ()
- {
- switch (c)
- {
- case 'c': if (cond)
- {
- }
- }
- }
-
- main()
- {
- (void) MyFancyFuasdfadsfnction(
- argument);
- }
-
- main()
- {
- char foo[] = "/*";
- /* as
- df */
- hello
- }
-
- /* valid namespaces with normal indent */
- namespace
- {
- {
- 111111111111;
- }
- }
- namespace /* test */
- {
- 11111111111111111;
- }
- namespace // test
- {
- 111111111111111111;
- }
- namespace
- {
- 111111111111111111;
- }
- namespace test
- {
- 111111111111111111;
- }
- namespace{
- 111111111111111111;
- }
- namespace test{
- 111111111111111111;
- }
- namespace {
- 111111111111111111;
- }
- namespace test {
- 111111111111111111;
- namespace test2 {
- 22222222222222222;
- }
- }
-
- /* invalid namespaces use block indent */
- namespace test test2 {
- 111111111111111111111;
- }
- namespace11111111111 {
- 111111111111;
- }
- namespace() {
- 1111111111111;
- }
- namespace()
- {
- 111111111111111111;
- }
- namespace test test2
- {
- 1111111111111111111;
- }
- namespace111111111
- {
- 111111111111111111;
- }
- void getstring() {
- /* Raw strings */
- const char* s = R"(
- test {
- # comment
- field: 123
- }
- )";
- }
- void getstring() {
- const char* s = R"foo(
- test {
- # comment
- field: 123
- }
- )foo";
- }
-
- {
- int a[4] = {
- [0] = 0,
- [1] = 1,
- [2] = 2,
- [3] = 3,
- };
- }
-
- {
- a = b[2]
- + 3;
- }
-
- {
- if (1)
- /* aaaaa
- * bbbbb
- */
- a = 1;
- }
-
- void func()
- {
- switch (foo)
- {
- case (bar):
- if (baz())
- quux();
- break;
- case (shmoo):
- if (!bar)
- {
- }
- case (foo1):
- switch (bar)
- {
- case baz:
- baz_f();
- break;
- }
- break;
- default:
- baz();
- baz();
- break;
- }
- }
-
- /* end of AUTO */
- ]=])
- end)
-
- it('2 is working', function()
- insert_([=[
-
- {
-
- /* this is
- * a real serious important big
- * comment
- */
- /* insert " about life, the universe, and the rest" after "serious" */
- }
- ]=])
-
- feed_command('set tw=0 noai fo=croq')
- feed_command('let &wm = &columns - 20')
- feed_command('/serious/e')
- feed('a about life, the universe, and the rest<esc>')
-
- expect([=[
-
- {
-
- /* this is
- * a real serious
- * about life, the
- * universe, and the
- * rest important big
- * comment
- */
- /* insert " about life, the universe, and the rest" after "serious" */
- }
- ]=])
- end)
-
- it('3 is working', function()
- insert_([=[
-
- {
- /*
- * Testing for comments, without 'cin' set
- */
-
- /*
- * what happens here?
- */
-
- /*
- the end of the comment, try inserting a line below */
-
- /* how about
- this one */
- }
- ]=])
-
- feed_command('set nocin')
- feed_command('/comments')
- feed('joabout life<esc>/happens<cr>')
- feed('jothere<esc>/below<cr>')
- feed('oline<esc>/this<cr>')
- feed('Ohello<esc>')
-
- expect([=[
-
- {
- /*
- * Testing for comments, without 'cin' set
- */
- about life
-
- /*
- * what happens here?
- */
- there
-
- /*
- the end of the comment, try inserting a line below */
- line
-
- /* how about
- hello
- this one */
- }
- ]=])
- end)
-
- it('4 is working', function()
- insert_([=[
-
- {
- var = this + that + vec[0] * vec[0]
- + vec[1] * vec[1]
- + vec2[2] * vec[2];
- }
- ]=])
- feed_command('set cin')
- feed_command('/vec2')
- feed('==<cr>')
-
- expect([=[
-
- {
- var = this + that + vec[0] * vec[0]
- + vec[1] * vec[1]
- + vec2[2] * vec[2];
- }
- ]=])
- end)
-
- it('5 is working', function()
- insert_([=[
-
- {
- asdf asdflkajds f;
- if (tes & ting) {
- asdf asdf asdf ;
- asdfa sdf asdf;
- }
- testing1;
- if (tes & ting)
- {
- asdf asdf asdf ;
- asdfa sdf asdf;
- }
- testing2;
- }
- ]=])
-
- feed_command('set cin')
- feed_command('set cino=}4')
- feed_command('/testing1')
- feed('k2==/testing2<cr>')
- feed('k2==<cr>')
-
- expect([=[
-
- {
- asdf asdflkajds f;
- if (tes & ting) {
- asdf asdf asdf ;
- asdfa sdf asdf;
- }
- testing1;
- if (tes & ting)
- {
- asdf asdf asdf ;
- asdfa sdf asdf;
- }
- testing2;
- }
- ]=])
- end)
-
- it('6 is working', function()
- insert_([=[
-
- main ( int first_par, /*
- * Comment for
- * first par
- */
- int second_par /*
- * Comment for
- * second par
- */
- )
- {
- func( first_par, /*
- * Comment for
- * first par
- */
- second_par /*
- * Comment for
- * second par
- */
- );
-
- }
- ]=])
-
- feed_command('set cin')
- feed_command('set cino=(0,)20')
- feed_command('/main')
- feed('=][<cr>')
-
- expect([=[
-
- main ( int first_par, /*
- * Comment for
- * first par
- */
- int second_par /*
- * Comment for
- * second par
- */
- )
- {
- func( first_par, /*
- * Comment for
- * first par
- */
- second_par /*
- * Comment for
- * second par
- */
- );
-
- }
- ]=])
- end)
-
- it('7 is working', function()
- insert_([=[
-
- main(void)
- {
- /* Make sure that cino=X0s is not parsed like cino=Xs. */
- if (cond)
- foo();
- else
- {
- bar();
- }
- }
- ]=])
-
- feed_command('set cin')
- feed_command('set cino=es,n0s')
- feed_command('/main')
- feed('=][<cr>')
-
- expect([=[
-
- main(void)
- {
- /* Make sure that cino=X0s is not parsed like cino=Xs. */
- if (cond)
- foo();
- else
- {
- bar();
- }
- }
- ]=])
- end)
-
- it('8 is working', function()
- insert_([=[
-
- {
- do
- {
- if ()
- {
- if ()
- asdf;
- else
- asdf;
- }
- } while ();
- cmd; /* this should go under the } */
- }
- ]=])
-
- feed_command('set cin')
- feed_command('set cino=')
- feed(']]=][<cr>')
-
- expect([=[
-
- {
- do
- {
- if ()
- {
- if ()
- asdf;
- else
- asdf;
- }
- } while ();
- cmd; /* this should go under the } */
- }
- ]=])
- end)
-
- it('9 is working', function()
- insert_([=[
-
- void f()
- {
- if ( k() ) {
- l();
-
- } else { /* Start (two words) end */
- m();
- }
-
- n();
- }
- ]=])
-
- feed(']]=][<cr>')
-
- expect([=[
-
- void f()
- {
- if ( k() ) {
- l();
-
- } else { /* Start (two words) end */
- m();
- }
-
- n();
- }
- ]=])
- end)
-
- it('10 is working', function()
- -- This is nasty. This is the only test case where the buffer content
- -- differs from the original. Why? Proper behaviour of this test depends on
- -- the fact that the setup code contains an (unbalanced) opening curly
- -- bracket in "set cino={s,e-s". This bracket actually affects the outcome
- -- of the test: without it the curly bracket under "void f()" would not be
- -- indented properly. And that's why we've had to add one explicitly.
- insert_([=[
- { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT.
-
- void f()
- {
- if ( k() )
- {
- l();
- } else { /* Start (two words) end */
- m();
- }
- n(); /* should be under the if () */
- }
- ]=])
-
- feed_command('set cino={s,e-s')
- feed(']]=][<cr>')
-
- expect([=[
- { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT.
-
- void f()
- {
- if ( k() )
- {
- l();
- } else { /* Start (two words) end */
- m();
- }
- n(); /* should be under the if () */
- }
- ]=])
- end)
-
- it('11 is working', function()
- insert_([=[
-
- void bar(void)
- {
- static array[2][2] =
- {
- { 1, 2 },
- { 3, 4 },
- }
-
- while (a)
- {
- foo(&a);
- }
-
- {
- int a;
- {
- a = a + 1;
- }
- }
- b = a;
- }
-
- void func(void)
- {
- a = 1;
- {
- b = 2;
- }
- c = 3;
- d = 4;
- }
- /* foo */
- ]=])
-
- feed_command('set cino={s,fs')
- feed(']]=/ foo<cr>')
-
- expect([=[
-
- void bar(void)
- {
- static array[2][2] =
- {
- { 1, 2 },
- { 3, 4 },
- }
-
- while (a)
- {
- foo(&a);
- }
-
- {
- int a;
- {
- a = a + 1;
- }
- }
- b = a;
- }
-
- void func(void)
- {
- a = 1;
- {
- b = 2;
- }
- c = 3;
- d = 4;
- }
- /* foo */
- ]=])
- end)
-
- it('12 is working', function()
- insert_([=[
-
- a()
- {
- do {
- a = a +
- a;
- } while ( a ); /* add text under this line */
- if ( a )
- a;
- }
- ]=])
-
- feed_command('set cino=')
- feed_command('/while')
- feed('ohere<esc>')
-
- expect([=[
-
- a()
- {
- do {
- a = a +
- a;
- } while ( a ); /* add text under this line */
- here
- if ( a )
- a;
- }
- ]=])
- end)
-
- it('13 is working', function()
- insert_([=[
-
- a()
- {
- label1:
- /* hmm */
- // comment
- }
- ]=])
-
- feed_command('set cino= com=')
- feed_command('/comment')
- feed('olabel2: b();<cr>label3 /* post */:<cr>/* pre */ label4:<cr>f(/*com*/);<cr>if (/*com*/)<cr>cmd();<esc>')
-
- expect([=[
-
- a()
- {
- label1:
- /* hmm */
- // comment
- label2: b();
- label3 /* post */:
- /* pre */ label4:
- f(/*com*/);
- if (/*com*/)
- cmd();
- }
- ]=])
- end)
-
- it('14 is working', function()
- insert_([=[
-
- /*
- * A simple comment
- */
-
- /*
- ** A different comment
- */
- ]=])
-
- feed_command('set comments& comments^=s:/*,m:**,ex:*/')
- feed_command('/simple')
- feed('=5j<cr>')
-
- expect([=[
-
- /*
- * A simple comment
- */
-
- /*
- ** A different comment
- */
- ]=])
- end)
-
- it('15 is working', function()
- insert_([=[
-
-
- void f()
- {
-
- /*********
- A comment.
- *********/
- }
- ]=])
-
- feed_command('set cino=c0')
- feed_command('set comments& comments-=s1:/* comments^=s0:/*')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
-
- /*********
- A comment.
- *********/
- }
- ]=])
- end)
-
- it('16 is working', function()
- insert_([=[
-
-
- void f()
- {
-
- /*********
- A comment.
- *********/
- }
- ]=])
-
- feed_command('set cino=c0,C1')
- feed_command('set comments& comments-=s1:/* comments^=s0:/*')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
-
- /*********
- A comment.
- *********/
- }
- ]=])
- end)
-
- it('17 is working', function()
- insert_([=[
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
-
- feed_command('set cino=')
- feed(']]=][<cr>')
-
- expect([=[
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
- end)
-
- it('18 is working', function()
- insert_([=[
-
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
-
- feed_command('set cino=(s')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
- end)
-
- it('19 is working', function()
- insert_([=[
-
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
-
- feed_command('set cino=(s,U1 ')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
- end)
-
- it('20 is working', function()
- insert_([=[
-
-
- void f()
- {
- if ( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
-
- feed_command('set cino=(0')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- if ( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
- end)
-
- it('21 is working', function()
- insert_([=[
-
-
- void f()
- {
- if ( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
-
- feed_command('set cino=(0,w1 ')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- if ( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
- end)
-
- it('22 is working', function()
- insert_([=[
-
-
- void f()
- {
- c = c1 && (
- c2 ||
- c3
- ) && c4;
- if (
- c1 && c2
- )
- foo;
- }
- ]=])
-
- feed_command('set cino=(s')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- c = c1 && (
- c2 ||
- c3
- ) && c4;
- if (
- c1 && c2
- )
- foo;
- }
- ]=])
- end)
-
- it('23 is working', function()
- insert_([=[
-
-
- void f()
- {
- c = c1 && (
- c2 ||
- c3
- ) && c4;
- if (
- c1 && c2
- )
- foo;
- }
- ]=])
-
- feed_command('set cino=(s,m1 ')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- c = c1 && (
- c2 ||
- c3
- ) && c4;
- if (
- c1 && c2
- )
- foo;
- }
- ]=])
- end)
-
- it('24 is working', function()
- insert_([=[
-
-
- void f()
- {
- switch (x)
- {
- case 1:
- a = b;
- break;
- default:
- a = 0;
- break;
- }
- }
- ]=])
-
- feed_command('set cino=b1')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- switch (x)
- {
- case 1:
- a = b;
- break;
- default:
- a = 0;
- break;
- }
- }
- ]=])
- end)
-
- it('25 is working', function()
- insert_([=[
-
-
- void f()
- {
- invokeme(
- argu,
- ment);
- invokeme(
- argu,
- ment
- );
- invokeme(argu,
- ment
- );
- }
- ]=])
-
- feed_command('set cino=(0,W5')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- invokeme(
- argu,
- ment);
- invokeme(
- argu,
- ment
- );
- invokeme(argu,
- ment
- );
- }
- ]=])
- end)
-
- it('26 is working', function()
- insert_([=[
-
-
- void f()
- {
- statement;
- // comment 1
- // comment 2
- }
- ]=])
-
- feed_command('set cino=/6')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void f()
- {
- statement;
- // comment 1
- // comment 2
- }
- ]=])
- end)
-
- it('27 is working', function()
- insert_([=[
-
-
- void f()
- {
- statement;
- // comment 1
- // comment 2
- }
- ]=])
-
- feed_command('set cino=')
- feed('2kdd]]/comment 1/+1<cr>')
- feed('==<cr>')
-
- expect([=[
-
- void f()
- {
- statement;
- // comment 1
- // comment 2
- }
- ]=])
- end)
-
- it('28 is working', function()
- insert_([=[
-
-
- class CAbc
- {
- int Test() { return FALSE; }
-
- public: // comment
- void testfall();
- protected:
- void testfall();
- };
- ]=])
-
- feed_command('set cino=g0')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- class CAbc
- {
- int Test() { return FALSE; }
-
- public: // comment
- void testfall();
- protected:
- void testfall();
- };
- ]=])
- end)
-
- it('29 is working', function()
- insert_([=[
-
-
- class Foo : public Bar
- {
- public:
- virtual void method1(void) = 0;
- virtual void method2(int arg1,
- int arg2,
- int arg3) = 0;
- };
- ]=])
-
- feed_command('set cino=(0,gs,hs')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- class Foo : public Bar
- {
- public:
- virtual void method1(void) = 0;
- virtual void method2(int arg1,
- int arg2,
- int arg3) = 0;
- };
- ]=])
- end)
-
- it('30 is working', function()
- insert_([=[
-
-
- void
- foo()
- {
- if (a)
- {
- } else
- asdf;
- }
- ]=])
-
- feed_command('set cino=+20')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- void
- foo()
- {
- if (a)
- {
- } else
- asdf;
- }
- ]=])
- end)
-
- it('31 is working', function()
- insert_([=[
-
-
- {
- averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
- asdasdf,
- func(asdf,
- asdfadsf),
- asdfasdf
- );
-
- /* those are ugly, but consequent */
-
- func()->asd(asdasdf,
- averylongfunctionname(
- abc,
- dec)->averylongfunctionname(
- asdfadsf,
- asdfasdf,
- asdfasdf,
- ),
- func(asdfadf,
- asdfasdf
- ),
- asdasdf
- );
-
- averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
- abc,
- dec)->asdfasdfasdf(
- asdfadsf,
- asdfasdf,
- asdfasdf,
- ),
- func(asdfadf,
- asdfasdf),
- asdasdf
- );
- }
- ]=])
-
- feed_command('set cino=(0,W2s')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- {
- averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
- asdasdf,
- func(asdf,
- asdfadsf),
- asdfasdf
- );
-
- /* those are ugly, but consequent */
-
- func()->asd(asdasdf,
- averylongfunctionname(
- abc,
- dec)->averylongfunctionname(
- asdfadsf,
- asdfasdf,
- asdfasdf,
- ),
- func(asdfadf,
- asdfasdf
- ),
- asdasdf
- );
-
- averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
- abc,
- dec)->asdfasdfasdf(
- asdfadsf,
- asdfasdf,
- asdfasdf,
- ),
- func(asdfadf,
- asdfasdf),
- asdasdf
- );
- }
- ]=])
- end)
-
- it('32 is working', function()
- insert_([=[
-
-
- int main ()
- {
- if (cond1 &&
- cond2
- )
- foo;
- }
- ]=])
-
- feed_command('set cino=M1')
- feed('2kdd]]=][<cr>')
-
- expect([=[
-
- int main ()
- {
- if (cond1 &&
- cond2
- )
- foo;
- }
- ]=])
- end)
-
- it('33 is working', function()
- insert_([=[
-
-
- void func(int a
- #if defined(FOO)
- , int b
- , int c
- #endif
- )
- {
- }
- ]=])
-
- feed_command('set cino=(0,ts')
- feed('2kdd2j=][<cr>')
-
- expect([=[
-
- void func(int a
- #if defined(FOO)
- , int b
- , int c
- #endif
- )
- {
- }
- ]=])
- end)
-
- it('34 is working', function()
- insert_([=[
-
-
-
- void
- func(int a
- #if defined(FOO)
- , int b
- , int c
- #endif
- )
- {
- }
- ]=])
-
- feed_command('set cino=(0')
- feed('2kdd2j=][<cr>')
-
- expect([=[
-
-
- void
- func(int a
- #if defined(FOO)
- , int b
- , int c
- #endif
- )
- {
- }
- ]=])
- end)
-
- it('35 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if(x==y)
- if(y==z)
- foo=1;
- else { bar=1;
- baz=2;
- }
- printf("Foo!\n");
- }
-
- void func1(void)
- {
- char* tab[] = {"foo", "bar",
- "baz", "quux",
- "this line used", "to be indented incorrectly"};
- foo();
- }
-
- void func2(void)
- {
- int tab[] =
- {1, 2,
- 3, 4,
- 5, 6};
-
- printf("This line used to be indented incorrectly.\n");
- }
-
- int foo[]
- #ifdef BAR
-
- = { 1, 2, 3,
- 4, 5, 6 }
-
- #endif
- ;
- int baz;
-
- void func3(void)
- {
- int tab[] = {
- 1, 2,
- 3, 4,
- 5, 6};
-
- printf("Don't you dare indent this line incorrectly!\n");
- }
-
- void
- func4(a, b,
- c)
- int a;
- int b;
- int c;
- {
- }
-
- void
- func5(
- int a,
- int b)
- {
- }
-
- void
- func6(
- int a)
- {
- }
- ]=])
-
- feed_command('set cino&')
- feed('2kdd2j=7][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if(x==y)
- if(y==z)
- foo=1;
- else { bar=1;
- baz=2;
- }
- printf("Foo!\n");
- }
-
- void func1(void)
- {
- char* tab[] = {"foo", "bar",
- "baz", "quux",
- "this line used", "to be indented incorrectly"};
- foo();
- }
-
- void func2(void)
- {
- int tab[] =
- {1, 2,
- 3, 4,
- 5, 6};
-
- printf("This line used to be indented incorrectly.\n");
- }
-
- int foo[]
- #ifdef BAR
-
- = { 1, 2, 3,
- 4, 5, 6 }
-
- #endif
- ;
- int baz;
-
- void func3(void)
- {
- int tab[] = {
- 1, 2,
- 3, 4,
- 5, 6};
-
- printf("Don't you dare indent this line incorrectly!\n");
- }
-
- void
- func4(a, b,
- c)
- int a;
- int b;
- int c;
- {
- }
-
- void
- func5(
- int a,
- int b)
- {
- }
-
- void
- func6(
- int a)
- {
- }
- ]=])
- end)
-
- it('36 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- int tab[] =
- {
- 1, 2, 3,
- 4, 5, 6};
-
- printf("Indent this line correctly!\n");
-
- switch (foo)
- {
- case bar:
- printf("bar");
- break;
- case baz: {
- printf("baz");
- break;
- }
- case quux:
- printf("But don't break the indentation of this instruction\n");
- break;
- }
- }
- ]=])
-
- feed_command('set cino&')
- feed_command('set cino+=l1')
- feed('2kdd2j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- int tab[] =
- {
- 1, 2, 3,
- 4, 5, 6};
-
- printf("Indent this line correctly!\n");
-
- switch (foo)
- {
- case bar:
- printf("bar");
- break;
- case baz: {
- printf("baz");
- break;
- }
- case quux:
- printf("But don't break the indentation of this instruction\n");
- break;
- }
- }
- ]=])
- end)
-
- it('37 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- cout << "a"
- << "b"
- << ") :"
- << "c";
- }
- ]=])
-
- feed_command('set cino&')
- feed('2kdd2j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- cout << "a"
- << "b"
- << ") :"
- << "c";
- }
- ]=])
- end)
-
- it('38 is working', function()
- insert_([=[
-
- void func(void)
- {
- /*
- * This is a comment.
- */
- }
- ]=])
-
- feed_command('set com=s1:/*,m:*,ex:*/')
- feed(']]3jofoo();<esc>')
-
- expect([=[
-
- void func(void)
- {
- /*
- * This is a comment.
- */
- foo();
- }
- ]=])
- end)
-
- it('39 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- for (int i = 0; i < 10; ++i)
- if (i & 1) {
- foo(1);
- } else
- foo(0);
- baz();
- }
- ]=])
-
- feed_command('set cino&')
- feed('2kdd2j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- for (int i = 0; i < 10; ++i)
- if (i & 1) {
- foo(1);
- } else
- foo(0);
- baz();
- }
- ]=])
- end)
-
- it('40 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
-
- feed_command('set cino=k2s,(0')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
- end)
-
- it('41 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
-
- feed_command('set cino=k2s,(s')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
- end)
-
- it('42 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
-
- feed_command('set cino=k2s,(s,U1')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- c = c1 &&
- (
- c2 ||
- c3
- ) && c4;
- }
- ]=])
- end)
-
- it('43 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- if ( c1
- && ( c2
- || c3))
- foo;
-
- a_long_line(
- argument,
- argument);
- a_short_line(argument,
- argument);
- }
- ]=])
-
- feed_command('set cino=k2s,(0,W4')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- if ( c1
- && ( c2
- || c3))
- foo;
-
- a_long_line(
- argument,
- argument);
- a_short_line(argument,
- argument);
- }
- ]=])
- end)
-
- it('44 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
- }
- ]=])
-
- feed_command('set cino=k2s,u2')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
- }
- ]=])
- end)
-
- it('45 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
-
- feed_command('set cino=k2s,(0,w1')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- if (c123456789
- && (c22345
- || c3))
- printf("foo\n");
-
- if ( c1
- && ( c2
- || c3))
- foo;
- func( c1
- && ( c2
- || c3))
- foo;
- }
- ]=])
- end)
-
- it('46 is working', function()
- insert_([=[
-
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- }
- ]=])
-
- feed_command('set cino=k2,(s')
- feed('2kdd3j=][<cr>')
-
- expect([=[
-
- void func(void)
- {
- if (condition1
- && condition2)
- action();
- function(argument1
- && argument2);
-
- if (c1 && (c2 ||
- c3))
- foo;
- if (c1 &&
- (c2 || c3))
- {
- }
- }
- ]=])
- end)
-
- it('47 is working', function()
- insert_([=[
-
- NAMESPACESTART
- /* valid namespaces with normal indent */
- namespace
- {
- {
- 111111111111;
- }
- }
- namespace /* test */
- {
- 11111111111111111;
- }
- namespace // test
- {
- 111111111111111111;
- }
- namespace
- {
- 111111111111111111;
- }
- namespace test
- {
- 111111111111111111;
- }
- namespace test::cpp17
- {
- 111111111111111111;
- }
- namespace ::incorrectcpp17
- {
- 111111111111111111;
- }
- namespace test::incorrectcpp17::
- {
- 111111111111111111;
- }
- namespace test:incorrectcpp17
- {
- 111111111111111111;
- }
- namespace test:::incorrectcpp17
- {
- 111111111111111111;
- }
- namespace{
- 111111111111111111;
- }
- namespace test{
- 111111111111111111;
- }
- namespace {
- 111111111111111111;
- }
- namespace test {
- 111111111111111111;
- namespace test2 {
- 22222222222222222;
- }
- }
-
- /* invalid namespaces use block indent */
- namespace test test2 {
- 111111111111111111111;
- }
- namespace11111111111 {
- 111111111111;
- }
- namespace() {
- 1111111111111;
- }
- namespace()
- {
- 111111111111111111;
- }
- namespace test test2
- {
- 1111111111111111111;
- }
- namespace111111111
- {
- 111111111111111111;
- }
- NAMESPACEEND
- ]=])
-
- feed_command('set cino=N-s')
- feed_command('/^NAMESPACESTART')
- feed('=/^NAMESPACEEND<cr>')
-
- expect([=[
-
- NAMESPACESTART
- /* valid namespaces with normal indent */
- namespace
- {
- {
- 111111111111;
- }
- }
- namespace /* test */
- {
- 11111111111111111;
- }
- namespace // test
- {
- 111111111111111111;
- }
- namespace
- {
- 111111111111111111;
- }
- namespace test
- {
- 111111111111111111;
- }
- namespace test::cpp17
- {
- 111111111111111111;
- }
- namespace ::incorrectcpp17
- {
- 111111111111111111;
- }
- namespace test::incorrectcpp17::
- {
- 111111111111111111;
- }
- namespace test:incorrectcpp17
- {
- 111111111111111111;
- }
- namespace test:::incorrectcpp17
- {
- 111111111111111111;
- }
- namespace{
- 111111111111111111;
- }
- namespace test{
- 111111111111111111;
- }
- namespace {
- 111111111111111111;
- }
- namespace test {
- 111111111111111111;
- namespace test2 {
- 22222222222222222;
- }
- }
-
- /* invalid namespaces use block indent */
- namespace test test2 {
- 111111111111111111111;
- }
- namespace11111111111 {
- 111111111111;
- }
- namespace() {
- 1111111111111;
- }
- namespace()
- {
- 111111111111111111;
- }
- namespace test test2
- {
- 1111111111111111111;
- }
- namespace111111111
- {
- 111111111111111111;
- }
- NAMESPACEEND
- ]=])
- end)
-
- it('48 is working', function()
- insert_([=[
-
- JSSTART
- var bar = {
- foo: {
- that: this,
- some: ok,
- },
- "bar":{
- a : 2,
- b: "123abc",
- x: 4,
- "y": 5
- }
- }
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- var bar = {
- foo: {
- that: this,
- some: ok,
- },
- "bar":{
- a : 2,
- b: "123abc",
- x: 4,
- "y": 5
- }
- }
- JSEND
- ]=])
- end)
-
- it('49 is working', function()
- insert_([=[
-
- JSSTART
- var foo = [
- 1,
- 2,
- 3
- ];
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- var foo = [
- 1,
- 2,
- 3
- ];
- JSEND
- ]=])
- end)
-
- it('50 is working', function()
- insert_([=[
-
- JSSTART
- function bar() {
- var foo = [
- 1,
- 2,
- 3
- ];
- }
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- function bar() {
- var foo = [
- 1,
- 2,
- 3
- ];
- }
- JSEND
- ]=])
- end)
-
- it('51 is working', function()
- insert_([=[
-
- JSSTART
- (function($){
-
- if (cond &&
- cond) {
- stmt;
- }
- window.something.left =
- (width - 50 + offset) + "px";
- var class_name='myclass';
-
- function private_method() {
- }
-
- var public_method={
- method: function(options,args){
- private_method();
- }
- }
-
- function init(options) {
-
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
-
- $.fn[class_name]=function() {
-
- var _arguments=arguments;
- return this.each(function(){
-
- var options=$(this).data(class_name+'_public');
- if (!options) {
- init.apply(this,_arguments);
-
- } else {
- var method=public_method[_arguments[0]];
-
- if (typeof(method)!='function') {
- console.log(class_name+' has no method "'+_arguments[0]+'"');
- return false;
- }
- _arguments[0]=options;
- method.apply(this,_arguments);
- }
- });
- }
-
- })(jQuery);
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- (function($){
-
- if (cond &&
- cond) {
- stmt;
- }
- window.something.left =
- (width - 50 + offset) + "px";
- var class_name='myclass';
-
- function private_method() {
- }
-
- var public_method={
- method: function(options,args){
- private_method();
- }
- }
-
- function init(options) {
-
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
-
- $.fn[class_name]=function() {
-
- var _arguments=arguments;
- return this.each(function(){
-
- var options=$(this).data(class_name+'_public');
- if (!options) {
- init.apply(this,_arguments);
-
- } else {
- var method=public_method[_arguments[0]];
-
- if (typeof(method)!='function') {
- console.log(class_name+' has no method "'+_arguments[0]+'"');
- return false;
- }
- _arguments[0]=options;
- method.apply(this,_arguments);
- }
- });
- }
-
- })(jQuery);
- JSEND
- ]=])
- end)
-
- it('52 is working', function()
- insert_([=[
-
- JSSTART
- function init(options) {
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- function init(options) {
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
- JSEND
- ]=])
- end)
-
- it('53 is working', function()
- insert_([=[
-
- JSSTART
- (function($){
- function init(options) {
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
- })(jQuery);
- JSEND
- ]=])
-
- feed_command('set cino=j1,J1')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- (function($){
- function init(options) {
- $(this).data(class_name+'_public',$.extend({},{
- foo: 'bar',
- bar: 2,
- foobar: [
- 1,
- 2,
- 3
- ],
- callback: function(){
- return true;
- }
- }, options||{}));
- }
- })(jQuery);
- JSEND
- ]=])
- end)
-
- it('javascript indent / vim-patch 7.4.670', function()
- insert_([=[
-
- JSSTART
- // Results of JavaScript indent
- // 1
- (function(){
- var a = [
- 'a',
- 'b',
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 2
- (function(){
- var a = [
- 0 +
- 5 *
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 3
- (function(){
- var a = [
- 0 +
- // comment 1
- 5 *
- /* comment 2 */
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 4
- {
- var a = [
- 0,
- 1
- ];
- var b;
- var c;
- }
-
- // 5
- {
- var a = [
- [
- 0
- ],
- 2,
- 3
- ];
- }
-
- // 6
- {
- var a = [
- [
- 0,
- 1
- ],
- 2,
- 3
- ];
- }
-
- // 7
- {
- var a = [
- // [
- 0,
- // 1
- // ],
- 2,
- 3
- ];
- }
-
- // 8
- var x = [
- (function(){
- var a,
- b,
- c,
- d,
- e,
- f,
- g,
- h,
- i;
- })
- ];
-
- // 9
- var a = [
- 0 +
- 5 *
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
-
- // 10
- var a,
- b,
- c,
- d,
- e,
- f,
- g,
- h,
- i;
- JSEND
- ]=])
-
- -- :set cino=j1,J1,+2
- feed_command('set cino=j1,J1,+2')
- feed_command('/^JSSTART')
- feed('=/^JSEND<cr>')
-
- expect([=[
-
- JSSTART
- // Results of JavaScript indent
- // 1
- (function(){
- var a = [
- 'a',
- 'b',
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 2
- (function(){
- var a = [
- 0 +
- 5 *
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 3
- (function(){
- var a = [
- 0 +
- // comment 1
- 5 *
- /* comment 2 */
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
- }())
-
- // 4
- {
- var a = [
- 0,
- 1
- ];
- var b;
- var c;
- }
-
- // 5
- {
- var a = [
- [
- 0
- ],
- 2,
- 3
- ];
- }
-
- // 6
- {
- var a = [
- [
- 0,
- 1
- ],
- 2,
- 3
- ];
- }
-
- // 7
- {
- var a = [
- // [
- 0,
- // 1
- // ],
- 2,
- 3
- ];
- }
-
- // 8
- var x = [
- (function(){
- var a,
- b,
- c,
- d,
- e,
- f,
- g,
- h,
- i;
- })
- ];
-
- // 9
- var a = [
- 0 +
- 5 *
- 9 *
- 'a',
- 'b',
- 0 +
- 5 *
- 9 *
- 'c',
- 'd',
- 'e',
- 'f',
- 'g',
- 'h',
- 'i'
- ];
-
- // 10
- var a,
- b,
- c,
- d,
- e,
- f,
- g,
- h,
- i;
- JSEND
- ]=])
- end)
-
- it('line continuations in macros / vim-patch 8.0.0148', function()
- insert_([=[
- /* start of define */
- {
- }
- #define AAA \
- BBB\
- CCC
-
- #define CNT \
- 1 + \
- 2 + \
- 4
- /* end of define */]=])
-
- feed_command('set cino&')
- feed_command('/start of define')
- feed('=/end of define<cr>')
-
- expect([=[
- /* start of define */
- {
- }
- #define AAA \
- BBB\
- CCC
-
- #define CNT \
- 1 + \
- 2 + \
- 4
- /* end of define */]=])
- end)
-
- it('* immediately follows comment / vim-patch 8.0.1291', function()
- insert_([=[
- {
- a = second/*bug*/*line;
- }]=])
-
- feed_command('set cin cino&')
- feed_command('/a = second')
- feed('ox')
-
- expect([=[
- {
- a = second/*bug*/*line;
- x
- }]=])
- end)
-end)
diff --git a/test/functional/legacy/expand_spec.lua b/test/functional/legacy/expand_spec.lua
deleted file mode 100644
index cd3713eabe..0000000000
--- a/test/functional/legacy/expand_spec.lua
+++ /dev/null
@@ -1,129 +0,0 @@
--- Test for expanding file names
-
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local call = helpers.call
-local nvim = helpers.meths
-local clear = helpers.clear
-local source = helpers.source
-
-local function expected_empty()
- eq({}, nvim.get_vvar('errors'))
-end
-
-describe('expand file name', function()
- after_each(function()
- helpers.rmdir('Xdir1')
- helpers.rmdir('Xdir2')
- helpers.rmdir('Xdir3')
- helpers.rmdir('Xdir4')
- end)
-
- before_each(function()
- clear()
-
- source([[
- func Test_with_directories()
- call mkdir('Xdir1')
- call mkdir('Xdir2')
- call mkdir('Xdir3')
- cd Xdir3
- call mkdir('Xdir4')
- cd ..
-
- split Xdir1/file
- call setline(1, ['a', 'b'])
- w
- w Xdir3/Xdir4/file
- close
-
- next Xdir?/*/file
- call assert_equal('Xdir3/Xdir4/file', expand('%'))
- if has('unix')
- next! Xdir?/*/nofile
- call assert_equal('Xdir?/*/nofile', expand('%'))
- endif
- " Edit another file, on MS-Windows the swap file would be in use and can't
- " be deleted
- edit foo
-
- call assert_equal(0, delete('Xdir1', 'rf'))
- call assert_equal(0, delete('Xdir2', 'rf'))
- call assert_equal(0, delete('Xdir3', 'rf'))
- endfunc
-
- func Test_with_tilde()
- let dir = getcwd()
- call mkdir('Xdir ~ dir')
- call assert_true(isdirectory('Xdir ~ dir'))
- cd Xdir\ ~\ dir
- call assert_true(getcwd() =~ 'Xdir \~ dir')
- exe 'cd ' . fnameescape(dir)
- call delete('Xdir ~ dir', 'd')
- call assert_false(isdirectory('Xdir ~ dir'))
- endfunc
-
- func Test_expand_tilde_filename()
- split ~
- call assert_equal('~', expand('%'))
- call assert_notequal(expand('%:p'), expand('~/'))
- call assert_match('\~', expand('%:p'))
- bwipe!
- endfunc
-
- func Test_expandcmd()
- let $FOO = 'Test'
- call assert_equal('e x/Test/y', expandcmd('e x/$FOO/y'))
- unlet $FOO
-
- new
- edit Xfile1
- call assert_equal('e Xfile1', expandcmd('e %'))
- edit Xfile2
- edit Xfile1
- call assert_equal('e Xfile2', 'e #'->expandcmd())
- edit Xfile2
- edit Xfile3
- edit Xfile4
- let bnum = bufnr('Xfile2')
- call assert_equal('e Xfile2', expandcmd('e #' . bnum))
- call setline('.', 'Vim!@#')
- call assert_equal('e Vim', expandcmd('e <cword>'))
- call assert_equal('e Vim!@#', expandcmd('e <cWORD>'))
- enew!
- edit Xfile.java
- call assert_equal('e Xfile.py', expandcmd('e %:r.py'))
- call assert_equal('make abc.java', expandcmd('make abc.%:e'))
- call assert_equal('make Xabc.java', expandcmd('make %:s?file?abc?'))
- edit a1a2a3.rb
- call assert_equal('make b1b2b3.rb a1a2a3 Xfile.o', expandcmd('make %:gs?a?b? %< #<.o'))
-
- call assert_fails('call expandcmd("make <afile>")', 'E495:')
- call assert_fails('call expandcmd("make <afile>")', 'E495:')
- enew
- call assert_fails('call expandcmd("make %")', 'E499:')
- close
- endfunc
- ]])
- end)
-
- it('works with directories', function()
- call('Test_with_directories')
- expected_empty()
- end)
-
- it('works with tilde', function()
- call('Test_with_tilde')
- expected_empty()
- end)
-
- it('does not expand tilde if it is a filename', function()
- call('Test_expand_tilde_filename')
- expected_empty()
- end)
-
- it('works with expandcmd()', function()
- call('Test_expandcmd')
- expected_empty()
- end)
-end)
diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua
index dc6ccd3628..7a1afa1fd6 100644
--- a/test/functional/legacy/listchars_spec.lua
+++ b/test/functional/legacy/listchars_spec.lua
@@ -1,7 +1,8 @@
-- Tests for 'listchars' display with 'list' and :list.
local helpers = require('test.functional.helpers')(after_each)
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local Screen = require('test.functional.ui.screen')
+local feed, insert, exec = helpers.feed, helpers.insert, helpers.exec
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
-- luacheck: ignore 621 (Indentation)
@@ -13,7 +14,7 @@ describe("'listchars'", function()
-- luacheck: ignore 613 (Trailing whitespace in a string)
it("works with 'list'", function()
- source([[
+ exec([[
function GetScreenCharsForLine(lnum)
return join(map(range(1, virtcol('$')), 'nr2char(screenchar(a:lnum, v:val))'), '')
endfunction
@@ -98,4 +99,80 @@ describe("'listchars'", function()
.....h>-$
iii<<<<><<$]])
end)
+
+ it('"exceeds" character does not appear in foldcolumn vim-patch:8.2.3121', function()
+ local screen = Screen.new(60, 10)
+ screen:attach()
+ exec([[
+ call setline(1, ['aaa', '', 'a', 'aaaaaa'])
+ vsplit
+ vsplit
+ windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:<
+ ]])
+ feed('13<C-W>>')
+ screen:expect([[
+ aaa │ a>│ ^aaa |
+ │ │ |
+ a │ a │ a |
+ aaaaaa │ a>│ aaaaaa |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ [No Name] [+] <[+] [No Name] [+] |
+ |
+ ]])
+ feed('<C-W>>')
+ screen:expect([[
+ aaa │ >│ ^aaa |
+ │ │ |
+ a │ a│ a |
+ aaaaaa │ >│ aaaaaa |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ [No Name] [+] <+] [No Name] [+] |
+ |
+ ]])
+ feed('<C-W>>')
+ screen:expect([[
+ aaa │ │ ^aaa |
+ │ │ |
+ a │ │ a |
+ aaaaaa │ │ aaaaaa |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ [No Name] [+] <] [No Name] [+] |
+ |
+ ]])
+ feed('<C-W>>')
+ screen:expect([[
+ aaa │ │ ^aaa |
+ │ │ |
+ a │ │ a |
+ aaaaaa │ │ aaaaaa |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ ~ │~ │~ |
+ [No Name] [+] < [No Name] [+] |
+ |
+ ]])
+ feed('<C-W>>')
+ screen:expect([[
+ aaa │ │ ^aaa |
+ │ │ |
+ a │ │ a |
+ aaaaaa │ │ aaaaaa |
+ ~ │~│~ |
+ ~ │~│~ |
+ ~ │~│~ |
+ ~ │~│~ |
+ [No Name] [+] < [No Name] [+] |
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/legacy/search_stat_spec.lua b/test/functional/legacy/search_stat_spec.lua
new file mode 100644
index 0000000000..fdd46c0cb9
--- /dev/null
+++ b/test/functional/legacy/search_stat_spec.lua
@@ -0,0 +1,121 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear, feed, exec, command = helpers.clear, helpers.feed, helpers.exec, helpers.command
+local poke_eventloop = helpers.poke_eventloop
+
+describe('search stat', function()
+ local screen
+ before_each(function()
+ clear()
+ screen = Screen.new(30, 10)
+ screen:set_default_attr_ids({
+ [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
+ [2] = {background = Screen.colors.Yellow}, -- Search
+ [3] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded
+ })
+ screen:attach()
+ end)
+
+ it('right spacing with silent mapping vim-patch:8.1.1970', function()
+ exec([[
+ set shortmess-=S
+ " Append 50 lines with text to search for, "foobar" appears 20 times
+ call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20))
+ call setline(2, 'find this')
+ call setline(70, 'find this')
+ nnoremap n n
+ let @/ = 'find this'
+ call cursor(1,1)
+ norm n
+ ]])
+ screen:expect([[
+ foobar |
+ {2:^find this} |
+ fooooobar |
+ foba |
+ foobar |
+ foobar |
+ foo |
+ fooooobar |
+ foba |
+ /find this [1/2] |
+ ]])
+ command('nnoremap <silent> n n')
+ feed('gg0n')
+ screen:expect([[
+ foobar |
+ {2:^find this} |
+ fooooobar |
+ foba |
+ foobar |
+ foobar |
+ foo |
+ fooooobar |
+ foba |
+ [1/2] |
+ ]])
+ end)
+
+ it('when only match is in fold vim-patch:8.2.0840', function()
+ exec([[
+ set shortmess-=S
+ setl foldenable foldmethod=indent foldopen-=search
+ call append(0, ['if', "\tfoo", "\tfoo", 'endif'])
+ let @/ = 'foo'
+ call cursor(1,1)
+ norm n
+ ]])
+ screen:expect([[
+ if |
+ {3:^+-- 2 lines: foo·············}|
+ endif |
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ /foo [1/2] |
+ ]])
+ feed('n')
+ poke_eventloop()
+ screen:expect_unchanged()
+ feed('n')
+ poke_eventloop()
+ screen:expect_unchanged()
+ end)
+
+ it('is cleared by gd and gD vim-patch:8.2.3583', function()
+ exec([[
+ call setline(1, ['int cat;', 'int dog;', 'cat = dog;'])
+ set shortmess-=S
+ set hlsearch
+ ]])
+ feed('/dog<CR>')
+ screen:expect([[
+ int cat; |
+ int {2:^dog}; |
+ cat = {2:dog}; |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ /dog [1/2] |
+ ]])
+ feed('G0gD')
+ screen:expect([[
+ int {2:^cat}; |
+ int dog; |
+ {2:cat} = dog; |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end)
+end)
diff --git a/test/functional/legacy/visual_mode_spec.lua b/test/functional/legacy/visual_mode_spec.lua
index c8e83ed649..8b5dd0c2dc 100644
--- a/test/functional/legacy/visual_mode_spec.lua
+++ b/test/functional/legacy/visual_mode_spec.lua
@@ -1,5 +1,3 @@
--- Test visual line mode selection redraw after scrolling
-
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
@@ -10,6 +8,7 @@ local feed_command = helpers.feed_command
local funcs = helpers.funcs
local meths = helpers.meths
local eq = helpers.eq
+local exec = helpers.exec
describe('visual line mode', function()
local screen
@@ -40,3 +39,44 @@ describe('visual line mode', function()
]])
end)
end)
+
+describe('visual block mode', function()
+ it('shows selection correctly with virtualedit=block', function()
+ clear()
+ local screen = Screen.new(30, 7)
+ screen:set_default_attr_ids({
+ [1] = {bold = true}, -- ModeMsg
+ [2] = {background = Screen.colors.LightGrey}, -- Visual
+ [3] = {foreground = Screen.colors.Blue, bold = true} -- NonText
+ })
+ screen:attach()
+
+ exec([[
+ call setline(1, ['aaaaaa', 'bbbb', 'cc'])
+ set virtualedit=block
+ normal G
+ ]])
+
+ feed('<C-V>gg$')
+ screen:expect([[
+ {2:aaaaaa}^ |
+ {2:bbbb } |
+ {2:cc } |
+ {3:~ }|
+ {3:~ }|
+ {3:~ }|
+ {1:-- VISUAL BLOCK --} |
+ ]])
+
+ feed('<Esc>gg<C-V>G$')
+ screen:expect([[
+ {2:aaaaaa } |
+ {2:bbbb } |
+ {2:cc}^ {2: } |
+ {3:~ }|
+ {3:~ }|
+ {3:~ }|
+ {1:-- VISUAL BLOCK --} |
+ ]])
+ end)
+end)
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index c543dd1995..1322155595 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -532,6 +532,7 @@ describe('v:lua', function()
command('set pp+=test/functional/fixtures')
eq('\tbadval', eval("v:lua.require'leftpad'('badval')"))
eq(9003, eval("v:lua.require'bar'.doit()"))
+ eq(9004, eval("v:lua.require'baz-quux'.doit()"))
end)
it('throw errors for invalid use', function()
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index fa11fdf794..4635f17557 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -101,7 +101,7 @@ describe('URI methods', function()
eq('C:\\Foo\\Bar\\Baz.txt', exec_lua(test_case))
end)
- it('file path includes only ascii charactors with encoded colon character', function()
+ it('file path includes only ascii characters with encoded colon character', function()
local test_case = [[
local uri = 'file:///C%3A/Foo/Bar/Baz.txt'
return vim.uri_to_fname(uri)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index ddcf7687f5..17f7a04db6 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -2406,6 +2406,17 @@ describe('lua stdlib', function()
eq(buf1, meths.get_current_buf())
eq(buf2, val)
end)
+
+ it('does not cause ml_get errors with invalid visual selection', function()
+ -- Should be fixed by vim-patch:8.2.4028.
+ exec_lua [[
+ local a = vim.api
+ local t = function(s) return a.nvim_replace_termcodes(s, true, true, true) end
+ a.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
+ a.nvim_feedkeys(t "G<C-V>", "txn", false)
+ a.nvim_buf_call(a.nvim_create_buf(false, true), function() vim.cmd "redraw" end)
+ ]]
+ end)
end)
describe('vim.api.nvim_win_call', function()
@@ -2434,6 +2445,75 @@ describe('lua stdlib', function()
eq(win1, meths.get_current_win())
eq(win2, val)
end)
+
+ it('does not cause ml_get errors with invalid visual selection', function()
+ -- Add lines to the current buffer and make another window looking into an empty buffer.
+ exec_lua [[
+ _G.a = vim.api
+ _G.t = function(s) return a.nvim_replace_termcodes(s, true, true, true) end
+ _G.win_lines = a.nvim_get_current_win()
+ vim.cmd "new"
+ _G.win_empty = a.nvim_get_current_win()
+ a.nvim_set_current_win(win_lines)
+ a.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
+ ]]
+
+ -- Start Visual in current window, redraw in other window with fewer lines.
+ -- Should be fixed by vim-patch:8.2.4018.
+ exec_lua [[
+ a.nvim_feedkeys(t "G<C-V>", "txn", false)
+ a.nvim_win_call(win_empty, function() vim.cmd "redraw" end)
+ ]]
+
+ -- Start Visual in current window, extend it in other window with more lines.
+ -- Fixed for win_execute by vim-patch:8.2.4026, but nvim_win_call should also not be affected.
+ exec_lua [[
+ a.nvim_feedkeys(t "<Esc>gg", "txn", false)
+ a.nvim_set_current_win(win_empty)
+ a.nvim_feedkeys(t "gg<C-V>", "txn", false)
+ a.nvim_win_call(win_lines, function() a.nvim_feedkeys(t "G<C-V>", "txn", false) end)
+ vim.cmd "redraw"
+ ]]
+ end)
+
+ it('updates ruler if cursor moved', function()
+ -- Fixed for win_execute in vim-patch:8.1.2124, but should've applied to nvim_win_call too!
+ local screen = Screen.new(30, 5)
+ screen:set_default_attr_ids {
+ [1] = {reverse = true},
+ [2] = {bold = true, reverse = true},
+ }
+ screen:attach()
+ exec_lua [[
+ _G.a = vim.api
+ vim.opt.ruler = true
+ local lines = {}
+ for i = 0, 499 do lines[#lines + 1] = tostring(i) end
+ a.nvim_buf_set_lines(0, 0, -1, true, lines)
+ a.nvim_win_set_cursor(0, {20, 0})
+ vim.cmd "split"
+ _G.win = a.nvim_get_current_win()
+ vim.cmd "wincmd w | redraw"
+ ]]
+ screen:expect [[
+ 19 |
+ {1:[No Name] [+] 20,1 3%}|
+ ^19 |
+ {2:[No Name] [+] 20,1 3%}|
+ |
+ ]]
+ exec_lua [[
+ a.nvim_win_call(win, function() a.nvim_win_set_cursor(0, {100, 0}) end)
+ vim.cmd "redraw"
+ ]]
+ screen:expect [[
+ 99 |
+ {1:[No Name] [+] 100,1 19%}|
+ ^19 |
+ {2:[No Name] [+] 20,1 3%}|
+ |
+ ]]
+ end)
end)
end)
diff --git a/test/functional/lua/xdiff_spec.lua b/test/functional/lua/xdiff_spec.lua
index 4f28f84c01..d55268fc78 100644
--- a/test/functional/lua/xdiff_spec.lua
+++ b/test/functional/lua/xdiff_spec.lua
@@ -90,6 +90,48 @@ describe('xdiff bindings', function()
exec_lua([[return vim.diff(a2, b2, {result_type = 'indices'})]]))
end)
+ it('can run different algorithms', function()
+ local a = table.concat({
+ '.foo1 {',
+ ' margin: 0;',
+ '}',
+ '',
+ '.bar {',
+ ' margin: 0;',
+ '}',
+ ''}, '\n')
+
+ local b = table.concat({
+ '.bar {',
+ ' margin: 0;',
+ '}',
+ '',
+ '.foo1 {',
+ ' margin: 0;',
+ ' color: green;',
+ '}',
+ ''}, '\n')
+
+ eq(
+ table.concat({'@@ -1,4 +0,0 @@',
+ '-.foo1 {',
+ '- margin: 0;',
+ '-}',
+ '-',
+ '@@ -7,0 +4,5 @@',
+ '+',
+ '+.foo1 {',
+ '+ margin: 0;',
+ '+ color: green;',
+ '+}',
+ ''}, '\n'),
+ exec_lua([[
+ local args = {...}
+ return vim.diff(args[1], args[2], {
+ algorithm = 'patience'
+ })
+ ]], a, b))
+ end)
end)
it('can handle bad args', function()
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 37de5d0ce6..f7c2dbdb43 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -230,3 +230,14 @@ describe('health.vim', function()
end)
end)
end)
+
+describe(':checkhealth provider', function()
+ it("works correctly with a wrongly configured 'shell'", function()
+ clear()
+ command([[set shell=echo\ WRONG!!!]])
+ command('let g:loaded_perl_provider = 0')
+ command('let g:loaded_python3_provider = 0')
+ command('checkhealth provider')
+ eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
+ end)
+end)
diff --git a/test/functional/provider/provider_spec.lua b/test/functional/provider/provider_spec.lua
index 78bc4a4edb..3895b8613f 100644
--- a/test/functional/provider/provider_spec.lua
+++ b/test/functional/provider/provider_spec.lua
@@ -14,8 +14,8 @@ describe('providers', function()
command('set loadplugins')
-- Using test-fixture with broken impl:
-- test/functional/fixtures/autoload/provider/python.vim
- eq('Vim:provider: python: missing required variable g:loaded_python_provider',
- pcall_err(eval, "has('python')"))
+ eq('Vim:provider: python3: missing required variable g:loaded_python3_provider',
+ pcall_err(eval, "has('python3')"))
end)
it('with g:loaded_xx_provider, missing #Call()', function()
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index d100db8de2..603f4d91b9 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -8,6 +8,7 @@ local source = helpers.source
local missing_provider = helpers.missing_provider
local matches = helpers.matches
local pcall_err = helpers.pcall_err
+local funcs = helpers.funcs
do
clear()
@@ -93,16 +94,40 @@ describe('python3 provider', function()
ghi]])
end)
- it('py3eval', function()
- eq({1, 2, {['key'] = 'val'}}, eval([[py3eval('[1, 2, {"key": "val"}]')]]))
+ describe('py3eval()', function()
+ it('works', function()
+ eq({1, 2, {['key'] = 'val'}}, funcs.py3eval('[1, 2, {"key": "val"}]'))
+ end)
+
+ it('errors out when given non-string', function()
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(10)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(v:_null_dict)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(v:_null_list)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(0.0)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(function("tr"))'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(v:true)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(v:false)'))
+ eq('Vim:E474: Invalid argument', pcall_err(eval, 'py3eval(v:null)'))
+ end)
+
+ it('accepts NULL string', function()
+ matches('.*SyntaxError.*', pcall_err(eval, 'py3eval($XXX_NONEXISTENT_VAR_XXX)'))
+ end)
end)
it('pyxeval #10758', function()
- eq(0, eval([[&pyxversion]]))
+ eq(3, eval([[&pyxversion]]))
eq(3, eval([[pyxeval('sys.version_info[:3][0]')]]))
eq(3, eval([[&pyxversion]]))
end)
+ it("setting 'pyxversion'", function()
+ command 'set pyxversion=3' -- no error
+ eq('Vim(set):E474: Invalid argument: pyxversion=2', pcall_err(command, 'set pyxversion=2'))
+ command 'set pyxversion=0' -- allowed, but equivalent to pyxversion=3
+ eq(3, eval'&pyxversion')
+ end)
+
it('RPC call to expand("<afile>") during BufDelete #5245 #5617', function()
helpers.add_builddir_to_rtp()
source([=[
@@ -120,3 +145,15 @@ describe('python3 provider', function()
assert_alive()
end)
end)
+
+describe('python2 feature test', function()
+ -- python2 is not supported, so correct behaviour is to return 0
+ it('works', function()
+ eq(0, funcs.has('python2'))
+ eq(0, funcs.has('python'))
+ eq(0, funcs.has('python_compiled'))
+ eq(0, funcs.has('python_dynamic'))
+ eq(0, funcs.has('python_dynamic_'))
+ eq(0, funcs.has('python_'))
+ end)
+end)
diff --git a/test/functional/provider/python_spec.lua b/test/functional/provider/python_spec.lua
deleted file mode 100644
index d60d8d1001..0000000000
--- a/test/functional/provider/python_spec.lua
+++ /dev/null
@@ -1,123 +0,0 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local eq = helpers.eq
-local neq = helpers.neq
-local feed = helpers.feed
-local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
-local insert = helpers.insert
-local expect = helpers.expect
-local command = helpers.command
-local exc_exec = helpers.exc_exec
-local write_file = helpers.write_file
-local curbufmeths = helpers.curbufmeths
-local missing_provider = helpers.missing_provider
-local matches = helpers.matches
-local pcall_err = helpers.pcall_err
-
-do
- clear()
- local reason = missing_provider('python')
- if reason then
- it(':python reports E319 if provider is missing', function()
- local expected = [[Vim%(py.*%):E319: No "python" provider found.*]]
- matches(expected, pcall_err(command, 'py print("foo")'))
- matches(expected, pcall_err(command, 'pyfile foo'))
- end)
- pending(string.format('Python 2 (or the pynvim module) is broken/missing (%s)', reason), function() end)
- return
- end
-end
-
-before_each(function()
- clear()
- command('python import vim')
-end)
-
-describe('python feature test', function()
- it('works', function()
- eq(1, funcs.has('python'))
- eq(1, funcs.has('python_compiled'))
- eq(1, funcs.has('python_dynamic'))
- eq(0, funcs.has('python_dynamic_'))
- eq(0, funcs.has('python_'))
- end)
-end)
-
-describe(':python command', function()
- it('works with a line', function()
- command('python vim.vars["set_by_python"] = [100, 0]')
- eq({100, 0}, meths.get_var('set_by_python'))
- end)
-
- -- TODO(ZyX-I): works with << EOF
- -- TODO(ZyX-I): works with execute 'python' line1."\n".line2."\n"…
-
- it('supports nesting', function()
- command([[python vim.command('python vim.command("python vim.command(\'let set_by_nested_python = 555\')")')]])
- eq(555, meths.get_var('set_by_nested_python'))
- end)
-
- it('supports range', function()
- insert([[
- line1
- line2
- line3
- line4]])
- feed('ggjvj:python vim.vars["range"] = vim.current.range[:]<CR>')
- eq({'line2', 'line3'}, meths.get_var('range'))
- end)
-end)
-
-describe(':pyfile command', function()
- it('works', function()
- local fname = 'pyfile.py'
- write_file(fname, 'vim.command("let set_by_pyfile = 123")')
- command('pyfile pyfile.py')
- eq(123, meths.get_var('set_by_pyfile'))
- os.remove(fname)
- end)
-end)
-
-describe(':pydo command', function()
- it('works', function()
- -- :pydo 42 returns None for all lines,
- -- the buffer should not be changed
- command('normal :pydo 42')
- eq(false, curbufmeths.get_option('modified'))
- -- insert some text
- insert('abc\ndef\nghi')
- expect([[
- abc
- def
- ghi]])
- -- go to top and select and replace the first two lines
- feed('ggvj:pydo return str(linenr)<CR>')
- expect([[
- 1
- 2
- ghi]])
- end)
-end)
-
-describe('pyeval()', function()
- it('works', function()
- eq({1, 2, {['key'] = 'val'}}, funcs.pyeval('[1, 2, {"key": "val"}]'))
- end)
-
- it('errors out when given non-string', function()
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(10)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(v:_null_dict)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(v:_null_list)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(0.0)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(function("tr"))'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(v:true)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(v:false)'))
- eq('Vim(call):E474: Invalid argument', exc_exec('call pyeval(v:null)'))
- end)
-
- it('accepts NULL string', function()
- neq(0, exc_exec('call pyeval($XXX_NONEXISTENT_VAR_XXX)'))
- end)
-end)
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index 44a7f00d8b..396fe5feab 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -666,6 +666,21 @@ int x = INT_MAX;
-- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
}, get_ranges())
end)
+
+ it("should not inject bad languages", function()
+ if helpers.pending_win32(pending) then return end
+ exec_lua([=[
+ vim.treesitter.add_directive("inject-bad!", function(match, _, _, pred, metadata)
+ metadata.language = "{"
+ metadata.combined = true
+ metadata.content = pred[2]
+ end)
+
+ parser = vim.treesitter.get_parser(0, "c", {
+ injections = {
+ c = "(preproc_function_def value: ((preproc_arg) @_a (#inject-bad! @_a)))"}})
+ ]=])
+ end)
end)
describe("when using the offset directive", function()
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index 7716414e87..9f84b71ece 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -759,6 +759,7 @@ describe('Buffer highlighting', function()
priority = 0,
virt_text = s1,
-- other details
+ right_gravity = true,
virt_text_pos = 'eol',
virt_text_hide = false,
}}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true}))
@@ -770,6 +771,7 @@ describe('Buffer highlighting', function()
priority = 0,
virt_text = s2,
-- other details
+ right_gravity = true,
virt_text_pos = 'eol',
virt_text_hide = false,
}}}, get_extmarks(id1, {lastline,0}, {lastline, -1}, {details=true}))
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index 11718a6e18..78f4c6ddd3 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -165,7 +165,7 @@ describe('input non-printable chars', function()
{1:~ }|
{1:~ }|
{1:~ }|
- "Xtest-overwrite" [noeol] 1L, 6C |
+ "Xtest-overwrite" [noeol] 1L, 6B |
]])
-- The timestamp is in second resolution, wait two seconds to be sure.
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index d7f43ca18c..c44e59cfd3 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -26,6 +26,7 @@ describe('ui/ext_popupmenu', function()
[5] = {bold = true, foreground = Screen.colors.SeaGreen},
[6] = {background = Screen.colors.WebGray},
[7] = {background = Screen.colors.LightMagenta},
+ [8] = {foreground = Screen.colors.Red},
})
source([[
function! TestComplete() abort
@@ -426,6 +427,55 @@ describe('ui/ext_popupmenu', function()
{1:~ }|
{2:-- INSERT --} |
]])
+
+ feed('<esc>ddiaa bb cc<cr>')
+ feed('<c-x><c-n>')
+ screen:expect([[
+ aa bb cc |
+ aa^ |
+ {6:aa }{1: }|
+ {7:bb }{1: }|
+ {7:cc }{1: }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- Keyword Local completion (^N^P) }{5:match 1 of 3} |
+ ]])
+
+ feed('<f1>')
+ screen:expect([[
+ aa bb cc |
+ cc^ |
+ {7:aa }{1: }|
+ {7:bb }{1: }|
+ {6:cc }{1: }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- Keyword Local completion (^N^P) }{5:match 3 of 3} |
+ ]])
+
+ feed('<f2>')
+ screen:expect([[
+ aa bb cc |
+ cc^ |
+ {7:aa }{1: }|
+ {7:bb }{1: }|
+ {7:cc }{1: }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- Keyword Local completion (^N^P) }{8:Back at original} |
+ ]])
+
+ feed('<f3>')
+ screen:expect([[
+ aa bb cc |
+ bb^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- INSERT --} |
+ ]])
end)
local function source_complete_month()
@@ -2271,6 +2321,47 @@ describe('builtin popupmenu', function()
assert_alive()
end)
+ it('is closed by :stopinsert from timer #12976', function()
+ screen:try_resize(32,14)
+ command([[call setline(1, ['hello', 'hullo', 'heeee', ''])]])
+ feed('Gah<C-N>')
+ screen:expect([[
+ hello |
+ hullo |
+ heeee |
+ hello^ |
+ {s:hello }{1: }|
+ {n:hullo }{1: }|
+ {n:heeee }{1: }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- }{5:match 1 of 3} |
+ ]])
+ command([[call timer_start(100, { -> execute('stopinsert') })]])
+ helpers.sleep(200)
+ feed('k') -- cursor should move up in Normal mode
+ screen:expect([[
+ hello |
+ hullo |
+ heee^e |
+ hello |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end)
+
it('truncates double-width character correctly when there is no scrollbar', function()
screen:try_resize(32,8)
command('set completeopt+=menuone,noselect')
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 958e137f65..09bcbc2bbd 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -6,6 +6,7 @@ local insert = helpers.insert
local eq = helpers.eq
local eval = helpers.eval
local iswin = helpers.iswin
+local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua
describe('screen', function()
local screen
@@ -127,14 +128,67 @@ local function screen_tests(linegrid)
end)
it('has correct default title with named file', function()
- local expected = (iswin() and 'myfile (C:\\mydir) - NVIM'
- or 'myfile (/mydir) - NVIM')
+ local expected = (iswin() and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM')
command('set title')
command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
screen:expect(function()
eq(expected, screen.title)
end)
end)
+
+ describe('is not changed by', function()
+ local file1 = iswin() and 'C:\\mydir\\myfile1' or '/mydir/myfile1'
+ local file2 = iswin() and 'C:\\mydir\\myfile2' or '/mydir/myfile2'
+ local expected = (iswin() and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM')
+ local buf2
+
+ before_each(function()
+ command('edit '..file1)
+ buf2 = funcs.bufadd(file2)
+ command('set title')
+ end)
+
+ it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function()
+ command([[inoremap <F2> <C-R>=setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : ''<CR>]])
+ feed('i<F2><Esc>')
+ command('redraw!')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end)
+
+ it('an RPC call to nvim_buf_set_option in a hidden buffer', function()
+ meths.buf_set_option(buf2, 'autoindent', true)
+ command('redraw!')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end)
+
+ it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function()
+ exec_lua(string.format([[
+ vim.schedule(function()
+ vim.api.nvim_buf_set_option(%d, 'autoindent', true)
+ end)
+ ]], buf2))
+ command('redraw!')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end)
+
+ it('a Lua callback calling nvim_buf_call in a hidden buffer', function()
+ exec_lua(string.format([[
+ vim.schedule(function()
+ vim.api.nvim_buf_call(%d, function() end)
+ end)
+ ]], buf2))
+ command('redraw!')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end)
+ end)
end)
describe(':set icon', function()
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua
index e1459ab5b8..0c2ca8de78 100644
--- a/test/functional/vimscript/eval_spec.lua
+++ b/test/functional/vimscript/eval_spec.lua
@@ -5,7 +5,7 @@
-- null_spec.lua
-- operators_spec.lua
--
--- Tests for the Vimscript |functions| library should live in:
+-- Tests for the Vimscript |builtin-functions| library should live in:
-- test/functional/vimscript/<funcname>_spec.lua
-- test/functional/vimscript/functions_spec.lua
diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua
index 0ad7fd8010..20c1400030 100644
--- a/test/functional/vimscript/functions_spec.lua
+++ b/test/functional/vimscript/functions_spec.lua
@@ -1,4 +1,4 @@
--- Tests for misc Vimscript |functions|.
+-- Tests for misc Vimscript |builtin-functions|.
--
-- If a function is non-trivial, consider moving its spec to:
-- test/functional/vimscript/<funcname>_spec.lua
diff --git a/test/helpers.lua b/test/helpers.lua
index 87431e4342..522714c8be 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -815,7 +815,7 @@ end
function module.read_nvim_log(logfile, ci_rename)
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
local is_ci = module.isCI()
- local keep = is_ci and 999 or 10
+ local keep = is_ci and 100 or 10
local lines = module.read_file_list(logfile, -keep) or {}
local log = (('-'):rep(78)..'\n'
..string.format('$NVIM_LOG_FILE: %s\n', logfile)
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index 3692e19379..34c88248e6 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -249,7 +249,7 @@ describe('buffer functions', function()
--
-- @param arg Options can be placed in an optional dictionary as the last parameter
-- .expected_cell_count The expected number of cells build_stl_str_hl will return
- -- .expected_byte_length The expected byte length of the string
+ -- .expected_byte_length The expected byte length of the string (defaults to byte length of expected_stl)
-- .file_name The name of the file to be tested (useful in %f type tests)
-- .fillchar The character that will be used to fill any 'extra' space in the stl
local function statusline_test (description,
@@ -264,7 +264,7 @@ describe('buffer functions', function()
local fillchar = option.fillchar or (' '):byte()
local expected_cell_count = option.expected_cell_count or statusline_cell_count
- local expected_byte_length = option.expected_byte_length or expected_cell_count
+ local expected_byte_length = option.expected_byte_length or #expected_stl
itp(description, function()
if option.file_name then
@@ -312,12 +312,12 @@ describe('buffer functions', function()
statusline_test('should put fillchar `~` in between text', 10,
'abc%=def', 'abc~~~~def',
{fillchar=('~'):byte()})
+ statusline_test('should put fillchar `━` in between text', 10,
+ 'abc%=def', 'abc━━━━def',
+ {fillchar=0x2501})
statusline_test('should handle zero-fillchar as a space', 10,
'abcde%=', 'abcde ',
{fillchar=0})
- statusline_test('should handle multibyte-fillchar as a dash', 10,
- 'abcde%=', 'abcde-----',
- {fillchar=0x80})
statusline_test('should print the tail file name', 80,
'%t', 'buffer_spec.lua',
{file_name='test/unit/buffer_spec.lua', expected_cell_count=15})
@@ -366,70 +366,86 @@ describe('buffer functions', function()
statusline_test('should ignore trailing %', 3, 'abc%', 'abc')
- -- alignment testing
- statusline_test('should right align when using =', 20,
- 'neo%=vim', 'neo vim')
- statusline_test('should, when possible, center text when using %=text%=', 20,
- 'abc%=neovim%=def', 'abc neovim def')
- statusline_test('should handle uneven spacing in the buffer when using %=text%=', 20,
- 'abc%=neo_vim%=def', 'abc neo_vim def')
- statusline_test('should have equal spaces even with non-equal sides when using =', 20,
- 'foobar%=test%=baz', 'foobar test baz')
- statusline_test('should have equal spaces even with longer right side when using =', 20,
- 'a%=test%=longtext', 'a test longtext')
- statusline_test('should handle an empty left side when using ==', 20,
- '%=test%=baz', ' test baz')
- statusline_test('should handle an empty right side when using ==', 20,
- 'foobar%=test%=', 'foobar test ')
- statusline_test('should handle consecutive empty ==', 20,
- '%=%=test%=', ' test ')
- statusline_test('should handle an = alone', 20,
- '%=', ' ')
- statusline_test('should right align text when it is alone with =', 20,
- '%=foo', ' foo')
- statusline_test('should left align text when it is alone with =', 20,
- 'foo%=', 'foo ')
-
- statusline_test('should approximately center text when using %=text%=', 21,
- 'abc%=neovim%=def', 'abc neovim def')
- statusline_test('should completely fill the buffer when using %=text%=', 21,
- 'abc%=neo_vim%=def', 'abc neo_vim def')
- statusline_test('should have equal spaces even with non-equal sides when using =', 21,
- 'foobar%=test%=baz', 'foobar test baz')
- statusline_test('should have equal spaces even with longer right side when using =', 21,
- 'a%=test%=longtext', 'a test longtext')
- statusline_test('should handle an empty left side when using ==', 21,
- '%=test%=baz', ' test baz')
- statusline_test('should handle an empty right side when using ==', 21,
- 'foobar%=test%=', 'foobar test ')
-
- statusline_test('should quadrant the text when using 3 %=', 40,
- 'abcd%=n%=eovim%=ef', 'abcd n eovim ef')
- statusline_test('should work well with %t', 40,
- '%t%=right_aligned', 'buffer_spec.lua right_aligned',
+ -- alignment testing with fillchar
+ local function statusline_test_align (description,
+ statusline_cell_count,
+ input_stl,
+ expected_stl,
+ arg)
+ arg = arg or {}
+ statusline_test(description .. ' without fillchar',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', ' '), arg)
+ arg.fillchar = ('!'):byte()
+ statusline_test(description .. ' with fillchar `!`',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', '!'), arg)
+ arg.fillchar = 0x2501
+ statusline_test(description .. ' with fillchar `━`',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', '━'), arg)
+ end
+
+ statusline_test_align('should right align when using =', 20,
+ 'neo%=vim', 'neo~~~~~~~~~~~~~~vim')
+ statusline_test_align('should, when possible, center text when using %=text%=', 20,
+ 'abc%=neovim%=def', 'abc~~~~neovim~~~~def')
+ statusline_test_align('should handle uneven spacing in the buffer when using %=text%=', 20,
+ 'abc%=neo_vim%=def', 'abc~~~neo_vim~~~~def')
+ statusline_test_align('should have equal spaces even with non-equal sides when using =', 20,
+ 'foobar%=test%=baz', 'foobar~~~test~~~~baz')
+ statusline_test_align('should have equal spaces even with longer right side when using =', 20,
+ 'a%=test%=longtext', 'a~~~test~~~~longtext')
+ statusline_test_align('should handle an empty left side when using ==', 20,
+ '%=test%=baz', '~~~~~~test~~~~~~~baz')
+ statusline_test_align('should handle an empty right side when using ==', 20,
+ 'foobar%=test%=', 'foobar~~~~~test~~~~~')
+ statusline_test_align('should handle consecutive empty ==', 20,
+ '%=%=test%=', '~~~~~~~~~~test~~~~~~')
+ statusline_test_align('should handle an = alone', 20,
+ '%=', '~~~~~~~~~~~~~~~~~~~~')
+ statusline_test_align('should right align text when it is alone with =', 20,
+ '%=foo', '~~~~~~~~~~~~~~~~~foo')
+ statusline_test_align('should left align text when it is alone with =', 20,
+ 'foo%=', 'foo~~~~~~~~~~~~~~~~~')
+
+ statusline_test_align('should approximately center text when using %=text%=', 21,
+ 'abc%=neovim%=def', 'abc~~~~neovim~~~~~def')
+ statusline_test_align('should completely fill the buffer when using %=text%=', 21,
+ 'abc%=neo_vim%=def', 'abc~~~~neo_vim~~~~def')
+ statusline_test_align('should have equal spacing even with non-equal sides when using =', 21,
+ 'foobar%=test%=baz', 'foobar~~~~test~~~~baz')
+ statusline_test_align('should have equal spacing even with longer right side when using =', 21,
+ 'a%=test%=longtext', 'a~~~~test~~~~longtext')
+ statusline_test_align('should handle an empty left side when using ==', 21,
+ '%=test%=baz', '~~~~~~~test~~~~~~~baz')
+ statusline_test_align('should handle an empty right side when using ==', 21,
+ 'foobar%=test%=', 'foobar~~~~~test~~~~~~')
+
+ statusline_test_align('should quadrant the text when using 3 %=', 40,
+ 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~ef')
+ statusline_test_align('should work well with %t', 40,
+ '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~right_aligned',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should work well with %t and regular text', 40,
- 'l%=m_l %t m_r%=r', 'l m_l buffer_spec.lua m_r r',
+ statusline_test_align('should work well with %t and regular text', 40,
+ 'l%=m_l %t m_r%=r', 'l~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should work well with %=, %t, %L, and %l', 40,
- '%t %= %L %= %l', 'buffer_spec.lua 1 0',
+ statusline_test_align('should work well with %=, %t, %L, and %l', 40,
+ '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~ 1 ~~~~~~~~~~ 0',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should quadrant the text when using 3 %=', 41,
- 'abcd%=n%=eovim%=ef', 'abcd n eovim ef')
- statusline_test('should work well with %t', 41,
- '%t%=right_aligned', 'buffer_spec.lua right_aligned',
+ statusline_test_align('should quadrant the text when using 3 %=', 41,
+ 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~~ef')
+ statusline_test_align('should work well with %t', 41,
+ '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~~right_aligned',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should work well with %t and regular text', 41,
- 'l%=m_l %t m_r%=r', 'l m_l buffer_spec.lua m_r r',
+ statusline_test_align('should work well with %t and regular text', 41,
+ 'l%=m_l %t m_r%=r', 'l~~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should work well with %=, %t, %L, and %l', 41,
- '%t %= %L %= %l', 'buffer_spec.lua 1 0',
+ statusline_test_align('should work well with %=, %t, %L, and %l', 41,
+ '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~~ 1 ~~~~~~~~~~ 0',
{file_name='test/unit/buffer_spec.lua'})
- statusline_test('should work with 10 %=', 50,
+ statusline_test_align('should work with 10 %=', 50,
'aaaa%=b%=c%=d%=e%=fg%=hi%=jk%=lmnop%=qrstuv%=wxyz',
- 'aaaa b c d e fg hi jk lmnop qrstuv wxyz')
+ 'aaaa~~b~~c~~d~~e~~fg~~hi~~jk~~lmnop~~qrstuv~~~wxyz')
-- stl item testing
local tabline = ''
@@ -452,11 +468,10 @@ describe('buffer functions', function()
-- multi-byte testing
statusline_test('should handle multibyte characters', 10,
- 'Ĉ%=x', 'Ĉ x',
- {expected_byte_length=11})
+ 'Ĉ%=x', 'Ĉ x')
statusline_test('should handle multibyte characters and different fillchars', 10,
'Ą%=mid%=end', 'Ą@mid@@end',
- {fillchar=('@'):byte(), expected_byte_length=11})
+ {fillchar=('@'):byte()})
-- escaping % testing
statusline_test('should handle escape of %', 4, 'abc%%', 'abc%')
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 15ce59747e..fb476397e6 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -626,4 +626,20 @@ describe('path.c', function()
eq(false, path_with_extension('/some/path/file', 'lua'))
end)
end)
+
+ describe('path_with_url', function()
+ itp('scheme is alpha and inner hyphen only', function()
+ local function path_with_url(fname)
+ return cimp.path_with_url(to_cstr(fname))
+ end
+ eq(1, path_with_url([[test://xyz/foo/b0]]))
+ eq(2, path_with_url([[test:\\xyz\foo\b0]]))
+ eq(0, path_with_url([[test+abc://xyz/foo/b1]]))
+ eq(0, path_with_url([[test_abc://xyz/foo/b2]]))
+ eq(1, path_with_url([[test-abc://xyz/foo/b3]]))
+ eq(2, path_with_url([[test-abc:\\xyz\foo\b3]]))
+ eq(0, path_with_url([[-test://xyz/foo/b4]]))
+ eq(0, path_with_url([[test-://xyz/foo/b5]]))
+ end)
+ end)
end)