aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-11-09 12:41:50 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-11-11 20:18:15 +0100
commit18a8b702c0ce7a8bacd84f6c95e440ae23a3299e (patch)
treecd3bbe1bfe009ce75633793b028da2ce0ed35ef2 /test/functional/api
parenta9065a50518ef59351f9d0d32041a991a751653f (diff)
downloadrneovim-18a8b702c0ce7a8bacd84f6c95e440ae23a3299e.tar.gz
rneovim-18a8b702c0ce7a8bacd84f6c95e440ae23a3299e.tar.bz2
rneovim-18a8b702c0ce7a8bacd84f6c95e440ae23a3299e.zip
extmark: review changes
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/mark_extended_spec.lua624
1 files changed, 314 insertions, 310 deletions
diff --git a/test/functional/api/mark_extended_spec.lua b/test/functional/api/mark_extended_spec.lua
index 6bf0e59133..a5d68c6b9f 100644
--- a/test/functional/api/mark_extended_spec.lua
+++ b/test/functional/api/mark_extended_spec.lua
@@ -1,7 +1,3 @@
--- TODO(timeyyy): go through todo's lol
--- change representation of stored marks to have location start at 0
--- check with memsan, asan etc
-
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
@@ -9,17 +5,14 @@ local request = helpers.request
local eq = helpers.eq
local ok = helpers.ok
local curbufmeths = helpers.curbufmeths
-local meth_pcall = helpers.meth_pcall
+local pcall_err = helpers.pcall_err
local insert = helpers.insert
local feed = helpers.feed
local clear = helpers.clear
-
-local ALL = -1
-
-local rv = nil
+local command = helpers.command
local function check_undo_redo(ns, mark, sr, sc, er, ec) --s = start, e = end
- rv = curbufmeths.get_extmark_by_id(ns, mark)
+ local rv = curbufmeths.get_extmark_by_id(ns, mark)
eq({er, ec}, rv)
feed("u")
rv = curbufmeths.get_extmark_by_id(ns, mark)
@@ -29,6 +22,20 @@ local function check_undo_redo(ns, mark, sr, sc, er, ec) --s = start, e = end
eq({er, ec}, rv)
end
+local function set_extmark(ns_id, id, line, col, opts)
+ if opts == nil then
+ opts = {}
+ end
+ return curbufmeths.set_extmark(ns_id, id, line, col, opts)
+end
+
+local function get_extmarks(ns_id, start, end_, opts)
+ if opts == nil then
+ opts = {}
+ end
+ return curbufmeths.get_extmarks(ns_id, start, end_, opts)
+end
+
describe('Extmarks buffer api', function()
local screen
local marks, positions, ns_string2, ns_string, init_text, row, col
@@ -55,24 +62,24 @@ describe('Extmarks buffer api', function()
end)
it('adds, updates and deletes marks #extmarks', function()
- rv = curbufmeths.set_extmark(ns, marks[1], positions[1][1], positions[1][2])
+ local rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2])
eq(marks[1], rv)
rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({positions[1][1], positions[1][2]}, rv)
-- Test adding a second mark on same row works
- rv = curbufmeths.set_extmark(ns, marks[2], positions[2][1], positions[2][2])
+ rv = set_extmark(ns, marks[2], positions[2][1], positions[2][2])
eq(marks[2], rv)
-- Test an update, (same pos)
- rv = curbufmeths.set_extmark(ns, marks[1], positions[1][1], positions[1][2])
- eq(0, rv)
+ rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2])
+ eq(marks[1], rv)
rv = curbufmeths.get_extmark_by_id(ns, marks[2])
eq({positions[2][1], positions[2][2]}, rv)
-- Test an update, (new pos)
row = positions[1][1]
col = positions[1][2] + 1
- rv = curbufmeths.set_extmark(ns, marks[1], row, col)
- eq(0, rv)
+ rv = set_extmark(ns, marks[1], row, col)
+ eq(marks[1], rv)
rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({row, col}, rv)
@@ -85,50 +92,50 @@ describe('Extmarks buffer api', function()
end)
it('can clear a specific namespace range #extmarks', function()
- curbufmeths.set_extmark(ns, 1, 0, 1)
- curbufmeths.set_extmark(ns2, 1, 0, 1)
+ set_extmark(ns, 1, 0, 1)
+ set_extmark(ns2, 1, 0, 1)
-- force a new undo buffer
feed('o<esc>')
curbufmeths.clear_namespace(ns2, 0, -1)
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({{1, 0, 1}}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({}, get_extmarks(ns2, {0, 0}, {-1, -1}))
feed('u')
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({{1, 0, 1}}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({{1, 0, 1}}, get_extmarks(ns2, {0, 0}, {-1, -1}))
feed('<c-r>')
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({{1, 0, 1}}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({}, get_extmarks(ns2, {0, 0}, {-1, -1}))
end)
- it('can clear a namespace range using ALL #extmarks', function()
- curbufmeths.set_extmark(ns, 1, 0, 1)
- curbufmeths.set_extmark(ns2, 1, 0, 1)
+ it('can clear a namespace range using 0,-1 #extmarks', function()
+ set_extmark(ns, 1, 0, 1)
+ set_extmark(ns2, 1, 0, 1)
-- force a new undo buffer
feed('o<esc>')
curbufmeths.clear_namespace(-1, 0, -1)
- eq({}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({}, get_extmarks(ns2, {0, 0}, {-1, -1}))
feed('u')
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({{1, 0, 1}}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({{1, 0, 1}}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({{1, 0, 1}}, get_extmarks(ns2, {0, 0}, {-1, -1}))
feed('<c-r>')
- eq({}, curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL))
- eq({}, curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL))
+ eq({}, get_extmarks(ns, {0, 0}, {-1, -1}))
+ eq({}, get_extmarks(ns2, {0, 0}, {-1, -1}))
end)
it('querying for information and ranges #extmarks', function()
-- add some more marks
for i, m in ipairs(marks) do
if positions[i] ~= nil then
- rv = curbufmeths.set_extmark(ns, m, positions[i][1], positions[i][2])
+ local rv = set_extmark(ns, m, positions[i][1], positions[i][2])
eq(m, rv)
end
end
-- {0, 0} and {-1, -1} work as extreme values
- eq({{1, 0, 0}}, curbufmeths.get_extmarks(ns, {0, 0}, {0, 0}, ALL))
- eq({}, curbufmeths.get_extmarks(ns, {-1, -1}, {-1, -1}, ALL))
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ eq({{1, 0, 0}}, get_extmarks(ns, {0, 0}, {0, 0}))
+ eq({}, get_extmarks(ns, {-1, -1}, {-1, -1}))
+ local rv = get_extmarks(ns, {0, 0}, {-1, -1})
for i, m in ipairs(marks) do
if positions[i] ~= nil then
eq({m, positions[i][1], positions[i][2]}, rv[i])
@@ -136,9 +143,9 @@ describe('Extmarks buffer api', function()
end
-- 0 and -1 works as short hand extreme values
- eq({{1, 0, 0}}, curbufmeths.get_extmarks(ns, 0, 0, ALL))
- eq({}, curbufmeths.get_extmarks(ns, -1, -1, ALL))
- rv = curbufmeths.get_extmarks(ns, 0, -1, ALL)
+ eq({{1, 0, 0}}, get_extmarks(ns, 0, 0))
+ eq({}, get_extmarks(ns, -1, -1))
+ rv = get_extmarks(ns, 0, -1)
for i, m in ipairs(marks) do
if positions[i] ~= nil then
eq({m, positions[i][1], positions[i][2]}, rv[i])
@@ -146,91 +153,91 @@ describe('Extmarks buffer api', function()
end
-- next with mark id
- rv = curbufmeths.get_extmarks(ns, marks[1], {-1, -1}, 1)
+ rv = get_extmarks(ns, marks[1], {-1, -1}, {amount=1})
eq({{marks[1], positions[1][1], positions[1][2]}}, rv)
- rv = curbufmeths.get_extmarks(ns, marks[2], {-1, -1}, 1)
+ rv = get_extmarks(ns, marks[2], {-1, -1}, {amount=1})
eq({{marks[2], positions[2][1], positions[2][2]}}, rv)
-- next with positional when mark exists at position
- rv = curbufmeths.get_extmarks(ns, positions[1], {-1, -1}, 1)
+ rv = get_extmarks(ns, positions[1], {-1, -1}, {amount=1})
eq({{marks[1], positions[1][1], positions[1][2]}}, rv)
-- next with positional index (no mark at position)
- rv = curbufmeths.get_extmarks(ns, {positions[1][1], positions[1][2] +1}, {-1, -1}, 1)
+ rv = get_extmarks(ns, {positions[1][1], positions[1][2] +1}, {-1, -1}, {amount=1})
eq({{marks[2], positions[2][1], positions[2][2]}}, rv)
-- next with Extremity index
- rv = curbufmeths.get_extmarks(ns, {0,0}, {-1, -1}, 1)
+ rv = get_extmarks(ns, {0,0}, {-1, -1}, {amount=1})
eq({{marks[1], positions[1][1], positions[1][2]}}, rv)
-- nextrange with mark id
- rv = curbufmeths.get_extmarks(ns, marks[1], marks[3], ALL)
+ rv = get_extmarks(ns, marks[1], marks[3])
eq({marks[1], positions[1][1], positions[1][2]}, rv[1])
eq({marks[2], positions[2][1], positions[2][2]}, rv[2])
-- nextrange with amount
- rv = curbufmeths.get_extmarks(ns, marks[1], marks[3], 2)
+ rv = get_extmarks(ns, marks[1], marks[3], {amount=2})
eq(2, table.getn(rv))
-- nextrange with positional when mark exists at position
- rv = curbufmeths.get_extmarks(ns, positions[1], positions[3], ALL)
+ rv = get_extmarks(ns, positions[1], positions[3])
eq({marks[1], positions[1][1], positions[1][2]}, rv[1])
eq({marks[2], positions[2][1], positions[2][2]}, rv[2])
- rv = curbufmeths.get_extmarks(ns, positions[2], positions[3], ALL)
+ rv = get_extmarks(ns, positions[2], positions[3])
eq(2, table.getn(rv))
-- nextrange with positional index (no mark at position)
local lower = {positions[1][1], positions[2][2] -1}
local upper = {positions[2][1], positions[3][2] - 1}
- rv = curbufmeths.get_extmarks(ns, lower, upper, ALL)
+ rv = get_extmarks(ns, lower, upper)
eq({{marks[2], positions[2][1], positions[2][2]}}, rv)
lower = {positions[3][1], positions[3][2] + 1}
upper = {positions[3][1], positions[3][2] + 2}
- rv = curbufmeths.get_extmarks(ns, lower, upper, ALL)
+ rv = get_extmarks(ns, lower, upper)
eq({}, rv)
-- nextrange with extremity index
lower = {positions[2][1], positions[2][2]+1}
upper = {-1, -1}
- rv = curbufmeths.get_extmarks(ns, lower, upper, ALL)
+ rv = get_extmarks(ns, lower, upper)
eq({{marks[3], positions[3][1], positions[3][2]}}, rv)
-- prev with mark id
- rv = curbufmeths.get_extmarks(ns, marks[3], {0, 0}, 1)
+ rv = get_extmarks(ns, marks[3], {0, 0}, {amount=1})
eq({{marks[3], positions[3][1], positions[3][2]}}, rv)
- rv = curbufmeths.get_extmarks(ns, marks[2], {0, 0}, 1)
+ rv = get_extmarks(ns, marks[2], {0, 0}, {amount=1})
eq({{marks[2], positions[2][1], positions[2][2]}}, rv)
-- prev with positional when mark exists at position
- rv = curbufmeths.get_extmarks(ns, positions[3], {0, 0}, 1)
+ rv = get_extmarks(ns, positions[3], {0, 0}, {amount=1})
eq({{marks[3], positions[3][1], positions[3][2]}}, rv)
-- prev with positional index (no mark at position)
- rv = curbufmeths.get_extmarks(ns, {positions[1][1], positions[1][2] +1}, {0, 0}, 1)
+ rv = get_extmarks(ns, {positions[1][1], positions[1][2] +1}, {0, 0}, {amount=1})
eq({{marks[1], positions[1][1], positions[1][2]}}, rv)
-- prev with Extremity index
- rv = curbufmeths.get_extmarks(ns, {-1,-1}, {0,0}, 1)
+ rv = get_extmarks(ns, {-1,-1}, {0,0}, {amount=1})
eq({{marks[3], positions[3][1], positions[3][2]}}, rv)
-- prevrange with mark id
- rv = curbufmeths.get_extmarks(ns, marks[3], marks[1], ALL)
+ rv = get_extmarks(ns, marks[3], marks[1])
eq({marks[3], positions[3][1], positions[3][2]}, rv[1])
eq({marks[2], positions[2][1], positions[2][2]}, rv[2])
eq({marks[1], positions[1][1], positions[1][2]}, rv[3])
-- prevrange with amount
- rv = curbufmeths.get_extmarks(ns, marks[3], marks[1], 2)
+ rv = get_extmarks(ns, marks[3], marks[1], {amount=2})
eq(2, table.getn(rv))
-- prevrange with positional when mark exists at position
- rv = curbufmeths.get_extmarks(ns, positions[3], positions[1], ALL)
+ rv = get_extmarks(ns, positions[3], positions[1])
eq({{marks[3], positions[3][1], positions[3][2]},
{marks[2], positions[2][1], positions[2][2]},
{marks[1], positions[1][1], positions[1][2]}}, rv)
- rv = curbufmeths.get_extmarks(ns, positions[2], positions[1], ALL)
+ rv = get_extmarks(ns, positions[2], positions[1])
eq(2, table.getn(rv))
-- prevrange with positional index (no mark at position)
lower = {positions[2][1], positions[2][2] + 1}
upper = {positions[3][1], positions[3][2] + 1}
- rv = curbufmeths.get_extmarks(ns, upper, lower, ALL)
+ rv = get_extmarks(ns, upper, lower)
eq({{marks[3], positions[3][1], positions[3][2]}}, rv)
lower = {positions[3][1], positions[3][2] + 1}
upper = {positions[3][1], positions[3][2] + 2}
- rv = curbufmeths.get_extmarks(ns, upper, lower, ALL)
+ rv = get_extmarks(ns, upper, lower)
eq({}, rv)
-- prevrange with extremity index
lower = {0,0}
upper = {positions[2][1], positions[2][2] - 1}
- rv = curbufmeths.get_extmarks(ns, upper, lower, ALL)
+ rv = get_extmarks(ns, upper, lower)
eq({{marks[1], positions[1][1], positions[1][2]}}, rv)
end)
@@ -238,50 +245,50 @@ describe('Extmarks buffer api', function()
-- add some more marks
for i, m in ipairs(marks) do
if positions[i] ~= nil then
- rv = curbufmeths.set_extmark(ns, m, positions[i][1], positions[i][2])
+ local rv = set_extmark(ns, m, positions[i][1], positions[i][2])
eq(m, rv)
end
end
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 1)
+ local rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=1})
eq(1, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 2)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=2})
eq(2, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 3)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=3})
eq(3, table.getn(rv))
-- now in reverse
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 1)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=1})
eq(1, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 2)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=2})
eq(2, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, 3)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1}, {amount=3})
eq(3, table.getn(rv))
end)
it('get_marks works when mark col > upper col #extmarks', function()
feed('A<cr>12345<esc>')
feed('A<cr>12345<esc>')
- curbufmeths.set_extmark(ns, 10, 0, 2) -- this shouldn't be found
- curbufmeths.set_extmark(ns, 11, 2, 1) -- this shouldn't be found
- curbufmeths.set_extmark(ns, marks[1], 0, 4) -- check col > our upper bound
- curbufmeths.set_extmark(ns, marks[2], 1, 1) -- check col < lower bound
- curbufmeths.set_extmark(ns, marks[3], 2, 0) -- check is inclusive
+ set_extmark(ns, 10, 0, 2) -- this shouldn't be found
+ set_extmark(ns, 11, 2, 1) -- this shouldn't be found
+ set_extmark(ns, marks[1], 0, 4) -- check col > our upper bound
+ set_extmark(ns, marks[2], 1, 1) -- check col < lower bound
+ set_extmark(ns, marks[3], 2, 0) -- check is inclusive
eq({{marks[1], 0, 4},
{marks[2], 1, 1},
{marks[3], 2, 0}},
- curbufmeths.get_extmarks(ns, {0, 3}, {2, 0}, -1))
+ get_extmarks(ns, {0, 3}, {2, 0}))
end)
it('get_marks works in reverse when mark col < lower col #extmarks', function()
feed('A<cr>12345<esc>')
feed('A<cr>12345<esc>')
- curbufmeths.set_extmark(ns, 10, 0, 1) -- this shouldn't be found
- curbufmeths.set_extmark(ns, 11, 2, 4) -- this shouldn't be found
- curbufmeths.set_extmark(ns, marks[1], 2, 1) -- check col < our lower bound
- curbufmeths.set_extmark(ns, marks[2], 1, 4) -- check col > upper bound
- curbufmeths.set_extmark(ns, marks[3], 0, 2) -- check is inclusive
- rv = curbufmeths.get_extmarks(ns, {2, 3}, {0, 2}, -1)
+ set_extmark(ns, 10, 0, 1) -- this shouldn't be found
+ set_extmark(ns, 11, 2, 4) -- this shouldn't be found
+ set_extmark(ns, marks[1], 2, 1) -- check col < our lower bound
+ set_extmark(ns, marks[2], 1, 4) -- check col > upper bound
+ set_extmark(ns, marks[3], 0, 2) -- check is inclusive
+ local rv = get_extmarks(ns, {2, 3}, {0, 2})
eq({{marks[1], 2, 1},
{marks[2], 1, 4},
{marks[3], 0, 2}},
@@ -289,21 +296,21 @@ describe('Extmarks buffer api', function()
end)
it('get_marks amount 0 returns nothing #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], positions[1][1], positions[1][2])
- rv = curbufmeths.get_extmarks(ns, {-1, -1}, {-1, -1}, 0)
+ set_extmark(ns, marks[1], positions[1][1], positions[1][2])
+ local rv = get_extmarks(ns, {-1, -1}, {-1, -1}, {amount=0})
eq({}, rv)
end)
it('marks move with line insertations #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 0)
+ set_extmark(ns, marks[1], 0, 0)
feed("yyP")
check_undo_redo(ns, marks[1], 0, 0, 1, 0)
end)
it('marks move with multiline insertations #extmarks', function()
feed("a<cr>22<cr>33<esc>")
- curbufmeths.set_extmark(ns, marks[1], 1, 1)
+ set_extmark(ns, marks[1], 1, 1)
feed('ggVGyP')
check_undo_redo(ns, marks[1], 1, 1, 4, 1)
end)
@@ -311,7 +318,7 @@ describe('Extmarks buffer api', function()
it('marks move with line join #extmarks', function()
-- do_join in ops.c
feed("a<cr>222<esc>")
- curbufmeths.set_extmark(ns, marks[1], 1, 0)
+ set_extmark(ns, marks[1], 1, 0)
feed('ggJ')
check_undo_redo(ns, marks[1], 1, 0, 0, 6)
end)
@@ -337,21 +344,21 @@ describe('Extmarks buffer api', function()
it('marks move with multiline join #extmarks', function()
-- do_join in ops.c
feed("a<cr>222<cr>333<cr>444<esc>")
- curbufmeths.set_extmark(ns, marks[1], 3, 0)
+ set_extmark(ns, marks[1], 3, 0)
feed('2GVGJ')
check_undo_redo(ns, marks[1], 3, 0, 1, 8)
end)
it('marks move with line deletes #extmarks', function()
feed("a<cr>222<cr>333<cr>444<esc>")
- curbufmeths.set_extmark(ns, marks[1], 2, 1)
+ set_extmark(ns, marks[1], 2, 1)
feed('ggjdd')
check_undo_redo(ns, marks[1], 2, 1, 1, 1)
end)
it('marks move with multiline deletes #extmarks', function()
feed("a<cr>222<cr>333<cr>444<esc>")
- curbufmeths.set_extmark(ns, marks[1], 3, 0)
+ set_extmark(ns, marks[1], 3, 0)
feed('gg2dd')
check_undo_redo(ns, marks[1], 3, 0, 1, 0)
-- regression test, undoing multiline delete when mark is on row 1
@@ -363,8 +370,8 @@ describe('Extmarks buffer api', function()
-- open_line in misc1.c
-- testing marks below are also moved
feed("yyP")
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
- curbufmeths.set_extmark(ns, marks[2], 1, 4)
+ set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[2], 1, 4)
feed('1G<s-o><esc>')
check_undo_redo(ns, marks[1], 0, 4, 1, 4)
check_undo_redo(ns, marks[2], 1, 4, 2, 4)
@@ -373,10 +380,9 @@ describe('Extmarks buffer api', function()
check_undo_redo(ns, marks[2], 2, 4, 3, 4)
end)
- -- NO idea why this doesn't work... works in program.
- pending('marks move with char inserts #extmarks', function()
+ it('marks move with char inserts #extmarks', function()
-- insertchar in edit.c (the ins_str branch)
- curbufmeths.set_extmark(ns, marks[1], 1, 3)
+ set_extmark(ns, marks[1], 0, 3)
feed('0')
insert('abc')
screen:expect([[
@@ -391,16 +397,15 @@ describe('Extmarks buffer api', function()
~ |
|
]])
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
- eq(1, rv[2])
- eq(6, rv[3])
+ local rv = curbufmeths.get_extmark_by_id(ns, marks[1])
+ eq({0, 6}, rv)
-- check_undo_redo(ns, marks[1], 0, 2, 0, 5)
end)
-- gravity right as definted in tk library
it('marks have gravity right #extmarks', function()
-- insertchar in edit.c (the ins_str branch)
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('03l')
insert("X")
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
@@ -414,7 +419,7 @@ describe('Extmarks buffer api', function()
it('we can insert multibyte chars #extmarks', function()
-- insertchar in edit.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 2)
+ set_extmark(ns, marks[1], 1, 2)
-- Insert a fullwidth (two col) tilde, NICE
feed('0i~<esc>')
check_undo_redo(ns, marks[1], 1, 2, 1, 3)
@@ -423,7 +428,7 @@ describe('Extmarks buffer api', function()
it('marks move with blockwise inserts #extmarks', function()
-- op_insert in ops.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 2)
+ set_extmark(ns, marks[1], 1, 2)
feed('0<c-v>lkI9<esc>')
check_undo_redo(ns, marks[1], 1, 2, 1, 3)
end)
@@ -432,18 +437,16 @@ describe('Extmarks buffer api', function()
-- open_line in misc1.c
-- testing marks below are also moved
feed("yyP")
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
- curbufmeths.set_extmark(ns, marks[2], 1, 4)
+ set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[2], 1, 4)
feed('1Gla<cr><esc>')
check_undo_redo(ns, marks[1], 0, 4, 1, 2)
check_undo_redo(ns, marks[2], 1, 4, 2, 4)
end)
- -- TODO mark_col_adjust for normal marks fails in vim/neovim
- -- because flags is 9 in: if (flags & OPENLINE_MARKFIX) {
it('marks at last line move on insert new line #extmarks', function()
-- open_line in misc1.c
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[1], 0, 4)
feed('0i<cr><esc>')
check_undo_redo(ns, marks[1], 0, 4, 1, 4)
end)
@@ -451,22 +454,22 @@ describe('Extmarks buffer api', function()
it('yet again marks move with line splits #extmarks', function()
-- the first test above wasn't catching all errors..
feed("A67890<esc>")
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[1], 0, 4)
feed("04li<cr><esc>")
check_undo_redo(ns, marks[1], 0, 4, 1, 0)
end)
it('and one last time line splits... #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
- curbufmeths.set_extmark(ns, marks[2], 0, 2)
+ set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[2], 0, 2)
feed("02li<cr><esc>")
check_undo_redo(ns, marks[1], 0, 1, 0, 1)
check_undo_redo(ns, marks[2], 0, 2, 1, 0)
end)
it('multiple marks move with mark splits #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[2], 0, 3)
feed("0li<cr><esc>")
check_undo_redo(ns, marks[1], 0, 1, 1, 0)
check_undo_redo(ns, marks[2], 0, 3, 1, 2)
@@ -474,14 +477,14 @@ describe('Extmarks buffer api', function()
it('deleting on a mark works #extmarks', function()
-- op_delete in ops.c
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('02lx')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
end)
it('marks move with char deletes #extmarks', function()
-- op_delete in ops.c
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('02dl')
check_undo_redo(ns, marks[1], 0, 2, 0, 0)
-- from the other side (nothing should happen)
@@ -491,21 +494,20 @@ describe('Extmarks buffer api', function()
it('marks move with char deletes over a range #extmarks', function()
-- op_delete in ops.c
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
feed('0l3dl<esc>')
check_undo_redo(ns, marks[1], 0, 2, 0, 1)
check_undo_redo(ns, marks[2], 0, 3, 0, 1)
-- delete 1, nothing should happend to our marks
feed('u')
feed('$x')
- -- TODO do we need to test marks[1] ???
check_undo_redo(ns, marks[2], 0, 3, 0, 3)
end)
it('deleting marks at end of line works #extmarks', function()
-- mark_extended.c/extmark_col_adjust_delete
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[1], 0, 4)
feed('$x')
check_undo_redo(ns, marks[1], 0, 4, 0, 4)
-- check the copy happened correctly on delete at eol
@@ -518,7 +520,7 @@ describe('Extmarks buffer api', function()
it('marks move with blockwise deletes #extmarks', function()
-- op_delete in ops.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 4)
+ set_extmark(ns, marks[1], 1, 4)
feed('h<c-v>hhkd')
check_undo_redo(ns, marks[1], 1, 4, 1, 1)
end)
@@ -526,9 +528,9 @@ describe('Extmarks buffer api', function()
it('marks move with blockwise deletes over a range #extmarks', function()
-- op_delete in ops.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 1, 2)
+ set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 1, 2)
feed('0<c-v>k3lx')
check_undo_redo(ns, marks[1], 0, 1, 0, 0)
check_undo_redo(ns, marks[2], 0, 3, 0, 0)
@@ -536,14 +538,13 @@ describe('Extmarks buffer api', function()
-- delete 1, nothing should happend to our marks
feed('u')
feed('$<c-v>jx')
- -- TODO do we need to test marks[1] ???
check_undo_redo(ns, marks[2], 0, 3, 0, 3)
check_undo_redo(ns, marks[3], 1, 2, 1, 2)
end)
it('works with char deletes over multilines #extmarks', function()
feed('a<cr>12345<cr>test-me<esc>')
- curbufmeths.set_extmark(ns, marks[1], 2, 5)
+ set_extmark(ns, marks[1], 2, 5)
feed('gg')
feed('dv?-m?<cr>')
check_undo_redo(ns, marks[1], 2, 5, 0, 0)
@@ -551,7 +552,7 @@ describe('Extmarks buffer api', function()
it('marks outside of deleted range move with visual char deletes #extmarks', function()
-- op_delete in ops.c
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[1], 0, 3)
feed('0vx<esc>')
check_undo_redo(ns, marks[1], 0, 3, 0, 2)
@@ -570,7 +571,7 @@ describe('Extmarks buffer api', function()
it('marks outside of deleted range move with char deletes #extmarks', function()
-- op_delete in ops.c
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[1], 0, 3)
feed('0x<esc>')
check_undo_redo(ns, marks[1], 0, 3, 0, 2)
@@ -591,7 +592,7 @@ describe('Extmarks buffer api', function()
it('marks move with P(backward) paste #extmarks', function()
-- do_put in ops.c
feed('0iabc<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 7)
+ set_extmark(ns, marks[1], 0, 7)
feed('0veyP')
check_undo_redo(ns, marks[1], 0, 7, 0, 15)
end)
@@ -599,7 +600,7 @@ describe('Extmarks buffer api', function()
it('marks move with p(forward) paste #extmarks', function()
-- do_put in ops.c
feed('0iabc<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 7)
+ set_extmark(ns, marks[1], 0, 7)
feed('0veyp')
check_undo_redo(ns, marks[1], 0, 7, 0, 14)
end)
@@ -607,7 +608,7 @@ describe('Extmarks buffer api', function()
it('marks move with blockwise P(backward) paste #extmarks', function()
-- do_put in ops.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 4)
+ set_extmark(ns, marks[1], 1, 4)
feed('<c-v>hhkyP<esc>')
check_undo_redo(ns, marks[1], 1, 4, 1, 7)
end)
@@ -615,20 +616,20 @@ describe('Extmarks buffer api', function()
it('marks move with blockwise p(forward) paste #extmarks', function()
-- do_put in ops.c
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 4)
+ set_extmark(ns, marks[1], 1, 4)
feed('<c-v>hhkyp<esc>')
check_undo_redo(ns, marks[1], 1, 4, 1, 6)
end)
it('replace works #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('0r2')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
end)
it('blockwise replace works #extmarks', function()
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('0<c-v>llkr1<esc>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
end)
@@ -636,7 +637,7 @@ describe('Extmarks buffer api', function()
it('shift line #extmarks', function()
-- shift_line in ops.c
feed(':set shiftwidth=4<cr><esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('0>>')
check_undo_redo(ns, marks[1], 0, 2, 0, 6)
@@ -651,7 +652,7 @@ describe('Extmarks buffer api', function()
-- shift_block in ops.c
feed(':set shiftwidth=4<cr><esc>')
feed('a<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 2)
+ set_extmark(ns, marks[1], 1, 2)
feed('0<c-v>k>')
check_undo_redo(ns, marks[1], 1, 2, 1, 6)
feed('<c-v>j>')
@@ -665,7 +666,7 @@ describe('Extmarks buffer api', function()
-- ins_tab in edit.c
feed(':set expandtab<cr><esc>')
feed(':set shiftwidth=2<cr><esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('0i<tab><tab><esc>')
check_undo_redo(ns, marks[1], 0, 2, 0, 6)
end)
@@ -676,7 +677,7 @@ describe('Extmarks buffer api', function()
feed(':set shiftwidth=2<cr><esc>')
feed(':set softtabstop=2<cr><esc>')
feed(':set tabstop=8<cr><esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[1], 0, 2)
feed('0i<tab><esc>')
check_undo_redo(ns, marks[1], 0, 2, 0, 4)
feed('0iX<tab><esc>')
@@ -684,7 +685,7 @@ describe('Extmarks buffer api', function()
end)
it('marks move when using :move #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 0)
+ set_extmark(ns, marks[1], 0, 0)
feed('A<cr>2<esc>:1move 2<cr><esc>')
check_undo_redo(ns, marks[1], 0, 0, 1, 0)
-- test codepath when moving lines up
@@ -695,7 +696,7 @@ describe('Extmarks buffer api', function()
it('marks move when using :move part 2 #extmarks', function()
-- make sure we didn't get lucky with the math...
feed('A<cr>2<cr>3<cr>4<cr>5<cr>6<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 0)
+ set_extmark(ns, marks[1], 1, 0)
feed(':2,3move 5<cr><esc>')
check_undo_redo(ns, marks[1], 1, 0, 3, 0)
-- test codepath when moving lines up
@@ -706,23 +707,24 @@ describe('Extmarks buffer api', function()
it('undo and redo of set and unset marks #extmarks', function()
-- Force a new undo head
feed('o<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[1], 0, 1)
feed('o<esc>')
- curbufmeths.set_extmark(ns, marks[2], 0, -1)
- curbufmeths.set_extmark(ns, marks[3], 0, -1)
+ set_extmark(ns, marks[2], 0, -1)
+ set_extmark(ns, marks[3], 0, -1)
feed("u")
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ local rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(1, table.getn(rv))
feed("<c-r>")
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(3, table.getn(rv))
-- Test updates
feed('o<esc>')
- curbufmeths.set_extmark(ns, marks[1], positions[1][1], positions[1][2])
- rv = curbufmeths.get_extmarks(ns, marks[1], marks[1], 1)
+ set_extmark(ns, marks[1], positions[1][1], positions[1][2])
+ rv = get_extmarks(ns, marks[1], marks[1], {amount=1})
+ eq(1, table.getn(rv))
feed("u")
feed("<c-r>")
check_undo_redo(ns, marks[1], 0, 1, positions[1][1], positions[1][2])
@@ -731,80 +733,80 @@ describe('Extmarks buffer api', function()
feed('o<esc>')
curbufmeths.del_extmark(ns, marks[3])
feed("u")
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(3, table.getn(rv))
feed("<c-r>")
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(2, table.getn(rv))
end)
it('undo and redo of marks deleted during edits #extmarks', function()
-- test extmark_adjust
feed('A<cr>12345<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 2)
+ set_extmark(ns, marks[1], 1, 2)
feed('dd')
check_undo_redo(ns, marks[1], 1, 2, 1, 0)
end)
it('namespaces work properly #extmarks', function()
- rv = curbufmeths.set_extmark(ns, marks[1], positions[1][1], positions[1][2])
+ local rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2])
eq(1, rv)
- rv = curbufmeths.set_extmark(ns2, marks[1], positions[1][1], positions[1][2])
+ rv = set_extmark(ns2, marks[1], positions[1][1], positions[1][2])
eq(1, rv)
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(1, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns2, {0, 0}, {-1, -1})
eq(1, table.getn(rv))
-- Set more marks for testing the ranges
- rv = curbufmeths.set_extmark(ns, marks[2], positions[2][1], positions[2][2])
- rv = curbufmeths.set_extmark(ns, marks[3], positions[3][1], positions[3][2])
- rv = curbufmeths.set_extmark(ns2, marks[2], positions[2][1], positions[2][2])
- rv = curbufmeths.set_extmark(ns2, marks[3], positions[3][1], positions[3][2])
+ set_extmark(ns, marks[2], positions[2][1], positions[2][2])
+ set_extmark(ns, marks[3], positions[3][1], positions[3][2])
+ set_extmark(ns2, marks[2], positions[2][1], positions[2][2])
+ set_extmark(ns2, marks[3], positions[3][1], positions[3][2])
-- get_next (amount set)
- rv = curbufmeths.get_extmarks(ns, {0, 0}, positions[2], 1)
+ rv = get_extmarks(ns, {0, 0}, positions[2], {amount=1})
eq(1, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns2, {0, 0}, positions[2], 1)
+ rv = get_extmarks(ns2, {0, 0}, positions[2], {amount=1})
eq(1, table.getn(rv))
-- get_prev (amount set)
- rv = curbufmeths.get_extmarks(ns, positions[1], {0, 0}, 1)
+ rv = get_extmarks(ns, positions[1], {0, 0}, {amount=1})
eq(1, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns2, positions[1], {0, 0}, 1)
+ rv = get_extmarks(ns2, positions[1], {0, 0}, {amount=1})
eq(1, table.getn(rv))
-- get_next (amount not set)
- rv = curbufmeths.get_extmarks(ns, positions[1], positions[2], ALL)
+ rv = get_extmarks(ns, positions[1], positions[2])
eq(2, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns2, positions[1], positions[2], ALL)
+ rv = get_extmarks(ns2, positions[1], positions[2])
eq(2, table.getn(rv))
-- get_prev (amount not set)
- rv = curbufmeths.get_extmarks(ns, positions[2], positions[1], ALL)
+ rv = get_extmarks(ns, positions[2], positions[1])
eq(2, table.getn(rv))
- rv = curbufmeths.get_extmarks(ns2, positions[2], positions[1], ALL)
+ rv = get_extmarks(ns2, positions[2], positions[1])
eq(2, table.getn(rv))
curbufmeths.del_extmark(ns, marks[1])
- rv = curbufmeths.get_extmarks(ns, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns, {0, 0}, {-1, -1})
eq(2, table.getn(rv))
curbufmeths.del_extmark(ns2, marks[1])
- rv = curbufmeths.get_extmarks(ns2, {0, 0}, {-1, -1}, ALL)
+ rv = get_extmarks(ns2, {0, 0}, {-1, -1})
eq(2, table.getn(rv))
end)
it('mark set can create unique identifiers #extmarks', function()
-- create mark with id 1
- eq(1, curbufmeths.set_extmark(ns, 1, positions[1][1], positions[1][2]))
+ eq(1, set_extmark(ns, 1, positions[1][1], positions[1][2]))
-- ask for unique id, it should be the next one, i e 2
- eq(2, curbufmeths.set_extmark(ns, 0, positions[1][1], positions[1][2]))
- eq(3, curbufmeths.set_extmark(ns, 3, positions[2][1], positions[2][2]))
- eq(4, curbufmeths.set_extmark(ns, 0, positions[1][1], positions[1][2]))
+ eq(2, set_extmark(ns, 0, positions[1][1], positions[1][2]))
+ eq(3, set_extmark(ns, 3, positions[2][1], positions[2][2]))
+ eq(4, set_extmark(ns, 0, positions[1][1], positions[1][2]))
-- mixing manual and allocated id:s are not recommened, but it should
-- do something reasonable
- eq(6, curbufmeths.set_extmark(ns, 6, positions[2][1], positions[2][2]))
- eq(7, curbufmeths.set_extmark(ns, 0, positions[1][1], positions[1][2]))
- eq(8, curbufmeths.set_extmark(ns, 0, positions[1][1], positions[1][2]))
+ eq(6, set_extmark(ns, 6, positions[2][1], positions[2][2]))
+ eq(7, set_extmark(ns, 0, positions[1][1], positions[1][2]))
+ eq(8, set_extmark(ns, 0, positions[1][1], positions[1][2]))
end)
it('auto indenting with enter works #extmarks', function()
@@ -814,11 +816,11 @@ describe('Extmarks buffer api', function()
feed(':set shiftwidth=2<cr><esc>')
feed("0iint <esc>A {1M1<esc>b<esc>")
-- Set the mark on the M, should move..
- curbufmeths.set_extmark(ns, marks[1], 0, 12)
+ set_extmark(ns, marks[1], 0, 12)
-- Set the mark before the cursor, should stay there
- curbufmeths.set_extmark(ns, marks[2], 0, 10)
+ set_extmark(ns, marks[2], 0, 10)
feed("i<cr><esc>")
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
+ local rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({1, 3}, rv)
rv = curbufmeths.get_extmark_by_id(ns, marks[2])
eq({0, 10}, rv)
@@ -831,9 +833,9 @@ describe('Extmarks buffer api', function()
feed(':set shiftwidth=2<cr><esc>')
-- <c-f> will force an indent of 2
feed("0iint <esc>A {<cr><esc>0i1M1<esc>")
- curbufmeths.set_extmark(ns, marks[1], 1, 1)
+ set_extmark(ns, marks[1], 1, 1)
feed("0i<c-f><esc>")
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
+ local rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({1, 3}, rv)
check_undo_redo(ns, marks[1], 1, 1, 1, 3)
-- now check when cursor at eol
@@ -847,9 +849,9 @@ describe('Extmarks buffer api', function()
feed(':set autoindent<cr><esc>')
feed(':set shiftwidth=2<cr><esc>')
feed("0i<tab><esc>")
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[1], 0, 3)
feed("bi<c-d><esc>")
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
+ local rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({0, 1}, rv)
check_undo_redo(ns, marks[1], 0, 3, 0, 1)
-- check when cursor at eol
@@ -863,8 +865,8 @@ describe('Extmarks buffer api', function()
feed(':set autoindent<cr><esc>')
feed(':set shiftwidth=2<cr><esc>')
feed("0iint <esc>A {<cr><bs>1M1<cr><bs>2M2<esc>")
- curbufmeths.set_extmark(ns, marks[1], 1, 1)
- curbufmeths.set_extmark(ns, marks[2], 2, 1)
+ set_extmark(ns, marks[1], 1, 1)
+ set_extmark(ns, marks[2], 2, 1)
feed('=gg')
check_undo_redo(ns, marks[1], 1, 1, 1, 3)
check_undo_redo(ns, marks[2], 2, 1, 2, 5)
@@ -872,8 +874,8 @@ describe('Extmarks buffer api', function()
it('substitutes by deleting inside the replace matches #extmarks_sub', function()
-- do_sub in ex_cmds.c
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
feed(':s/34/xx<cr>')
check_undo_redo(ns, marks[1], 0, 2, 0, 4)
check_undo_redo(ns, marks[2], 0, 3, 0, 4)
@@ -881,8 +883,8 @@ describe('Extmarks buffer api', function()
it('substitutes when insert text > deleted #extmarks_sub', function()
-- do_sub in ex_cmds.c
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
feed(':s/34/xxx<cr>')
check_undo_redo(ns, marks[1], 0, 2, 0, 5)
check_undo_redo(ns, marks[2], 0, 3, 0, 5)
@@ -890,8 +892,8 @@ describe('Extmarks buffer api', function()
it('substitutes when marks around eol #extmarks_sub', function()
-- do_sub in ex_cmds.c
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
- curbufmeths.set_extmark(ns, marks[2], 0, 5)
+ set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[2], 0, 5)
feed(':s/5/xxx<cr>')
check_undo_redo(ns, marks[1], 0, 4, 0, 7)
check_undo_redo(ns, marks[2], 0, 5, 0, 7)
@@ -901,9 +903,9 @@ describe('Extmarks buffer api', function()
-- do_sub in ex_cmds.c
feed('A<cr>x34xx<esc>')
feed('A<cr>xxx34<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 1, 1)
- curbufmeths.set_extmark(ns, marks[3], 2, 4)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 1, 1)
+ set_extmark(ns, marks[3], 2, 4)
feed(':1,3s/34/xxx<cr><esc>')
check_undo_redo(ns, marks[1], 0, 2, 0, 5)
check_undo_redo(ns, marks[2], 1, 1, 1, 4)
@@ -913,9 +915,9 @@ describe('Extmarks buffer api', function()
it('substitutes multiple matches in a line #extmarks_sub', function()
-- do_sub in ex_cmds.c
feed('ddi3x3x3<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 0)
- curbufmeths.set_extmark(ns, marks[2], 0, 2)
- curbufmeths.set_extmark(ns, marks[3], 0, 4)
+ set_extmark(ns, marks[1], 0, 0)
+ set_extmark(ns, marks[2], 0, 2)
+ set_extmark(ns, marks[3], 0, 4)
feed(':s/3/yy/g<cr><esc>')
check_undo_redo(ns, marks[1], 0, 0, 0, 2)
check_undo_redo(ns, marks[2], 0, 2, 0, 5)
@@ -924,11 +926,11 @@ describe('Extmarks buffer api', function()
it('substitions over multiple lines with newline in pattern #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 1, 0)
- curbufmeths.set_extmark(ns, marks[4], 1, 5)
- curbufmeths.set_extmark(ns, marks[5], 2, 0)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 1, 0)
+ set_extmark(ns, marks[4], 1, 5)
+ set_extmark(ns, marks[5], 2, 0)
feed([[:1,2s:5\n:5 <cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 0, 6)
@@ -939,12 +941,12 @@ describe('Extmarks buffer api', function()
it('inserting #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 1, 0)
- curbufmeths.set_extmark(ns, marks[4], 1, 5)
- curbufmeths.set_extmark(ns, marks[5], 2, 0)
- curbufmeths.set_extmark(ns, marks[6], 1, 2)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 1, 0)
+ set_extmark(ns, marks[4], 1, 5)
+ set_extmark(ns, marks[5], 2, 0)
+ set_extmark(ns, marks[6], 1, 2)
feed([[:1,2s:5\n67:X<cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 0, 5)
@@ -956,11 +958,11 @@ describe('Extmarks buffer api', function()
it('substitions with multiple newlines in pattern #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 4)
- curbufmeths.set_extmark(ns, marks[2], 0, 5)
- curbufmeths.set_extmark(ns, marks[3], 1, 0)
- curbufmeths.set_extmark(ns, marks[4], 1, 5)
- curbufmeths.set_extmark(ns, marks[5], 2, 0)
+ set_extmark(ns, marks[1], 0, 4)
+ set_extmark(ns, marks[2], 0, 5)
+ set_extmark(ns, marks[3], 1, 0)
+ set_extmark(ns, marks[4], 1, 5)
+ set_extmark(ns, marks[5], 2, 0)
feed([[:1,2s:\n.*\n:X<cr>]])
check_undo_redo(ns, marks[1], 0, 4, 0, 4)
check_undo_redo(ns, marks[2], 0, 5, 0, 6)
@@ -971,11 +973,11 @@ describe('Extmarks buffer api', function()
it('substitions over multiple lines with replace in substition #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
- curbufmeths.set_extmark(ns, marks[2], 0, 2)
- curbufmeths.set_extmark(ns, marks[3], 0, 4)
- curbufmeths.set_extmark(ns, marks[4], 1, 0)
- curbufmeths.set_extmark(ns, marks[5], 2, 0)
+ set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[2], 0, 2)
+ set_extmark(ns, marks[3], 0, 4)
+ set_extmark(ns, marks[4], 1, 0)
+ set_extmark(ns, marks[5], 2, 0)
feed([[:1,2s:3:\r<cr>]])
check_undo_redo(ns, marks[1], 0, 1, 0, 1)
check_undo_redo(ns, marks[2], 0, 2, 1, 0)
@@ -989,9 +991,9 @@ describe('Extmarks buffer api', function()
it('substitions over multiple lines with replace in substition #extmarks_sub', function()
feed('A<cr>x3<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 1, 0)
- curbufmeths.set_extmark(ns, marks[2], 1, 1)
- curbufmeths.set_extmark(ns, marks[3], 1, 2)
+ set_extmark(ns, marks[1], 1, 0)
+ set_extmark(ns, marks[2], 1, 1)
+ set_extmark(ns, marks[3], 1, 2)
feed([[:2,2s:3:\r<cr>]])
check_undo_redo(ns, marks[1], 1, 0, 1, 0)
check_undo_redo(ns, marks[2], 1, 1, 2, 0)
@@ -1000,11 +1002,11 @@ describe('Extmarks buffer api', function()
it('substitions over multiple lines with replace in substition #extmarks_sub', function()
feed('A<cr>x3<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 1)
- curbufmeths.set_extmark(ns, marks[2], 0, 2)
- curbufmeths.set_extmark(ns, marks[3], 0, 4)
- curbufmeths.set_extmark(ns, marks[4], 1, 1)
- curbufmeths.set_extmark(ns, marks[5], 2, 0)
+ set_extmark(ns, marks[1], 0, 1)
+ set_extmark(ns, marks[2], 0, 2)
+ set_extmark(ns, marks[3], 0, 4)
+ set_extmark(ns, marks[4], 1, 1)
+ set_extmark(ns, marks[5], 2, 0)
feed([[:1,2s:3:\r<cr>]])
check_undo_redo(ns, marks[1], 0, 1, 0, 1)
check_undo_redo(ns, marks[2], 0, 2, 1, 0)
@@ -1018,12 +1020,12 @@ describe('Extmarks buffer api', function()
it('substitions with newline in match and sub, delta is 0 #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 1, 0)
- curbufmeths.set_extmark(ns, marks[5], 1, 5)
- curbufmeths.set_extmark(ns, marks[6], 2, 0)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 1, 0)
+ set_extmark(ns, marks[5], 1, 5)
+ set_extmark(ns, marks[6], 2, 0)
feed([[:1,1s:5\n:\r<cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 1, 0)
@@ -1035,12 +1037,12 @@ describe('Extmarks buffer api', function()
it('substitions with newline in match and sub, delta > 0 #extmarks_sub', function()
feed('A<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 1, 0)
- curbufmeths.set_extmark(ns, marks[5], 1, 5)
- curbufmeths.set_extmark(ns, marks[6], 2, 0)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 1, 0)
+ set_extmark(ns, marks[5], 1, 5)
+ set_extmark(ns, marks[6], 2, 0)
feed([[:1,1s:5\n:\r\r<cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 2, 0)
@@ -1052,13 +1054,13 @@ describe('Extmarks buffer api', function()
it('substitions with newline in match and sub, delta < 0 #extmarks_sub', function()
feed('A<cr>67890<cr>xx<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 1, 0)
- curbufmeths.set_extmark(ns, marks[5], 1, 5)
- curbufmeths.set_extmark(ns, marks[6], 2, 1)
- curbufmeths.set_extmark(ns, marks[7], 3, 0)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 1, 0)
+ set_extmark(ns, marks[5], 1, 5)
+ set_extmark(ns, marks[6], 2, 1)
+ set_extmark(ns, marks[7], 3, 0)
feed([[:1,2s:5\n.*\n:\r<cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 1, 0)
@@ -1071,12 +1073,12 @@ describe('Extmarks buffer api', function()
it('substitions with backrefs, newline inserted into sub #extmarks_sub', function()
feed('A<cr>67890<cr>xx<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 0, 3)
- curbufmeths.set_extmark(ns, marks[2], 0, 4)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 1, 0)
- curbufmeths.set_extmark(ns, marks[5], 1, 5)
- curbufmeths.set_extmark(ns, marks[6], 2, 0)
+ set_extmark(ns, marks[1], 0, 3)
+ set_extmark(ns, marks[2], 0, 4)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 1, 0)
+ set_extmark(ns, marks[5], 1, 5)
+ set_extmark(ns, marks[6], 2, 0)
feed([[:1,1s:5\(\n\):\0\1<cr>]])
check_undo_redo(ns, marks[1], 0, 3, 0, 3)
check_undo_redo(ns, marks[2], 0, 4, 2, 0)
@@ -1087,8 +1089,8 @@ describe('Extmarks buffer api', function()
end)
it('substitions a ^ #extmarks_sub', function()
- curbufmeths.set_extmark(ns, marks[1], 0, 0)
- curbufmeths.set_extmark(ns, marks[2], 0, 1)
+ set_extmark(ns, marks[1], 0, 0)
+ set_extmark(ns, marks[2], 0, 1)
feed([[:s:^:x<cr>]])
check_undo_redo(ns, marks[1], 0, 0, 0, 1)
check_undo_redo(ns, marks[2], 0, 1, 0, 2)
@@ -1097,11 +1099,11 @@ describe('Extmarks buffer api', function()
it('using <c-a> without increase in order of magnitude #extmarks_inc_dec', function()
-- do_addsub in ops.c
feed('ddiabc998xxx<esc>Tc')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 0, 6)
- curbufmeths.set_extmark(ns, marks[5], 0, 7)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 0, 6)
+ set_extmark(ns, marks[5], 0, 7)
feed('<c-a>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 6)
@@ -1113,11 +1115,11 @@ describe('Extmarks buffer api', function()
it('using <c-a> when increase in order of magnitude #extmarks_inc_dec', function()
-- do_addsub in ops.c
feed('ddiabc999xxx<esc>Tc')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 0, 6)
- curbufmeths.set_extmark(ns, marks[5], 0, 7)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 0, 6)
+ set_extmark(ns, marks[5], 0, 7)
feed('<c-a>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 7)
@@ -1128,11 +1130,11 @@ describe('Extmarks buffer api', function()
it('using <c-a> when negative and without decrease in order of magnitude #extmarks_inc_dec', function()
feed('ddiabc-999xxx<esc>T-')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 6)
- curbufmeths.set_extmark(ns, marks[4], 0, 7)
- curbufmeths.set_extmark(ns, marks[5], 0, 8)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 6)
+ set_extmark(ns, marks[4], 0, 7)
+ set_extmark(ns, marks[5], 0, 8)
feed('<c-a>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 7)
@@ -1143,11 +1145,11 @@ describe('Extmarks buffer api', function()
it('using <c-a> when negative and decrease in order of magnitude #extmarks_inc_dec', function()
feed('ddiabc-1000xxx<esc>T-')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 7)
- curbufmeths.set_extmark(ns, marks[4], 0, 8)
- curbufmeths.set_extmark(ns, marks[5], 0, 9)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 7)
+ set_extmark(ns, marks[4], 0, 8)
+ set_extmark(ns, marks[5], 0, 9)
feed('<c-a>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 7)
@@ -1159,11 +1161,11 @@ describe('Extmarks buffer api', function()
it('using <c-x> without decrease in order of magnitude #extmarks_inc_dec', function()
-- do_addsub in ops.c
feed('ddiabc999xxx<esc>Tc')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 5)
- curbufmeths.set_extmark(ns, marks[4], 0, 6)
- curbufmeths.set_extmark(ns, marks[5], 0, 7)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 5)
+ set_extmark(ns, marks[4], 0, 6)
+ set_extmark(ns, marks[5], 0, 7)
feed('<c-x>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 6)
@@ -1175,11 +1177,11 @@ describe('Extmarks buffer api', function()
it('using <c-x> when decrease in order of magnitude #extmarks_inc_dec', function()
-- do_addsub in ops.c
feed('ddiabc1000xxx<esc>Tc')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 6)
- curbufmeths.set_extmark(ns, marks[4], 0, 7)
- curbufmeths.set_extmark(ns, marks[5], 0, 8)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 6)
+ set_extmark(ns, marks[4], 0, 7)
+ set_extmark(ns, marks[5], 0, 8)
feed('<c-x>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 6)
@@ -1190,11 +1192,11 @@ describe('Extmarks buffer api', function()
it('using <c-x> when negative and without increase in order of magnitude #extmarks_inc_dec', function()
feed('ddiabc-998xxx<esc>T-')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 6)
- curbufmeths.set_extmark(ns, marks[4], 0, 7)
- curbufmeths.set_extmark(ns, marks[5], 0, 8)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 6)
+ set_extmark(ns, marks[4], 0, 7)
+ set_extmark(ns, marks[5], 0, 8)
feed('<c-x>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 7)
@@ -1205,11 +1207,11 @@ describe('Extmarks buffer api', function()
it('using <c-x> when negative and increase in order of magnitude #extmarks_inc_dec', function()
feed('ddiabc-999xxx<esc>T-')
- curbufmeths.set_extmark(ns, marks[1], 0, 2)
- curbufmeths.set_extmark(ns, marks[2], 0, 3)
- curbufmeths.set_extmark(ns, marks[3], 0, 6)
- curbufmeths.set_extmark(ns, marks[4], 0, 7)
- curbufmeths.set_extmark(ns, marks[5], 0, 8)
+ set_extmark(ns, marks[1], 0, 2)
+ set_extmark(ns, marks[2], 0, 3)
+ set_extmark(ns, marks[3], 0, 6)
+ set_extmark(ns, marks[4], 0, 7)
+ set_extmark(ns, marks[5], 0, 8)
feed('<c-x>')
check_undo_redo(ns, marks[1], 0, 2, 0, 2)
check_undo_redo(ns, marks[2], 0, 3, 0, 8)
@@ -1218,38 +1220,34 @@ describe('Extmarks buffer api', function()
check_undo_redo(ns, marks[5], 0, 8, 0, 9)
end)
- -- TODO catch exceptions
- pending('throws consistent error codes #todo', function()
+ it('throws consistent error codes', function()
local ns_invalid = ns2 + 1
- rv = curbufmeths.set_extmark(ns_invalid, marks[1], positions[1][1], positions[1][2])
- rv = curbufmeths.del_extmark(ns_invalid, marks[1])
- rv = curbufmeths.get_extmarks(ns_invalid, positions[1], positions[2], ALL)
- rv = curbufmeths.get_extmark_by_id(ns_invalid, marks[1])
-
+ eq("Invalid ns_id", pcall_err(set_extmark, ns_invalid, marks[1], positions[1][1], positions[1][2]))
+ eq("Invalid ns_id", pcall_err(curbufmeths.del_extmark, ns_invalid, marks[1]))
+ eq("Invalid ns_id", pcall_err(get_extmarks, ns_invalid, positions[1], positions[2]))
+ eq("Invalid ns_id", pcall_err(curbufmeths.get_extmark_by_id, ns_invalid, marks[1]))
end)
it('when col = line-length, set the mark on eol #extmarks', function()
- curbufmeths.set_extmark(ns, marks[1], 0, -1)
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
+ set_extmark(ns, marks[1], 0, -1)
+ local rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({0, init_text:len()}, rv)
-- Test another
- curbufmeths.set_extmark(ns, marks[1], 0, -1)
+ set_extmark(ns, marks[1], 0, -1)
rv = curbufmeths.get_extmark_by_id(ns, marks[1])
eq({0, init_text:len()}, rv)
end)
it('when col = line-length, set the mark on eol #extmarks', function()
local invalid_col = init_text:len() + 1
- eq({false, "col value outside range"}, meth_pcall(curbufmeths.set_extmark, ns, marks[1], 0, invalid_col))
+ eq("col value outside range", pcall_err(set_extmark, ns, marks[1], 0, invalid_col))
end)
- -- TODO(bfredl): decide what to do with this
- pending('when line > line, set the mark on end of buffer #extmarks', function()
+ it('when line > line_count, throw error #extmarks', function()
local invalid_col = init_text:len() + 1
- local invalid_lnum = 3 -- line1 ends in an eol. so line 2 contains a valid position (eol)?
- curbufmeths.set_extmark(ns, marks[1], invalid_lnum, invalid_col)
- rv = curbufmeths.get_extmark_by_id(ns, marks[1])
- eq({2, 1}, rv)
+ local invalid_lnum = 3
+ eq('line value outside range', pcall_err(set_extmark, ns, marks[1], invalid_lnum, invalid_col))
+ eq({}, curbufmeths.get_extmark_by_id(ns, marks[1]))
end)
it('bug from check_col in extmark_set #extmarks_sub', function()
@@ -1259,7 +1257,7 @@ describe('Extmarks buffer api', function()
-- check_col and check_lnum only when they are required.
feed('A<cr>67890<cr>xx<esc>')
feed('A<cr>12345<cr>67890<cr>xx<esc>')
- curbufmeths.set_extmark(ns, marks[1], 3, 4)
+ set_extmark(ns, marks[1], 3, 4)
feed([[:1,5s:5\n:5 <cr>]])
check_undo_redo(ns, marks[1], 3, 4, 2, 6)
end)
@@ -1284,7 +1282,7 @@ describe('Extmarks buffer api with many marks', function()
local q = 0
for i = 0,29 do
for j = 0,i do
- local id = curbufmeths.set_extmark(ns,0, i,j)
+ local id = set_extmark(ns,0, i,j)
eq(nil, ns_marks[ns][id])
ok(id > 0)
ns_marks[ns][id] = {i,j}
@@ -1298,7 +1296,7 @@ describe('Extmarks buffer api with many marks', function()
end)
local function get_marks(ns)
- local mark_list = curbufmeths.get_extmarks(ns, 0, -1, -1)
+ local mark_list = get_extmarks(ns, 0, -1)
local marks = {}
for _, mark in ipairs(mark_list) do
local id, row, col = unpack(mark)
@@ -1362,4 +1360,10 @@ describe('Extmarks buffer api with many marks', function()
eq(ns_marks[ns1], get_marks(ns1))
eq(ns_marks[ns2], get_marks(ns2))
end)
+
+ it("can wipe buffer #extmarks", function()
+ command('bwipe!')
+ eq({}, get_marks(ns1))
+ eq({}, get_marks(ns2))
+ end)
end)