aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/extmark_spec.lua9
-rw-r--r--test/functional/core/job_spec.lua1
-rw-r--r--test/functional/lua/buffer_updates_spec.lua147
-rw-r--r--test/functional/lua/treesitter_spec.lua7
-rw-r--r--test/functional/lua/vim_spec.lua25
-rw-r--r--test/functional/ui/cursor_spec.lua17
-rw-r--r--test/functional/ui/fold_spec.lua22
-rw-r--r--test/functional/ui/messages_spec.lua2
8 files changed, 189 insertions, 41 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index a2a188d036..ab913ba4a4 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -100,6 +100,15 @@ describe('API/extmarks', function()
ns2 = request('nvim_create_namespace', "my-fancy-plugin2")
end)
+ it("can end extranges past final newline using end_col = 0", function()
+ set_extmark(ns, marks[1], 0, 0, {
+ end_col = 0,
+ end_line = 1
+ })
+ eq("end_col value outside range",
+ pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_line = 1 }))
+ end)
+
it('adds, updates and deletes marks', function()
local rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2])
eq(marks[1], rv)
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 57e6f4fd63..1155f12ffc 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -93,6 +93,7 @@ describe('jobs', function()
{'notification', 'stdout', {0, {'hello world %VAR%', ''}}}
})
else
+ nvim('command', "set shell=/bin/sh")
nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
expect_msg_seq({
{'notification', 'stdout', {0, {'hello world', ''}}}
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 5be47070a7..439cc12192 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -5,6 +5,7 @@ local inspect = require'vim.inspect'
local command = helpers.command
local meths = helpers.meths
+local funcs = helpers.funcs
local clear = helpers.clear
local eq = helpers.eq
local fail = helpers.fail
@@ -256,9 +257,9 @@ describe('lua: nvim_buf_attach on_bytes', function()
-- 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)
- meths.buf_set_lines(0, 0, -1, true, origlines)
- local shadow = deepcopy(origlines)
+ 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'
-- TODO: while we are brewing the real strong coffe,
-- verify should check buf_get_offset after every check_events
@@ -273,7 +274,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
local events = exec_lua("return get_events(...)" )
if not pcall(eq, expected, events) then
- local msg = 'unexpected byte updates received.\n\nBABBLA MER \n\n'
+ local msg = 'unexpected byte updates received.\n\n'
msg = msg .. 'received events:\n'
for _, e in ipairs(events) do
@@ -286,26 +287,36 @@ describe('lua: nvim_buf_attach on_bytes', function()
fail(msg)
end
- if verify then
- for _, event in ipairs(events) do
- if event[1] == verify_name and event[2] == "bytes" then
- local _, _, _, _, _, _, start_byte, _, _, old_byte, _, _, new_byte = unpack(event)
- local before = string.sub(shadowbytes, 1, start_byte)
- -- no text in the tests will contain 0xff bytes (invalid UTF-8)
- -- so we can use it as marker for unknown bytes
- local unknown = string.rep('\255', new_byte)
- local after = string.sub(shadowbytes, start_byte + old_byte + 1)
- shadowbytes = before .. unknown .. after
+ if not verify then
+ return
+ end
+
+ for _, event in ipairs(events) do
+ for _, elem in ipairs(event) do
+ if type(elem) == "number" and elem < 0 then
+ fail(string.format("Received event has negative values"))
end
end
- local text = meths.buf_get_lines(0, 0, -1, true)
- local bytes = table.concat(text, '\n') .. '\n'
- eq(string.len(bytes), string.len(shadowbytes), shadowbytes)
- for i = 1, string.len(shadowbytes) do
- local shadowbyte = string.sub(shadowbytes, i, i)
- if shadowbyte ~= '\255' then
- eq(string.sub(bytes, i, i), shadowbyte, i)
- end
+
+ if event[1] == verify_name and event[2] == "bytes" then
+ local _, _, _, _, _, _, start_byte, _, _, old_byte, _, _, new_byte = unpack(event)
+ local before = string.sub(shadowbytes, 1, start_byte)
+ -- no text in the tests will contain 0xff bytes (invalid UTF-8)
+ -- so we can use it as marker for unknown bytes
+ local unknown = string.rep('\255', new_byte)
+ local after = string.sub(shadowbytes, start_byte + old_byte + 1)
+ shadowbytes = before .. unknown .. after
+ end
+ end
+
+ local text = meths.buf_get_lines(0, 0, -1, true)
+ local bytes = table.concat(text, '\n') .. '\n'
+
+ eq(string.len(bytes), string.len(shadowbytes), '\non_bytes: total bytecount of buffer is wrong')
+ for i = 1, string.len(shadowbytes) do
+ local shadowbyte = string.sub(shadowbytes, i, i)
+ if shadowbyte ~= '\255' then
+ eq(string.sub(bytes, i, i), shadowbyte, i)
end
end
end
@@ -316,7 +327,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
-- Yes, we can do both
local function do_both(verify)
it('single and multiple join', function()
- local check_events = setup_eventcheck(verify)
+ local check_events = setup_eventcheck(verify, origlines)
feed 'ggJ'
check_events {
{'test1', 'bytes', 1, 3, 0, 15, 15, 1, 0, 1, 0, 1, 1};
@@ -330,7 +341,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
end)
it('opening lines', function()
- local check_events = setup_eventcheck(verify)
+ local check_events = setup_eventcheck(verify, origlines)
-- meths.buf_set_option(0, 'autoindent', true)
feed 'Go'
check_events {
@@ -343,7 +354,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
end)
it('opening lines with autoindent', function()
- local check_events = setup_eventcheck(verify)
+ local check_events = setup_eventcheck(verify, origlines)
meths.buf_set_option(0, 'autoindent', true)
feed 'Go'
check_events {
@@ -355,6 +366,92 @@ describe('lua: nvim_buf_attach on_bytes', function()
{ "test1", "bytes", 1, 5, 7, 4, 118, 0, 0, 0, 1, 4, 5 };
}
end)
+
+ it('setline(num, line)', function()
+ local check_events = setup_eventcheck(verify, origlines)
+ funcs.setline(2, "babla")
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 16, 0, 15, 15, 0, 5, 5 };
+ }
+
+ funcs.setline(2, {"foo", "bar"})
+ check_events {
+ { "test1", "bytes", 1, 4, 1, 0, 16, 0, 5, 5, 0, 3, 3 };
+ { "test1", "bytes", 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 };
+ }
+
+ local buf_len = meths.buf_line_count(0)
+ funcs.setline(buf_len + 1, "baz")
+ check_events {
+ { "test1", "bytes", 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 };
+ }
+ end)
+
+ it('continuing comments with fo=or', function()
+ local check_events = setup_eventcheck(verify, {'// Comment'})
+ meths.buf_set_option(0, 'formatoptions', 'ro')
+ meths.buf_set_option(0, 'filetype', 'c')
+ feed 'A<CR>'
+ check_events {
+ { "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 };
+ }
+
+ feed '<ESC>'
+ check_events {
+ { "test1", "bytes", 1, 4, 1, 2, 13, 0, 1, 1, 0, 0, 0 };
+ }
+
+ feed 'ggo' -- goto first line to continue testing
+ check_events {
+ { "test1", "bytes", 1, 6, 1, 0, 11, 0, 0, 0, 1, 0, 4 };
+ }
+
+ feed '<CR>'
+ check_events {
+ { "test1", "bytes", 1, 6, 2, 2, 16, 0, 1, 1, 0, 0, 0 };
+ { "test1", "bytes", 1, 7, 1, 3, 14, 0, 0, 0, 1, 3, 4 };
+ }
+ end)
+
+ it('editing empty buffers', function()
+ local check_events = setup_eventcheck(verify, {})
+
+ feed 'ia'
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
+ }
+ end)
+
+ it("changing lines", function()
+ local check_events = setup_eventcheck(verify, origlines)
+
+ feed "cc"
+ check_events {
+ { "test1", "bytes", 1, 4, 0, 0, 0, 0, 15, 15, 0, 0, 0 };
+ }
+
+ feed "<ESC>"
+ check_events {}
+
+ feed "c3j"
+ check_events {
+ { "test1", "bytes", 1, 4, 1, 0, 1, 3, 0, 48, 0, 0, 0 };
+ }
+ end)
+
+ it("visual charwise paste", function()
+ local check_events = setup_eventcheck(verify, {'1234567890'})
+ funcs.setreg('a', '___')
+
+ feed '1G1|vll'
+ check_events {}
+
+ feed '"ap'
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 3, 3, 0, 0, 0 };
+ { "test1", "bytes", 1, 5, 0, 0, 0, 0, 0, 0, 0, 3, 3 };
+ }
+ end)
end
describe('(with verify) handles', function()
diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua
index 2c9107a65a..128545b472 100644
--- a/test/functional/lua/treesitter_spec.lua
+++ b/test/functional/lua/treesitter_spec.lua
@@ -446,10 +446,7 @@ static int nlua_schedule(lua_State *const lstate)
]]}
feed("5Goc<esc>dd")
- if true == true then
- pending('reenable this check in luahl PR')
- return
- end
+
screen:expect{grid=[[
{2:/// Schedule Lua callback on main loop's event queue} |
{3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) |
@@ -480,7 +477,7 @@ static int nlua_schedule(lua_State *const lstate)
|| {6:lstate} != {6:lstate}) { |
{11:lua_pushliteral}(lstate, {5:"vim.schedule: expected function"}); |
{4:return} {11:lua_error}(lstate); |
- *^/ |
+ {8:*^/} |
} |
|
{7:LuaRef} cb = {11:nlua_ref}(lstate, {5:1}); |
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index a9e8ca9686..61447f1152 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -1330,4 +1330,29 @@ describe('lua stdlib', function()
eq(false, pcall_result)
end)
end)
+
+ describe('vim.api.nvim_buf_call', function()
+ it('can access buf options', function()
+ local buf1 = meths.get_current_buf()
+ local buf2 = exec_lua [[
+ buf2 = vim.api.nvim_create_buf(false, true)
+ return buf2
+ ]]
+
+ eq(false, meths.buf_get_option(buf1, 'autoindent'))
+ eq(false, meths.buf_get_option(buf2, 'autoindent'))
+
+ local val = exec_lua [[
+ return vim.api.nvim_buf_call(buf2, function()
+ vim.cmd "set autoindent"
+ return vim.api.nvim_get_current_buf()
+ end)
+ ]]
+
+ eq(false, meths.buf_get_option(buf1, 'autoindent'))
+ eq(true, meths.buf_get_option(buf2, 'autoindent'))
+ eq(buf1, meths.get_current_buf())
+ eq(buf2, val)
+ end)
+ end)
end)
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 6c913124ac..e1a72ced05 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -286,6 +286,21 @@ describe('ui/cursor', function()
eq(173, named.normal.blinkon)
eq(42, named.showmatch.cell_percentage)
end)
+
+ -- If there is no setting for guicursor, it becomes the default setting.
+ meths.set_option('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor')
+ screen:expect(function()
+ for _,m in ipairs(screen._mode_info) do
+ if m.name ~= 'normal' then
+ eq('block', m.cursor_shape or 'block')
+ eq(0, m.blinkon or 0)
+ eq(0, m.blinkoff or 0)
+ eq(0, m.blinkwait or 0)
+ eq(0, m.hl_id or 0)
+ eq(0, m.id_lm or 0)
+ end
+ end
+ end)
end)
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
@@ -297,6 +312,8 @@ describe('ui/cursor', function()
if m['cursor_shape'] ~= nil then
eq('block', m.cursor_shape)
eq(0, m.blinkon)
+ eq(0, m.hl_id)
+ eq(0, m.id_lm)
end
end
end)
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 6ec45064da..fe67b9f6b0 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -21,6 +21,8 @@ describe("folded lines", function()
[5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
[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}
})
end)
@@ -29,7 +31,7 @@ describe("folded lines", function()
feed("i<cr><esc>")
feed("vkzf")
screen:expect([[
- {5: ^+-- 2 lines: ·············}|
+ {7: }{5:^+-- 2 lines: ·············}|
{1:~ }|
{1:~ }|
{1:~ }|
@@ -49,8 +51,8 @@ describe("folded lines", function()
funcs.setline(4, 'line 2')
feed("j")
screen:expect([[
- {7:+ }{5: 1 +-- 2 lines: ·························}|
- {7:+ }{5: 0 ^+-- 2 lines: ·························}|
+ {7:+ }{8: 1 }{5:+-- 2 lines: ·························}|
+ {7:+ }{9: 0 }{5:^+-- 2 lines: ·························}|
{1:~ }|
{1:~ }|
{1:~ }|
@@ -130,8 +132,8 @@ describe("folded lines", function()
]])
feed('vkzf')
- screen:expect([[
- {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}|
+ screen:expect{grid=[[
+ {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}|
{1:~ }|
{1:~ }|
{1:~ }|
@@ -139,7 +141,7 @@ describe("folded lines", function()
{1:~ }|
{1:~ }|
|
- ]])
+ ]]}
feed_command("set noarabicshape")
screen:expect([[
@@ -155,7 +157,7 @@ describe("folded lines", function()
feed_command("set number foldcolumn=2")
screen:expect([[
- {7:+ }{5: 1 ^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}|
+ {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}|
{1:~ }|
{1:~ }|
{1:~ }|
@@ -168,7 +170,7 @@ describe("folded lines", function()
-- Note: too much of the folded line gets cut off.This is a vim bug.
feed_command("set rightleft")
screen:expect([[
- {5:+-- 2 lines: å ······················^· 1 }{7: +}|
+ {5:···········ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}{8: 1 }{7: +}|
{1: ~}|
{1: ~}|
{1: ~}|
@@ -180,7 +182,7 @@ describe("folded lines", function()
feed_command("set nonumber foldcolumn=0")
screen:expect([[
- {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ال·····················^·}|
+ {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}|
{1: ~}|
{1: ~}|
{1: ~}|
@@ -192,7 +194,7 @@ describe("folded lines", function()
feed_command("set arabicshape")
screen:expect([[
- {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺍﻟ·····················^·}|
+ {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}|
{1: ~}|
{1: ~}|
{1: ~}|
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index efc02db159..5df4a1d533 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -323,7 +323,7 @@ describe('ui/ext_messages', function()
{1:~ }|
{1:~ }|
]], messages={
- {content = {{"/line [1/2] W"}}, kind = "search_count"}
+ {content = {{"/line W [1/2]"}}, kind = "search_count"}
}}
feed('n')