aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/buffer_updates_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua/buffer_updates_spec.lua')
-rw-r--r--test/functional/lua/buffer_updates_spec.lua110
1 files changed, 73 insertions, 37 deletions
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 2fd44b8b5f..51e4548edb 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1,6 +1,6 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
-local lfs = require('lfs')
+local luv = require('luv')
local command = helpers.command
local meths = helpers.meths
@@ -317,7 +317,18 @@ describe('lua buffer event callbacks: on_lines', function()
feed('1G0')
feed('P')
eq(meths.get_var('linesev'), { "lines", 1, 6, 0, 3, 3, 9 })
+ end)
+ it('calling nvim_buf_call() from callback does not cause Normal mode CTRL-A to misbehave #16729', function()
+ exec_lua([[
+ vim.api.nvim_buf_attach(0, false, {
+ on_lines = function(...)
+ vim.api.nvim_buf_call(0, function() end)
+ end,
+ })
+ ]])
+ feed('itest123<Esc><C-A>')
+ eq('test124', meths.get_current_line())
end)
end)
@@ -404,7 +415,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('opening lines', function()
local check_events = setup_eventcheck(verify, origlines)
- -- meths.buf_set_option(0, 'autoindent', true)
+ -- meths.set_option_value('autoindent', true, {})
feed 'Go'
check_events {
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 1 };
@@ -417,7 +428,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('opening lines with autoindent', function()
local check_events = setup_eventcheck(verify, origlines)
- meths.buf_set_option(0, 'autoindent', true)
+ meths.set_option_value('autoindent', true, {})
feed 'Go'
check_events {
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 5 };
@@ -451,8 +462,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('continuing comments with fo=or', function()
local check_events = setup_eventcheck(verify, {'// Comment'})
- meths.buf_set_option(0, 'formatoptions', 'ro')
- meths.buf_set_option(0, 'filetype', 'c')
+ meths.set_option_value('formatoptions', 'ro', {})
+ meths.set_option_value('filetype', 'c', {})
feed 'A<CR>'
check_events {
{ "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 };
@@ -592,7 +603,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('inccomand=nosplit and substitute', function()
local check_events = setup_eventcheck(verify,
{"abcde", "12345"})
- meths.set_option('inccommand', 'nosplit')
+ meths.set_option_value('inccommand', 'nosplit', {})
-- linewise substitute
feed(':%s/bcd/')
@@ -743,7 +754,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
write_file("Xtest-reload", dedent [[
old line 1
old line 2]])
- lfs.touch("Xtest-reload", os.time() - 10)
+ local atime = os.time() - 10
+ luv.fs_utime("Xtest-reload", atime, atime)
command "e Xtest-reload"
command "set autoread"
@@ -814,53 +826,53 @@ describe('lua: nvim_buf_attach on_bytes', function()
feed("<esc>u")
check_events {
- { "test1", "bytes", 1, 8, 0, 0, 0, 0, 1, 1, 0, 4, 4 },
- { "test1", "bytes", 1, 8, 0, 0, 0, 0, 4, 4, 0, 0, 0 }
+ { "test1", "bytes", 1, 9, 0, 0, 0, 0, 1, 1, 0, 4, 4 },
+ { "test1", "bytes", 1, 9, 0, 0, 0, 0, 4, 4, 0, 0, 0 }
}
-- in REPLACE mode
feed("R<tab><tab>")
check_events {
- { "test1", "bytes", 1, 9, 0, 0, 0, 0, 1, 1, 0, 1, 1 },
- { "test1", "bytes", 1, 10, 0, 1, 1, 0, 0, 0, 0, 1, 1 },
- { "test1", "bytes", 1, 11, 0, 2, 2, 0, 1, 1, 0, 1, 1 },
- { "test1", "bytes", 1, 12, 0, 3, 3, 0, 0, 0, 0, 1, 1 },
- { "test1", "bytes", 1, 13, 0, 0, 0, 0, 4, 4, 0, 1, 1 },
+ { "test1", "bytes", 1, 10, 0, 0, 0, 0, 1, 1, 0, 1, 1 },
+ { "test1", "bytes", 1, 11, 0, 1, 1, 0, 0, 0, 0, 1, 1 },
+ { "test1", "bytes", 1, 12, 0, 2, 2, 0, 1, 1, 0, 1, 1 },
+ { "test1", "bytes", 1, 13, 0, 3, 3, 0, 0, 0, 0, 1, 1 },
+ { "test1", "bytes", 1, 14, 0, 0, 0, 0, 4, 4, 0, 1, 1 },
}
feed("<esc>u")
check_events {
- { "test1", "bytes", 1, 14, 0, 0, 0, 0, 1, 1, 0, 4, 4 },
- { "test1", "bytes", 1, 14, 0, 2, 2, 0, 2, 2, 0, 1, 1 },
- { "test1", "bytes", 1, 14, 0, 0, 0, 0, 2, 2, 0, 1, 1 }
+ { "test1", "bytes", 1, 16, 0, 0, 0, 0, 1, 1, 0, 4, 4 },
+ { "test1", "bytes", 1, 16, 0, 2, 2, 0, 2, 2, 0, 1, 1 },
+ { "test1", "bytes", 1, 16, 0, 0, 0, 0, 2, 2, 0, 1, 1 }
}
-- in VISUALREPLACE mode
feed("gR<tab><tab>")
check_events {
- { "test1", "bytes", 1, 15, 0, 0, 0, 0, 1, 1, 0, 1, 1 };
- { "test1", "bytes", 1, 16, 0, 1, 1, 0, 1, 1, 0, 1, 1 };
- { "test1", "bytes", 1, 17, 0, 2, 2, 0, 1, 1, 0, 1, 1 };
- { "test1", "bytes", 1, 18, 0, 3, 3, 0, 1, 1, 0, 1, 1 };
- { "test1", "bytes", 1, 19, 0, 3, 3, 0, 1, 1, 0, 0, 0 };
- { "test1", "bytes", 1, 20, 0, 3, 3, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 22, 0, 2, 2, 0, 1, 1, 0, 0, 0 };
- { "test1", "bytes", 1, 23, 0, 2, 2, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 25, 0, 1, 1, 0, 1, 1, 0, 0, 0 };
- { "test1", "bytes", 1, 26, 0, 1, 1, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 28, 0, 0, 0, 0, 1, 1, 0, 0, 0 };
- { "test1", "bytes", 1, 29, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 31, 0, 0, 0, 0, 4, 4, 0, 1, 1 };
+ { "test1", "bytes", 1, 17, 0, 0, 0, 0, 1, 1, 0, 1, 1 };
+ { "test1", "bytes", 1, 18, 0, 1, 1, 0, 1, 1, 0, 1, 1 };
+ { "test1", "bytes", 1, 19, 0, 2, 2, 0, 1, 1, 0, 1, 1 };
+ { "test1", "bytes", 1, 20, 0, 3, 3, 0, 1, 1, 0, 1, 1 };
+ { "test1", "bytes", 1, 21, 0, 3, 3, 0, 1, 1, 0, 0, 0 };
+ { "test1", "bytes", 1, 22, 0, 3, 3, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 24, 0, 2, 2, 0, 1, 1, 0, 0, 0 };
+ { "test1", "bytes", 1, 25, 0, 2, 2, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 27, 0, 1, 1, 0, 1, 1, 0, 0, 0 };
+ { "test1", "bytes", 1, 28, 0, 1, 1, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 30, 0, 0, 0, 0, 1, 1, 0, 0, 0 };
+ { "test1", "bytes", 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 33, 0, 0, 0, 0, 4, 4, 0, 1, 1 };
}
-- inserting tab after other tabs
command("set sw=4")
feed("<esc>0a<tab>")
check_events {
- { "test1", "bytes", 1, 32, 0, 1, 1, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 33, 0, 2, 2, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 34, 0, 3, 3, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 35, 0, 4, 4, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 36, 0, 1, 1, 0, 4, 4, 0, 1, 1 };
+ { "test1", "bytes", 1, 34, 0, 1, 1, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 35, 0, 2, 2, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 36, 0, 3, 3, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 37, 0, 4, 4, 0, 0, 0, 0, 1, 1 };
+ { "test1", "bytes", 1, 38, 0, 1, 1, 0, 4, 4, 0, 1, 1 };
}
end)
@@ -986,7 +998,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it("virtual edit", function ()
local check_events = setup_eventcheck(verify, { "", " " })
- meths.set_option("virtualedit", "all")
+ meths.set_option_value('virtualedit', "all", {})
feed [[<Right><Right>iab<ESC>]]
@@ -1152,12 +1164,36 @@ describe('lua: nvim_buf_attach on_bytes', function()
end)
it("works with accepting spell suggestions", function()
- local check_events = setup_eventcheck(verify, {"hallo"})
+ local check_events = setup_eventcheck(verify, {"hallo world", "hallo world"})
feed("gg0z=4<cr><cr>") -- accepts 'Hello'
check_events {
{ "test1", "bytes", 1, 3, 0, 0, 0, 0, 2, 2, 0, 2, 2 };
}
+
+ command("spellrepall") -- replaces whole words
+ check_events {
+ { "test1", "bytes", 1, 4, 1, 0, 12, 0, 5, 5, 0, 5, 5 };
+ }
+ end)
+
+ it('works with :diffput and :diffget', function()
+ local check_events = setup_eventcheck(verify, {"AAA"})
+ command('diffthis')
+ command('new')
+ command('diffthis')
+ meths.buf_set_lines(0, 0, -1, true, {"AAA", "BBB"})
+ feed('G')
+ command('diffput')
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 4 };
+ }
+ meths.buf_set_lines(0, 0, -1, true, {"AAA", "CCC"})
+ feed('<C-w>pG')
+ command('diffget')
+ check_events {
+ { "test1", "bytes", 1, 4, 1, 0, 4, 1, 0, 4, 1, 0, 4 };
+ }
end)
local function test_lockmarks(mode)