aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/buffer_spec.lua22
-rw-r--r--test/functional/api/vim_spec.lua12
-rw-r--r--test/functional/ex_cmds/source_spec.lua47
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua4
-rw-r--r--test/functional/legacy/options_spec.lua47
-rw-r--r--test/functional/lua/buffer_updates_spec.lua278
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua63
-rw-r--r--test/functional/plugin/lsp_spec.lua40
-rw-r--r--test/functional/ui/decorations_spec.lua95
-rw-r--r--test/functional/ui/fold_spec.lua367
-rw-r--r--test/functional/ui/input_spec.lua38
-rw-r--r--test/functional/ui/messages_spec.lua40
12 files changed, 964 insertions, 89 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index fb8ed6a9d7..81fad206da 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -513,6 +513,28 @@ describe('api/buf', function()
eq({0, 8}, curbufmeths.get_extmark_by_id(ns, id2, {}))
eq({0, 8}, curbufmeths.get_extmark_by_id(ns, id3, {}))
end)
+
+ it("correctly marks changed region for redraw #13890", function()
+ local screen = Screen.new(20, 5)
+ screen:attach()
+
+ insert([[
+ AAA
+ BBB
+ ]])
+
+ curbufmeths.set_text(0, 0, 1, 3, {'XXX', 'YYY'})
+
+ screen:expect([[
+ XXX |
+ YYY |
+ ^ |
+ ~ |
+ |
+
+ ]])
+
+ end)
end)
describe('nvim_buf_get_offset', function()
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3ff3efb8c9..437a1858f3 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -475,6 +475,18 @@ describe('API', function()
end)
end)
+ describe('nvim_notify', function()
+ it('can notify a info message', function()
+ nvim("notify", "hello world", 2, {})
+ end)
+
+ it('can be overriden', function()
+ command("lua vim.notify = function(...) return 42 end")
+ eq(42, meths.exec_lua("return vim.notify('Hello world')", {}))
+ nvim("notify", "hello world", 4, {})
+ end)
+ end)
+
describe('nvim_input', function()
it("VimL error: does NOT fail, updates v:errmsg", function()
local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>")
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
new file mode 100644
index 0000000000..16d0dfb6a1
--- /dev/null
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -0,0 +1,47 @@
+local helpers = require('test.functional.helpers')(after_each)
+local command = helpers.command
+local insert = helpers.insert
+local eq = helpers.eq
+local clear = helpers.clear
+local meths = helpers.meths
+local feed = helpers.feed
+local feed_command = helpers.feed_command
+
+describe(':source', function()
+ before_each(function()
+ clear()
+ end)
+
+ it('current buffer', function()
+ insert('let a = 2')
+ command('source')
+ eq('2', meths.exec('echo a', true))
+ end)
+
+ it('selection in current buffer', function()
+ insert(
+ 'let a = 2\n'..
+ 'let a = 3\n'..
+ 'let a = 4\n')
+
+ -- Source the 2nd line only
+ feed('ggjV')
+ feed_command(':source')
+ eq('3', meths.exec('echo a', true))
+
+ -- Source from 2nd line to end of file
+ feed('ggjVG')
+ feed_command(':source')
+ eq('4', meths.exec('echo a', true))
+ end)
+
+ it('multiline heredoc command', function()
+ insert(
+ 'lua << EOF\n'..
+ 'y = 4\n'..
+ 'EOF\n')
+
+ command('source')
+ eq('4', meths.exec('echo luaeval("y")', true))
+ end)
+end)
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index 252db88b6b..3bbb4c4517 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -70,11 +70,11 @@ local function expect_notification(method, params, ...)
..., "expect_notification", "message")
end
-local function expect_request(method, callback, ...)
+local function expect_request(method, handler, ...)
local req = read_message()
assert_eq(method, req.method,
..., "expect_request", "method")
- local err, result = callback(req.params)
+ local err, result = handler(req.params)
respond(req.id, err, result)
end
diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua
index 1db7afc7a7..d7f5df3a1e 100644
--- a/test/functional/legacy/options_spec.lua
+++ b/test/functional/legacy/options_spec.lua
@@ -1,6 +1,10 @@
+-- See also: src/nvim/testdir/test_options.vim
local helpers = require('test.functional.helpers')(after_each)
local command, clear = helpers.command, helpers.clear
local source, expect = helpers.source, helpers.expect
+local exc_exec = helpers.exc_exec;
+local matches = helpers.matches;
+local Screen = require('test.functional.ui.screen')
describe('options', function()
setup(clear)
@@ -11,7 +15,7 @@ describe('options', function()
end)
describe('set', function()
- setup(clear)
+ before_each(clear)
it("should keep two comma when 'path' is changed", function()
source([[
@@ -24,4 +28,45 @@ describe('set', function()
foo,,bar]])
end)
+
+ it('winminheight works', function()
+ local screen = Screen.new(20, 11)
+ screen:attach()
+ source([[
+ set wmh=0 stal=2
+ below sp | wincmd _
+ below sp | wincmd _
+ below sp | wincmd _
+ below sp
+ ]])
+ matches('E36: Not enough room', exc_exec('set wmh=1'))
+ end)
+
+ it('scroll works', function()
+ local screen = Screen.new(42, 16)
+ screen:attach()
+ source([[
+ set scroll=2
+ set laststatus=2
+ ]])
+ command('verbose set scroll?')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ scroll=7 |
+ Last set from changed window size |
+ Press ENTER or type command to continue^ |
+ ]])
+ end)
end)
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 67dc5f5a16..7a6b5be8bc 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1,5 +1,6 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
+local lfs = require('lfs')
local command = helpers.command
local meths = helpers.meths
@@ -9,8 +10,9 @@ local eq = helpers.eq
local fail = helpers.fail
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local deepcopy = helpers.deepcopy
local expect_events = helpers.expect_events
+local write_file = helpers.write_file
+local dedent = helpers.dedent
local origlines = {"original line 1",
"original line 2",
@@ -20,19 +22,20 @@ local origlines = {"original line 1",
"original line 6",
" indented line"}
-local function attach_buffer(evname)
- exec_lua([[
+before_each(function ()
+ clear()
+ exec_lua [[
local evname = ...
local events = {}
- function test_register(bufnr, id, changedtick, utf_sizes, preview)
+ function test_register(bufnr, evname, id, changedtick, utf_sizes, preview)
local function callback(...)
table.insert(events, {id, ...})
if test_unreg == id then
return true
end
end
- local opts = {[evname]=callback, on_detach=callback, utf_sizes=utf_sizes, preview=preview}
+ local opts = {[evname]=callback, on_detach=callback, on_reload=callback, utf_sizes=utf_sizes, preview=preview}
if changedtick then
opts.on_changedtick = callback
end
@@ -44,41 +47,30 @@ local function attach_buffer(evname)
events = {}
return ret_events
end
- ]], evname)
-end
+ ]]
+end)
describe('lua buffer event callbacks: on_lines', function()
- before_each(function()
- clear()
- attach_buffer('on_lines')
- end)
-
-
- -- verifying the sizes with nvim_buf_get_offset is nice (checks we cannot
- -- assert the wrong thing), but masks errors with unflushed lines (as
- -- nvim_buf_get_offset forces a flush of the memline). To be safe run the
- -- test both ways.
- local function check(verify,utf_sizes)
+ local function setup_eventcheck(verify, utf_sizes, lines)
local lastsize
- meths.buf_set_lines(0, 0, -1, true, origlines)
+ meths.buf_set_lines(0, 0, -1, true, lines)
if verify then
lastsize = meths.buf_get_offset(0, meths.buf_line_count(0))
end
- exec_lua("return test_register(...)", 0, "test1",false,utf_sizes)
- local tick = meths.buf_get_changedtick(0)
-
+ exec_lua("return test_register(...)", 0, "on_lines", "test1",false,utf_sizes)
local verify_name = "test1"
+
local function check_events(expected)
local events = exec_lua("return get_events(...)" )
if utf_sizes then
-- this test case uses ASCII only, so sizes should be the same.
-- Unicode is tested below.
for _, event in ipairs(expected) do
- event[9] = event[8]
- event[10] = event[8]
+ event[9] = event[9] or event[8]
+ event[10] = event[10] or event[9]
end
end
- eq(expected, events)
+ expect_events(expected, events, "line updates")
if verify then
for _, event in ipairs(events) do
if event[1] == verify_name and event[2] == "lines" then
@@ -92,25 +84,38 @@ describe('lua buffer event callbacks: on_lines', function()
end
end
end
+ return check_events, function(new) verify_name = new end
+ end
+
+ -- verifying the sizes with nvim_buf_get_offset is nice (checks we cannot
+ -- assert the wrong thing), but masks errors with unflushed lines (as
+ -- nvim_buf_get_offset forces a flush of the memline). To be safe run the
+ -- test both ways.
+ local function check(verify,utf_sizes)
+ local check_events, verify_name = setup_eventcheck(verify, utf_sizes, origlines)
+
+ local tick = meths.buf_get_changedtick(0)
command('set autoindent')
command('normal! GyyggP')
tick = tick + 1
- check_events({{ "test1", "lines", 1, tick, 0, 0, 1, 0}})
+ check_events {{ "test1", "lines", 1, tick, 0, 0, 1, 0}}
meths.buf_set_lines(0, 3, 5, true, {"changed line"})
tick = tick + 1
- check_events({{ "test1", "lines", 1, tick, 3, 5, 4, 32 }})
+ check_events {{ "test1", "lines", 1, tick, 3, 5, 4, 32 }}
- exec_lua("return test_register(...)", 0, "test2", true, utf_sizes)
+ exec_lua("return test_register(...)", 0, "on_lines", "test2", true, utf_sizes)
tick = tick + 1
command('undo')
-- plugins can opt in to receive changedtick events, or choose
-- to only receive actual changes.
- check_events({{ "test1", "lines", 1, tick, 3, 4, 5, 13 },
- { "test2", "lines", 1, tick, 3, 4, 5, 13 },
- { "test2", "changedtick", 1, tick+1 } })
+ check_events {
+ { "test1", "lines", 1, tick, 3, 4, 5, 13 };
+ { "test2", "lines", 1, tick, 3, 4, 5, 13 };
+ { "test2", "changedtick", 1, tick+1 };
+ }
tick = tick + 1
-- simulate next callback returning true
@@ -121,38 +126,40 @@ describe('lua buffer event callbacks: on_lines', function()
-- plugins can opt in to receive changedtick events, or choose
-- to only receive actual changes.
- check_events({{ "test1", "lines", 1, tick, 6, 7, 9, 16 },
- { "test2", "lines", 1, tick, 6, 7, 9, 16 }})
+ check_events {
+ { "test1", "lines", 1, tick, 6, 7, 9, 16 };
+ { "test2", "lines", 1, tick, 6, 7, 9, 16 };
+ }
- verify_name = "test2"
+ verify_name "test2"
meths.buf_set_lines(0, 1, 1, true, {"added"})
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 1, 1, 2, 0 }})
+ check_events {{ "test2", "lines", 1, tick, 1, 1, 2, 0 }}
feed('wix')
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 4, 5, 5, 16 }})
+ check_events {{ "test2", "lines", 1, tick, 4, 5, 5, 16 }}
-- check hot path for multiple insert
feed('yz')
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 4, 5, 5, 17 }})
+ check_events {{ "test2", "lines", 1, tick, 4, 5, 5, 17 }}
feed('<bs>')
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 4, 5, 5, 19 }})
+ check_events {{ "test2", "lines", 1, tick, 4, 5, 5, 19 }}
feed('<esc>Go')
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 11, 11, 12, 0 }})
+ check_events {{ "test2", "lines", 1, tick, 11, 11, 12, 0 }}
feed('x')
tick = tick + 1
- check_events({{ "test2", "lines", 1, tick, 11, 12, 12, 5 }})
+ check_events {{ "test2", "lines", 1, tick, 11, 12, 12, 5 }}
command('bwipe!')
- check_events({{ "test2", "detach", 1 }})
+ check_events {{ "test2", "detach", 1 }}
end
it('works', function()
@@ -167,51 +174,63 @@ describe('lua buffer event callbacks: on_lines', function()
check(false,true)
end)
- it('works with utf_sizes and unicode text', function()
+ local function check_unicode(verify)
local unicode_text = {"ascii text",
"latin text åäö",
"BMP text ɧ αλφά",
"BMP text 汉语 ↥↧",
"SMP 🤦 🦄🦃",
"combining å بِيَّة"}
- meths.buf_set_lines(0, 0, -1, true, unicode_text)
- feed('gg')
- exec_lua("return test_register(...)", 0, "test1", false, true)
+ local check_events, verify_name = setup_eventcheck(verify, true, unicode_text)
+
local tick = meths.buf_get_changedtick(0)
- feed('dd')
+ feed('ggdd')
tick = tick + 1
- eq({{ "test1", "lines", 1, tick, 0, 1, 0, 11, 11, 11 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 0, 1, 0, 11, 11, 11 }}
feed('A<bs>')
tick = tick + 1
- eq({{ "test1", "lines", 1, tick, 0, 1, 1, 18, 15, 15 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 0, 1, 1, 18, 15, 15 }}
feed('<esc>jylp')
tick = tick + 1
- eq({{ "test1", "lines", 1, tick, 1, 2, 2, 21, 16, 16 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 1, 2, 2, 21, 16, 16 }}
feed('+eea<cr>')
tick = tick + 1
- eq({{ "test1", "lines", 1, tick, 2, 3, 4, 23, 15, 15 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 2, 3, 4, 23, 15, 15 }}
feed('<esc>jdw')
tick = tick + 1
-- non-BMP chars count as 2 UTF-2 codeunits
- eq({{ "test1", "lines", 1, tick, 4, 5, 5, 18, 9, 12 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 4, 5, 5, 18, 9, 12 }}
feed('+rx')
tick = tick + 1
-- count the individual codepoints of a composed character.
- eq({{ "test1", "lines", 1, tick, 5, 6, 6, 27, 20, 20 }}, exec_lua("return get_events(...)" ))
+ check_events {{ "test1", "lines", 1, tick, 5, 6, 6, 27, 20, 20 }}
feed('kJ')
tick = tick + 1
+ -- verification fails with multiple line updates, sorry about that
+ verify_name ""
-- NB: this is inefficient (but not really wrong).
- eq({{ "test1", "lines", 1, tick, 4, 5, 5, 14, 5, 8 },
- { "test1", "lines", 1, tick+1, 5, 6, 5, 27, 20, 20 }}, exec_lua("return get_events(...)" ))
+ check_events {
+ { "test1", "lines", 1, tick, 4, 5, 5, 14, 5, 8 };
+ { "test1", "lines", 1, tick+1, 5, 6, 5, 27, 20, 20 };
+ }
+ end
+
+ it('works with utf_sizes and unicode text', function()
+ check_unicode(false)
end)
+ it('works with utf_sizes and unicode text with verify', function()
+ check_unicode(true)
+ end)
+
+
it('has valid cursor position while shifting', function()
meths.buf_set_lines(0, 0, -1, true, {'line1'})
exec_lua([[
@@ -225,6 +244,14 @@ describe('lua buffer event callbacks: on_lines', function()
eq(1, meths.get_var('listener_cursor_line'))
end)
+ it('has valid cursor position while deleting lines', function()
+ meths.buf_set_lines(0, 0, -1, true, { "line_1", "line_2", "line_3", "line_4"})
+ meths.win_set_cursor(0, {2, 0})
+ eq(2, meths.win_get_cursor(0)[1])
+ meths.buf_set_lines(0, 0, -1, true, { "line_1", "line_2", "line_3"})
+ eq(2, meths.win_get_cursor(0)[1])
+ end)
+
it('does not SEGFAULT when calling win_findbuf in on_detach', function()
exec_lua[[
@@ -272,26 +299,24 @@ describe('lua buffer event callbacks: on_lines', function()
end)
describe('lua: nvim_buf_attach on_bytes', function()
- before_each(function()
- clear()
- attach_buffer('on_bytes')
- end)
-
-- verifying the sizes with nvim_buf_get_offset is nice (checks we cannot
-- assert the wrong thing), but masks errors with unflushed lines (as
-- nvim_buf_get_offset forces a flush of the memline). To be safe run the
-- test both ways.
local function setup_eventcheck(verify, start_txt)
- meths.buf_set_lines(0, 0, -1, true, start_txt)
- local shadow = deepcopy(start_txt)
- local shadowbytes = table.concat(shadow, '\n') .. '\n'
+ if start_txt then
+ meths.buf_set_lines(0, 0, -1, true, start_txt)
+ else
+ start_txt = meths.buf_get_lines(0, 0, -1, true)
+ end
+ local shadowbytes = table.concat(start_txt, '\n') .. '\n'
-- TODO: while we are brewing the real strong coffe,
-- verify should check buf_get_offset after every check_events
if verify then
local len = meths.buf_get_offset(0, meths.buf_line_count(0))
eq(len == -1 and 1 or len, string.len(shadowbytes))
end
- exec_lua("return test_register(...)", 0, "test1", false, false, true)
+ exec_lua("return test_register(...)", 0, "on_bytes", "test1", false, false, true)
meths.buf_get_changedtick(0)
local verify_name = "test1"
@@ -318,6 +343,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
local unknown = string.rep('\255', new_byte)
local after = string.sub(shadowbytes, start_byte + old_byte + 1)
shadowbytes = before .. unknown .. after
+ elseif event[1] == verify_name and event[2] == "reload" then
+ shadowbytes = table.concat(meths.buf_get_lines(0, 0, -1, true), '\n') .. '\n'
end
end
@@ -495,20 +522,34 @@ describe('lua: nvim_buf_attach on_bytes', function()
end)
- it('inccomand=nosplit and substitute', function()
- if verify then pending("Verification can't be done when previewing") end
+ it("linewise paste", function()
+ local check_events = setup_eventcheck(verify, origlines)
+
+ feed'yyp'
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 16, 0, 0, 0, 1, 0, 16 };
+ }
+ feed'Gyyp'
+ check_events {
+ { "test1", "bytes", 1, 4, 8, 0, 130, 0, 0, 0, 1, 0, 18 };
+ }
+ end)
+
+ it('inccomand=nosplit and substitute', function()
local check_events = setup_eventcheck(verify, {"abcde"})
meths.set_option('inccommand', 'nosplit')
feed ':%s/bcd/'
check_events {
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 0, 0 };
+ { "test1", "bytes", 1, 5, 0, 1, 1, 0, 0, 0, 0, 3, 3 };
}
feed 'a'
check_events {
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 1, 1 };
+ { "test1", "bytes", 1, 5, 0, 1, 1, 0, 1, 1, 0, 3, 3 };
}
end)
@@ -575,6 +616,113 @@ describe('lua: nvim_buf_attach on_bytes', function()
"original line 5", "original line 6" },
meths.buf_get_lines(0, 0, -1, true))
end)
+
+ it('checktime autoread', function()
+ write_file("Xtest-reload", dedent [[
+ old line 1
+ old line 2]])
+ lfs.touch("Xtest-reload", os.time() - 10)
+ command "e Xtest-reload"
+ command "set autoread"
+
+ local check_events = setup_eventcheck(verify, nil)
+
+ write_file("Xtest-reload", dedent [[
+ new line 1
+ new line 2
+ new line 3]])
+
+ command "checktime"
+ check_events {
+ { "test1", "reload", 1 };
+ }
+
+ feed 'ggJ'
+ check_events {
+ { "test1", "bytes", 1, 5, 0, 10, 10, 1, 0, 1, 0, 1, 1 };
+ }
+
+ eq({'new line 1 new line 2', 'new line 3'}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- check we can undo and redo a reload event.
+ feed 'u'
+ check_events {
+ { "test1", "bytes", 1, 8, 0, 10, 10, 0, 1, 1, 1, 0, 1 };
+ }
+
+ feed 'u'
+ check_events {
+ { "test1", "reload", 1 };
+ }
+
+ feed '<c-r>'
+ check_events {
+ { "test1", "reload", 1 };
+ }
+
+ feed '<c-r>'
+ check_events {
+ { "test1", "bytes", 1, 14, 0, 10, 10, 1, 0, 1, 0, 1, 1 };
+ }
+ end)
+
+ it("sends events when undoing with undofile", function()
+ write_file("Xtest-undofile", dedent([[
+ 12345
+ hello world
+ ]]))
+
+ command("e! Xtest-undofile")
+ command("set undodir=. | set undofile")
+
+ local ns = helpers.request('nvim_create_namespace', "ns1")
+ meths.buf_set_extmark(0, ns, 0, 0, {})
+
+ eq({"12345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- splice
+ feed("gg0d2l")
+
+ eq({"345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- move
+ command(".m+1")
+
+ eq({"hello world", "345"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- reload undofile and undo changes
+ command("w")
+ command("set noundofile")
+ command("bw!")
+ command("e! Xtest-undofile")
+
+ command("set undofile")
+
+ local check_events = setup_eventcheck(verify, nil)
+
+ feed("u")
+ eq({"345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ check_events {
+ { "test1", "bytes", 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 },
+ { "test1", "bytes", 2, 6, 0, 0, 0, 0, 0, 0, 1, 0, 4 }
+ }
+
+ feed("u")
+ eq({"12345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ check_events {
+ { "test1", "bytes", 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 }
+ }
+ command("bw!")
+ end)
+
+
+ teardown(function()
+ os.remove "Xtest-reload"
+ os.remove "Xtest-undofile"
+ os.remove ".Xtest-undofile.un~"
+ end)
end
describe('(with verify) handles', function()
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index 4705a76465..8c91c4ab2c 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -208,6 +208,69 @@ describe('vim.lsp.diagnostic', function()
]]))
end)
+ describe('reset', function()
+ it('diagnostic count is 0 and displayed diagnostics are 0 after call', function()
+ -- 1 Error (1)
+ -- 1 Warning (2)
+ -- 1 Warning (2) + 1 Warning (1)
+ -- 2 highlights and 2 underlines (since error)
+ -- 1 highlight + 1 underline
+ local all_highlights = {1, 1, 2, 4, 2}
+ eq(all_highlights, exec_lua [[
+ local server_1_diags = {
+ make_error("Error 1", 1, 1, 1, 5),
+ make_warning("Warning on Server 1", 2, 1, 2, 5),
+ }
+ local server_2_diags = {
+ make_warning("Warning 1", 2, 1, 2, 5),
+ }
+
+ vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_1_diags }, 1)
+ vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_2_diags }, 2)
+ return {
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Error", 1),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", 2),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", nil),
+ count_of_extmarks_for_client(diagnostic_bufnr, 1),
+ count_of_extmarks_for_client(diagnostic_bufnr, 2),
+ }
+ ]])
+
+ -- Reset diagnostics from server 1
+ exec_lua([[ vim.lsp.diagnostic.reset(1, { [ diagnostic_bufnr ] = { [ 1 ] = true ; [ 2 ] = true } } )]])
+
+ -- Make sure we have the right diagnostic count
+ eq({0, 1, 1, 0, 2} , exec_lua [[
+ local diagnostic_count = {}
+ vim.wait(100, function () diagnostic_count = {
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Error", 1),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", 2),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", nil),
+ count_of_extmarks_for_client(diagnostic_bufnr, 1),
+ count_of_extmarks_for_client(diagnostic_bufnr, 2),
+ } end )
+ return diagnostic_count
+ ]])
+
+ -- Reset diagnostics from server 2
+ exec_lua([[ vim.lsp.diagnostic.reset(2, { [ diagnostic_bufnr ] = { [ 1 ] = true ; [ 2 ] = true } } )]])
+
+ -- Make sure we have the right diagnostic count
+ eq({0, 0, 0, 0, 0}, exec_lua [[
+ local diagnostic_count = {}
+ vim.wait(100, function () diagnostic_count = {
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Error", 1),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", 2),
+ vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", nil),
+ count_of_extmarks_for_client(diagnostic_bufnr, 1),
+ count_of_extmarks_for_client(diagnostic_bufnr, 2),
+ } end )
+ return diagnostic_count
+ ]])
+
+ end)
+ end)
+
describe('get_next_diagnostic_pos', function()
it('can find the next pos with only one client', function()
eq({1, 1}, exec_lua [[
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 981e2a96a8..d5791fbbfa 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -41,10 +41,10 @@ local function fake_lsp_server_setup(test_name, timeout_ms)
"-c", string.format("lua TIMEOUT = %d", timeout),
"-c", "luafile "..fixture_filename,
};
- callbacks = setmetatable({}, {
+ handlers = setmetatable({}, {
__index = function(t, method)
return function(...)
- return vim.rpcrequest(1, 'callback', ...)
+ return vim.rpcrequest(1, 'handler', ...)
end
end;
});
@@ -89,7 +89,7 @@ local function test_rpc_server(config)
end
return NIL
end
- if method == 'callback' then
+ if method == 'handler' then
if config.on_callback then
config.on_callback(unpack(args))
end
@@ -205,7 +205,7 @@ describe('LSP', function()
}
test_rpc_server {
test_name = "basic_init";
- on_init = function(client, _init_result)
+ on_init = function(client, _)
-- client is a dummy object which will queue up commands to be run
-- once the server initializes. It can't accept lua callbacks or
-- other types that may be unserializable for now.
@@ -257,6 +257,7 @@ describe('LSP', function()
eq(0, client.resolved_capabilities().text_document_did_change)
client.request('shutdown')
client.notify('exit')
+ client.stop()
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)
@@ -333,6 +334,7 @@ describe('LSP', function()
client.stop()
local full_kind = exec_lua("return require'vim.lsp.protocol'.TextDocumentSyncKind.Full")
eq(full_kind, client.resolved_capabilities().text_document_did_change)
+ eq(true, client.resolved_capabilities().text_document_save)
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)
@@ -386,7 +388,7 @@ describe('LSP', function()
exec_lua([=[
BUFFER = vim.api.nvim_get_current_buf()
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
- vim.lsp.callbacks['textDocument/typeDefinition'] = function(err, method)
+ vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
vim.lsp._last_lsp_callback = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
@@ -425,7 +427,7 @@ describe('LSP', function()
test_name = "capabilities_for_client_supports_method";
on_setup = function()
exec_lua([=[
- vim.lsp.callbacks['textDocument/typeDefinition'] = function(err, method)
+ vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
vim.lsp._last_lsp_callback = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
@@ -897,8 +899,8 @@ describe('LSP', function()
eq(0, code, "exit code", fake_lsp_logfile)
eq(0, signal, "exit signal", fake_lsp_logfile)
end;
- on_callback = function(err, method, params, client_id)
- eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ on_handler = function(err, method, params, client_id)
+ eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected handler")
end;
}
end)
@@ -1032,6 +1034,20 @@ describe('LSP', function()
'å ä ɧ 汉语 ↥ 🤦 🦄';
}, buf_lines(1))
end)
+ it('applies text edits at the end of the document', function()
+ local edits = {
+ make_edit(5, 0, 5, 0, "foobar");
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({
+ 'First line of text';
+ 'Second line of text';
+ 'Third line of text';
+ 'Fourth line of text';
+ 'å å ɧ 汉语 ↥ 🤦 🦄';
+ 'foobar';
+ }, buf_lines(1))
+ end)
describe('with LSP end line after what Vim considers to be the end line', function()
it('applies edits when the last linebreak is considered a new line', function()
@@ -1765,8 +1781,8 @@ describe('LSP', function()
uri = "file:///src/main.rs"
}
} }
- local callback = require'vim.lsp.handlers'['callHierarchy/outgoingCalls']
- callback(nil, nil, rust_analyzer_response)
+ local handler = require'vim.lsp.handlers'['callHierarchy/outgoingCalls']
+ handler(nil, nil, rust_analyzer_response)
return vim.fn.getqflist()
]=])
@@ -1837,8 +1853,8 @@ describe('LSP', function()
} }
} }
- local callback = require'vim.lsp.handlers'['callHierarchy/incomingCalls']
- callback(nil, nil, rust_analyzer_response)
+ local handler = require'vim.lsp.handlers'['callHierarchy/incomingCalls']
+ handler(nil, nil, rust_analyzer_response)
return vim.fn.getqflist()
]=])
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 781fdf7203..7a87521a6b 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -302,3 +302,98 @@ describe('decorations providers', function()
]]}
end)
end)
+
+describe('extmark decorations', function()
+ local screen
+ before_each( function()
+ clear()
+ screen = Screen.new(50, 15)
+ screen:attach()
+ screen:set_default_attr_ids {
+ [1] = {bold=true, foreground=Screen.colors.Blue};
+ [2] = {foreground = Screen.colors.Brown};
+ [3] = {bold = true, foreground = Screen.colors.SeaGreen};
+ [4] = {background = Screen.colors.Red1, foreground = Screen.colors.Gray100};
+ }
+ end)
+
+ it('can have virtual text of overlay style', function()
+ insert [[
+for _,item in ipairs(items) do
+ local text, hl_id_cell, count = unpack(item)
+ if hl_id_cell ~= nil then
+ hl_id = hl_id_cell
+ end
+ for _ = 1, (count or 1) do
+ local cell = line[colpos]
+ cell.text = text
+ cell.hl_id = hl_id
+ colpos = colpos+1
+ end
+end]]
+ feed 'gg'
+
+ local ns = meths.create_namespace 'test'
+ for i = 1,9 do
+ meths.buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'})
+ if i == 3 or (i >= 6 and i <= 9) then
+ meths.buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'})
+ end
+ end
+ meths.buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'})
+
+ -- can "float" beyond end of line
+ meths.buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'})
+ -- bound check: right edge of window
+ meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork ' }, {'bork bork bork', 'ErrorMsg'}}, virt_text_pos='overlay'})
+
+ screen:expect{grid=[[
+ ^for _,item in ipairs(items) do |
+ {2:|} local text, hl_id_cell, count = unpack(item) |
+ {2:|} if hl_id_cell ~= nil tbork bork bork {4:bork bork}|
+ {2:|} {1:|} hl_id = hl_id_cell |
+ {2:|} end |
+ {2:|} for _ = 1, (count or 1) {4:loopy} |
+ {2:|} {1:|} local cell = line[colpos] |
+ {2:|} {1:|} cell.text = text |
+ {2:|} {1:|} cell.hl_id = hl_id |
+ {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 |
+ end |
+ end |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+
+ -- handles broken lines
+ screen:try_resize(22, 25)
+ screen:expect{grid=[[
+ ^for _,item in ipairs(i|
+ tems) do |
+ {2:|} local text, hl_id_|
+ cell, count = unpack(i|
+ tem) |
+ {2:|} if hl_id_cell ~= n|
+ il tbork bork bork {4:bor}|
+ {2:|} {1:|} hl_id = hl_id_|
+ cell |
+ {2:|} end |
+ {2:|} for _ = 1, (count |
+ or 1) {4:loopy} |
+ {2:|} {1:|} local cell = l|
+ ine[colpos] |
+ {2:|} {1:|} cell.text = te|
+ xt |
+ {2:|} {1:|} cell.hl_id = h|
+ l_id |
+ {2:|} {1:|} cofoo{3:bar}{4:!!}olpo|
+ s+1 |
+ end |
+ end |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
+end)
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 6ce8b33a63..d3b1d33956 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -38,7 +38,9 @@ describe("folded lines", function()
[6] = {background = Screen.colors.Yellow},
[7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
[8] = {foreground = Screen.colors.Brown },
- [9] = {bold = true, foreground = Screen.colors.Brown}
+ [9] = {bold = true, foreground = Screen.colors.Brown},
+ [10] = {background = Screen.colors.LightGrey, underline = true},
+ [11] = {bold=true},
})
end)
@@ -290,6 +292,369 @@ describe("folded lines", function()
end
end)
+ it("works with split", function()
+ insert([[
+ aa
+ bb
+ cc
+ dd
+ ee
+ ff]])
+ feed_command('2')
+ command("set foldcolumn=1")
+ feed('zf3j')
+ feed_command('1')
+ feed('zf2j')
+ feed('zO')
+ feed_command("rightbelow new")
+ insert([[
+ aa
+ bb
+ cc
+ dd
+ ee
+ ff]])
+ feed_command('2')
+ command("set foldcolumn=1")
+ feed('zf3j')
+ feed_command('1')
+ feed('zf2j')
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 4, 0, 0)
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ {2:[No Name] [+] }|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ {3:[No Name] [+] }|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:-}aa |
+ {7:-}bb |
+ ## grid 3
+ :1 |
+ ## grid 4
+ {7:-}^aa |
+ {7:+}{5:+--- 4 lines: bb···························}|
+ {7:│}ff |
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 3, 0)
+ screen:expect([[
+ {7:-}aa |
+ {7:-}bb |
+ {2:[No Name] [+] }|
+ {7:-}^aa |
+ {7:+}{5:+--- 4 lines: bb···························}|
+ {7:│}ff |
+ {3:[No Name] [+] }|
+ :1 |
+ ]])
+ end
+
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 4, 1, 0)
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ {2:[No Name] [+] }|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ {3:[No Name] [+] }|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:-}aa |
+ {7:-}bb |
+ ## grid 3
+ :1 |
+ ## grid 4
+ {7:-}^aa |
+ {7:-}bb |
+ {7:2}cc |
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 4, 0)
+ screen:expect([[
+ {7:-}aa |
+ {7:-}bb |
+ {2:[No Name] [+] }|
+ {7:-}^aa |
+ {7:-}bb |
+ {7:2}cc |
+ {3:[No Name] [+] }|
+ :1 |
+ ]])
+ end
+
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 2, 1, 0)
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ {3:[No Name] [+] }|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ {2:[No Name] [+] }|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:-}aa |
+ {7:+}{5:^+--- 4 lines: bb···························}|
+ ## grid 3
+ :1 |
+ ## grid 4
+ {7:-}aa |
+ {7:-}bb |
+ {7:2}cc |
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 1, 0)
+ screen:expect([[
+ {7:-}aa |
+ {7:+}{5:^+--- 4 lines: bb···························}|
+ {3:[No Name] [+] }|
+ {7:-}aa |
+ {7:-}bb |
+ {7:2}cc |
+ {2:[No Name] [+] }|
+ :1 |
+ ]])
+ end
+
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 2, 0, 0)
+ screen:expect([[
+ ## grid 1
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ {3:[No Name] [+] }|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ {2:[No Name] [+] }|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:+}{5:^+-- 6 lines: aa····························}|
+ {1:~ }|
+ ## grid 3
+ :1 |
+ ## grid 4
+ {7:-}aa |
+ {7:-}bb |
+ {7:2}cc |
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ screen:expect([[
+ {7:+}{5:^+-- 6 lines: aa····························}|
+ {1:~ }|
+ {3:[No Name] [+] }|
+ {7:-}aa |
+ {7:-}bb |
+ {7:2}cc |
+ {2:[No Name] [+] }|
+ :1 |
+ ]])
+ end
+ end)
+
+ it("works with tab", function()
+ insert([[
+ aa
+ bb
+ cc
+ dd
+ ee
+ ff]])
+ feed_command('2')
+ command("set foldcolumn=2")
+ feed('zf3j')
+ feed_command('1')
+ feed('zf2j')
+ feed('zO')
+ feed_command("tab split")
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 4, 1, 1)
+ screen:expect([[
+ ## grid 1
+ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2 (hidden)
+ {7:- }aa |
+ {7:│-}bb |
+ {7:││}cc |
+ {7:││}dd |
+ {7:││}ee |
+ {7:│ }ff |
+ {1:~ }|
+ ## grid 3
+ :tab split |
+ ## grid 4
+ {7:- }^aa |
+ {7:│+}{5:+--- 4 lines: bb··························}|
+ {7:│ }ff |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 2, 1)
+ screen:expect([[
+ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
+ {7:- }^aa |
+ {7:│+}{5:+--- 4 lines: bb··························}|
+ {7:│ }ff |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :tab split |
+ ]])
+ end
+
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 4, 0, 0)
+ screen:expect([[
+ ## grid 1
+ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [4:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2 (hidden)
+ {7:- }aa |
+ {7:│-}bb |
+ {7:││}cc |
+ {7:││}dd |
+ {7:││}ee |
+ {7:│ }ff |
+ {1:~ }|
+ ## grid 3
+ :tab split |
+ ## grid 4
+ {7:+ }{5:^+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 1, 0)
+ screen:expect([[
+ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
+ {7:+ }{5:^+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :tab split |
+ ]])
+ end
+
+ feed_command("tabnext")
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 2, 1, 1)
+ screen:expect([[
+ ## grid 1
+ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:- }^aa |
+ {7:│+}{5:+--- 4 lines: bb··························}|
+ {7:│ }ff |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ :tabnext |
+ ## grid 4 (hidden)
+ {7:+ }{5:+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 2, 1)
+ screen:expect([[
+ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
+ {7:- }^aa |
+ {7:│+}{5:+--- 4 lines: bb··························}|
+ {7:│ }ff |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :tabnext |
+ ]])
+ end
+
+ if multigrid then
+ meths.input_mouse('left', 'press', '', 2, 0, 0)
+ screen:expect([[
+ ## grid 1
+ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [2:---------------------------------------------]|
+ [3:---------------------------------------------]|
+ ## grid 2
+ {7:+ }{5:^+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ :tabnext |
+ ## grid 4 (hidden)
+ {7:+ }{5:+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]])
+ else
+ meths.input_mouse('left', 'press', '', 0, 1, 0)
+ screen:expect([[
+ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
+ {7:+ }{5:^+-- 6 lines: aa···························}|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :tabnext |
+ ]])
+ end
+ end)
+
it("works with multibyte text", function()
-- Currently the only allowed value of 'maxcombine'
eq(6, meths.get_option('maxcombine'))
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index 9313a35708..ea8968a653 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -1,16 +1,18 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim
+local clear, feed_command = helpers.clear, helpers.feed_command
local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq
local command = helpers.command
local expect = helpers.expect
+local meths = helpers.meths
+local exec_lua = helpers.exec_lua
local write_file = helpers.write_file
local Screen = require('test.functional.ui.screen')
-describe('mappings', function()
- local cid
+before_each(clear)
+describe('mappings', function()
local add_mapping = function(mapping, send)
- local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '"
+ local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '"
..send:gsub('<', '<lt>').."')<cr>"
feed_command(cmd)
end
@@ -21,8 +23,6 @@ describe('mappings', function()
end
before_each(function()
- clear()
- cid = nvim('get_api_info')[1]
add_mapping('<C-L>', '<C-L>')
add_mapping('<C-S-L>', '<C-S-L>')
add_mapping('<s-up>', '<s-up>')
@@ -115,7 +115,6 @@ describe('mappings', function()
end)
describe('input utf sequences that contain CSI/K_SPECIAL', function()
- before_each(clear)
it('ok', function()
feed('i…<esc>')
expect('…')
@@ -129,7 +128,6 @@ describe('input non-printable chars', function()
it("doesn't crash when echoing them back", function()
write_file("Xtest-overwrite", [[foobar]])
- clear()
local screen = Screen.new(60,8)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
@@ -215,3 +213,27 @@ describe('input non-printable chars', function()
]])
end)
end)
+
+describe("event processing and input", function()
+ it('not blocked by event bursts', function()
+ meths.set_keymap('', '<f2>', "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", {noremap=true})
+
+ exec_lua [[
+ winning = false
+ burst = vim.schedule_wrap(function(tell)
+ if tell then
+ vim.rpcnotify(1, 'start')
+ end
+ -- Are we winning, son?
+ if not winning then
+ burst(false)
+ end
+ end)
+ burst(true)
+ ]]
+
+ eq({'notification', 'start', {}}, next_msg())
+ feed '<f2>'
+ eq({'notification', 'stop', {}}, next_msg())
+ end)
+end)
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 5df4a1d533..1fe3a4128e 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -29,6 +29,7 @@ describe('ui/ext_messages', function()
[6] = {bold = true, reverse = true},
[7] = {background = Screen.colors.Yellow},
[8] = {foreground = Screen.colors.Red},
+ [9] = {special = Screen.colors.Red, undercurl = true},
})
end)
after_each(function()
@@ -795,6 +796,45 @@ describe('ui/ext_messages', function()
pos = 9,
}}}
end)
+
+ it('hides prompt_for_number messages', function()
+ command('set spell')
+ feed('ihelllo<esc>')
+
+ feed('z=')
+ screen:expect{grid=[[
+ {9:helllo} |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:^~ }|
+ ]], messages={
+ {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Helli"\nType number and <Enter> or click with mouse (empty cancels): ' } }, kind = ""}
+ }}
+
+ feed('1')
+ screen:expect{grid=[[
+ {9:helllo} |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:^~ }|
+ ]], messages={
+ {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Helli"\nType number and <Enter> or click with mouse (empty cancels): ' } }, kind = ""},
+ { content = { { "1" } }, kind = "" }
+ }}
+
+ feed('<cr>')
+ screen:expect{grid=[[
+ ^Hello |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]]}
+
+ end)
+
end)
describe('ui/builtin messages', function()