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:
Javier Lopez
2021-11-01 08:46:26 -05:00
committed by GitHub
parent fa97d34858
commit 961cd83b3b
5 changed files with 24 additions and 19 deletions

View File

@@ -2389,7 +2389,7 @@ describe('API', function()
it('works', function()
local buf = meths.create_buf(false,true)
meths.buf_set_lines(buf, -1, -1, true, {'a', 'bit of', 'text'})
eq(true, meths.buf_set_mark(buf, 'F', 2, 2))
eq(true, meths.buf_set_mark(buf, 'F', 2, 2, {}))
eq(true, meths.del_mark('F'))
eq({0, 0}, meths.buf_get_mark(buf, 'F'))
end)
@@ -2403,9 +2403,9 @@ describe('API', function()
it('works', function()
local buf = meths.create_buf(false,true)
meths.buf_set_lines(buf, -1, -1, true, {'a', 'bit of', 'text'})
meths.buf_set_mark(buf, 'F', 2, 2)
meths.buf_set_mark(buf, 'F', 2, 2, {})
meths.buf_set_name(buf, "mybuf")
local mark = meths.get_mark('F')
local mark = meths.get_mark('F', {})
-- Compare the path tail ony
assert(string.find(mark[4], "mybuf$"))
eq({2, 2, buf.id, mark[4]}, mark)
@@ -2417,7 +2417,7 @@ describe('API', function()
end)
it('returns the expected when mark is not set', function()
eq(true, meths.del_mark('A'))
eq({0, 0, 0, ''}, meths.get_mark('A'))
eq({0, 0, 0, ''}, meths.get_mark('A', {}))
end)
it('works with deleted buffers', function()
local fname = tmpname()
@@ -2425,12 +2425,12 @@ describe('API', function()
nvim("command", "edit " .. fname)
local buf = meths.get_current_buf()
meths.buf_set_mark(buf, 'F', 2, 2)
meths.buf_set_mark(buf, 'F', 2, 2, {})
nvim("command", "new") -- Create new buf to avoid :bd failing
nvim("command", "bd! " .. buf.id)
os.remove(fname)
local mark = meths.get_mark('F')
local mark = meths.get_mark('F', {})
-- To avoid comparing relative vs absolute path
local mfname = mark[4]
local tail_patt = [[[\/][^\/]*$]]