mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
refactor(api/marks)!: add opts param for feature extensibility (#16146)
In the future we might want to extend the concept of named marks and adding opts reduces the need of changing the function signature in the furute.
This commit is contained in:
@@ -711,46 +711,46 @@ describe('api/buf', function()
|
||||
describe('nvim_buf_set_mark', function()
|
||||
it('works with buffer local marks', function()
|
||||
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
|
||||
eq(true, curbufmeths.set_mark('z', 1, 1))
|
||||
eq(true, curbufmeths.set_mark('z', 1, 1, {}))
|
||||
eq({1, 1}, curbufmeths.get_mark('z'))
|
||||
end)
|
||||
it('works with file/uppercase marks', function()
|
||||
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
|
||||
eq(true, curbufmeths.set_mark('Z', 3, 1))
|
||||
eq(true, curbufmeths.set_mark('Z', 3, 1, {}))
|
||||
eq({3, 1}, curbufmeths.get_mark('Z'))
|
||||
end)
|
||||
it('fails when invalid marks names are used', function()
|
||||
eq(false, pcall(curbufmeths.set_mark, '!', 1, 0))
|
||||
eq(false, pcall(curbufmeths.set_mark, 'fail', 1, 0))
|
||||
eq(false, pcall(curbufmeths.set_mark, '!', 1, 0, {}))
|
||||
eq(false, pcall(curbufmeths.set_mark, 'fail', 1, 0, {}))
|
||||
end)
|
||||
it('fails when invalid buffer number is used', function()
|
||||
eq(false, pcall(meths.buf_set_mark, 99, 'a', 1, 1))
|
||||
eq(false, pcall(meths.buf_set_mark, 99, 'a', 1, 1, {}))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_buf_del_mark', function()
|
||||
it('works with buffer local marks', function()
|
||||
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
|
||||
curbufmeths.set_mark('z', 3, 1)
|
||||
curbufmeths.set_mark('z', 3, 1, {})
|
||||
eq(true, curbufmeths.del_mark('z'))
|
||||
eq({0, 0}, curbufmeths.get_mark('z'))
|
||||
end)
|
||||
it('works with file/uppercase marks', function()
|
||||
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
|
||||
curbufmeths.set_mark('Z', 3, 3)
|
||||
curbufmeths.set_mark('Z', 3, 3, {})
|
||||
eq(true, curbufmeths.del_mark('Z'))
|
||||
eq({0, 0}, curbufmeths.get_mark('Z'))
|
||||
end)
|
||||
it('returns false in marks not set in this buffer', function()
|
||||
local abuf = meths.create_buf(false,true)
|
||||
bufmeths.set_lines(abuf, -1, -1, true, {'a', 'bit of', 'text'})
|
||||
bufmeths.set_mark(abuf, 'A', 2, 2)
|
||||
bufmeths.set_mark(abuf, 'A', 2, 2, {})
|
||||
eq(false, curbufmeths.del_mark('A'))
|
||||
eq({2, 2}, bufmeths.get_mark(abuf, 'A'))
|
||||
end)
|
||||
it('returns false if mark was not deleted', function()
|
||||
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
|
||||
curbufmeths.set_mark('z', 3, 1)
|
||||
curbufmeths.set_mark('z', 3, 1, {})
|
||||
eq(true, curbufmeths.del_mark('z'))
|
||||
eq(false, curbufmeths.del_mark('z')) -- Mark was already deleted
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user