aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/extmark_spec.lua6
-rw-r--r--test/functional/autocmd/searchwrapped_spec.lua53
-rw-r--r--test/functional/terminal/scrollback_spec.lua70
-rw-r--r--test/functional/terminal/tui_spec.lua42
-rw-r--r--test/functional/treesitter/parser_spec.lua37
-rw-r--r--test/functional/vimscript/screenpos_spec.lua51
-rw-r--r--test/unit/os/shell_spec.lua1
7 files changed, 254 insertions, 6 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 45a01be620..a8f538b951 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -420,7 +420,7 @@ describe('API/extmarks', function()
end)
it('marks move with open line', function()
- -- open_line in misc1.c
+ -- open_line in change.c
-- testing marks below are also moved
feed("yyP")
set_extmark(ns, marks[1], 0, 4)
@@ -489,7 +489,7 @@ describe('API/extmarks', function()
end)
it('marks move with line splits (using enter)', function()
- -- open_line in misc1.c
+ -- open_line in change.c
-- testing marks below are also moved
feed("yyP")
set_extmark(ns, marks[1], 0, 4)
@@ -500,7 +500,7 @@ describe('API/extmarks', function()
end)
it('marks at last line move on insert new line', function()
- -- open_line in misc1.c
+ -- open_line in change.c
set_extmark(ns, marks[1], 0, 4)
feed('0i<cr><esc>')
check_undo_redo(ns, marks[1], 0, 4, 1, 4)
diff --git a/test/functional/autocmd/searchwrapped_spec.lua b/test/functional/autocmd/searchwrapped_spec.lua
new file mode 100644
index 0000000000..46c2c99b3d
--- /dev/null
+++ b/test/functional/autocmd/searchwrapped_spec.lua
@@ -0,0 +1,53 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local command = helpers.command
+local curbufmeths = helpers.curbufmeths
+local eq = helpers.eq
+local eval = helpers.eval
+local feed = helpers.feed
+
+describe('autocmd SearchWrapped', function()
+ before_each(function()
+ clear()
+ command('set ignorecase')
+ command('let g:test = 0')
+ command('autocmd! SearchWrapped * let g:test += 1')
+ curbufmeths.set_lines(0, 1, false, {
+ 'The quick brown fox',
+ 'jumps over the lazy dog'})
+ end)
+
+ it('gets triggered when search wraps the end', function()
+ feed('/the<Return>')
+ eq(0, eval('g:test'))
+
+ feed('n')
+ eq(1, eval('g:test'))
+
+ feed('nn')
+ eq(2, eval('g:test'))
+ end)
+
+ it('gets triggered when search wraps in reverse order', function()
+ feed('/the<Return>')
+ eq(0, eval('g:test'))
+
+ feed('NN')
+ eq(1, eval('g:test'))
+
+ feed('NN')
+ eq(2, eval('g:test'))
+ end)
+
+ it('does not get triggered on failed searches', function()
+ feed('/blargh<Return>')
+ eq(0, eval('g:test'))
+
+ feed('NN')
+ eq(0, eval('g:test'))
+
+ feed('NN')
+ eq(0, eval('g:test'))
+ end)
+end)
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index b932c58430..11bdc73a47 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -12,6 +12,8 @@ local curbufmeths = helpers.curbufmeths
local nvim = helpers.nvim
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
+local exec_lua = helpers.exec_lua
+local assert_alive = helpers.assert_alive
describe(':terminal scrollback', function()
local screen
@@ -527,3 +529,71 @@ describe("'scrollback' option", function()
end)
end)
+
+describe("pending scrollback line handling", function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(30, 7)
+ screen:attach()
+ screen:set_default_attr_ids {
+ [1] = {foreground = Screen.colors.Brown},
+ [2] = {reverse = true},
+ [3] = {bold = true},
+ }
+ end)
+
+ it("does not crash after setting 'number' #14891", function()
+ exec_lua [[
+ local a = vim.api
+ local buf = a.nvim_create_buf(true, true)
+ local chan = a.nvim_open_term(buf, {})
+ a.nvim_win_set_option(0, "number", true)
+ a.nvim_chan_send(chan, ("a\n"):rep(11) .. "a")
+ a.nvim_win_set_buf(0, buf)
+ ]]
+ screen:expect [[
+ {1: 1 }^a |
+ {1: 2 } a |
+ {1: 3 } a |
+ {1: 4 } a |
+ {1: 5 } a |
+ {1: 6 } a |
+ |
+ ]]
+ feed('G')
+ screen:expect [[
+ {1: 7 } a |
+ {1: 8 } a |
+ {1: 9 } a |
+ {1: 10 } a |
+ {1: 11 } a |
+ {1: 12 } ^a |
+ |
+ ]]
+ assert_alive()
+ end)
+
+ it("does not crash after nvim_buf_call #14891", function()
+ exec_lua [[
+ local a = vim.api
+ local bufnr = a.nvim_create_buf(false, true)
+ a.nvim_buf_call(bufnr, function()
+ vim.fn.termopen({"echo", ("hi\n"):rep(11)})
+ end)
+ a.nvim_win_set_buf(0, bufnr)
+ vim.cmd("startinsert")
+ ]]
+ screen:expect [[
+ hi |
+ hi |
+ hi |
+ |
+ |
+ [Process exited 0]{2: } |
+ {3:-- TERMINAL --} |
+ ]]
+ assert_alive()
+ end)
+end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 6b9586b4de..7113cc1b49 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -677,8 +677,8 @@ describe('TUI', function()
item 2997 |
item 2998 |
item 2999 |
- item 3000 en{1:d} |
- {5:[No Name] [+] 3000,13 Bot}|
+ item 3000 en{1:d}d |
+ {5:[No Name] [+] 5999,13 Bot}|
|
{3:-- TERMINAL --} |
]])
@@ -765,6 +765,44 @@ describe('TUI', function()
]])
end)
+ it('paste: streamed paste with isolated "stop paste" code', function()
+ child_session:request('nvim_exec_lua', [[
+ _G.paste_phases = {}
+ vim.paste = (function(overridden)
+ return function(lines, phase)
+ table.insert(_G.paste_phases, phase)
+ overridden(lines, phase)
+ end
+ end)(vim.paste)
+ ]], {})
+ feed_data('i')
+ feed_data('\027[200~pasted') -- phase 1
+ screen:expect([[
+ pasted{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]])
+ feed_data(' from terminal') -- phase 2
+ screen:expect([[
+ pasted from terminal{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]])
+ -- Send isolated "stop paste" sequence.
+ feed_data('\027[201~') -- phase 3
+ screen:expect_unchanged()
+ local _, rv = child_session:request('nvim_exec_lua', [[return _G.paste_phases]], {})
+ eq({1, 2, 3}, rv)
+ end)
+
it('allows termguicolors to be set at runtime', function()
screen:set_option('rgb', true)
screen:set_default_attr_ids({
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index 1138cfbf4c..911fa017ab 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -227,6 +227,43 @@ void ui_refresh(void)
}, res)
end)
+ it('supports getting text of multiline node', function()
+ if pending_c_parser(pending) then return end
+ insert(test_text)
+ local res = exec_lua([[
+ local parser = vim.treesitter.get_parser(0, "c")
+ local tree = parser:parse()[1]
+ return vim.treesitter.get_node_text(tree:root(), 0)
+ ]])
+ eq(test_text, res)
+
+ local res2 = exec_lua([[
+ local parser = vim.treesitter.get_parser(0, "c")
+ local root = parser:parse()[1]:root()
+ return vim.treesitter.get_node_text(root:child(0):child(0), 0)
+ ]])
+ eq('void', res2)
+ end)
+
+ it('support getting text where start of node is past EOF', function()
+ local text = [[
+def run
+ a = <<~E
+end]]
+ insert(text)
+ local result = exec_lua([[
+ local fake_node = {}
+ function fake_node:start()
+ return 3, 0, 23
+ end
+ function fake_node:end_()
+ return 3, 0, 23
+ end
+ return vim.treesitter.get_node_text(fake_node, 0) == nil
+ ]])
+ eq(true, result)
+ end)
+
it('can match special regex characters like \\ * + ( with `vim-match?`', function()
insert('char* astring = "\\n"; (1 + 1) * 2 != 2;')
diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua
new file mode 100644
index 0000000000..75e5c02298
--- /dev/null
+++ b/test/functional/vimscript/screenpos_spec.lua
@@ -0,0 +1,51 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
+local command, funcs = helpers.command, helpers.funcs
+
+before_each(clear)
+
+describe('screenpos() function', function()
+ it('works in floating window with border', function()
+ local bufnr = meths.create_buf(false, true)
+ local opts = {
+ relative='editor',
+ height=8,
+ width=12,
+ row=6,
+ col=8,
+ anchor='NW',
+ style='minimal',
+ border='none',
+ focusable=1
+ }
+ local float = meths.open_win(bufnr, false, opts)
+ command('redraw')
+ local pos = funcs.screenpos(bufnr, 1, 1)
+ eq(7, pos.row)
+ eq(9, pos.col)
+
+ -- only left border
+ opts.border = {'', '', '', '', '', '', '', '|'}
+ meths.win_set_config(float, opts)
+ command('redraw')
+ pos = funcs.screenpos(bufnr, 1, 1)
+ eq(7, pos.row)
+ eq(10, pos.col)
+
+ -- only top border
+ opts.border = {'', '_', '', '', '', '', '', ''}
+ meths.win_set_config(float, opts)
+ command('redraw')
+ pos = funcs.screenpos(bufnr, 1, 1)
+ eq(8, pos.row)
+ eq(9, pos.col)
+
+ -- both left and top border
+ opts.border = 'single'
+ meths.win_set_config(float, opts)
+ command('redraw')
+ pos = funcs.screenpos(bufnr, 1, 1)
+ eq(8, pos.row)
+ eq(10, pos.col)
+ end)
+end)
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index a73fc8e47e..29a2b78491 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -4,7 +4,6 @@ local cimported = helpers.cimport(
'./src/nvim/os/shell.h',
'./src/nvim/option_defs.h',
'./src/nvim/main.h',
- './src/nvim/misc1.h',
'./src/nvim/memory.h'
)
local ffi, eq = helpers.ffi, helpers.eq