mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
Merge pull request #12699 from jamessan/getn
This commit is contained in:
commit
1153ac9036
@ -1,5 +1,10 @@
|
||||
-- vim: ft=lua tw=80
|
||||
|
||||
stds.nvim = {
|
||||
read_globals = { "jit" }
|
||||
}
|
||||
std = "lua51+nvim"
|
||||
|
||||
-- Ignore W211 (unused variable) with preload files.
|
||||
files["**/preload.lua"] = {ignore = { "211" }}
|
||||
-- Allow vim module to modify itself, but only here.
|
||||
|
@ -204,13 +204,13 @@ describe('API/extmarks', function()
|
||||
eq({marks[2], positions[2][1], positions[2][2]}, rv[2])
|
||||
-- nextrange with `limit`
|
||||
rv = get_extmarks(ns, marks[1], marks[3], {limit=2})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
-- nextrange with positional when mark exists at position
|
||||
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 = get_extmarks(ns, positions[2], positions[3])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #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}
|
||||
@ -248,14 +248,14 @@ describe('API/extmarks', function()
|
||||
eq({marks[1], positions[1][1], positions[1][2]}, rv[3])
|
||||
-- prevrange with limit
|
||||
rv = get_extmarks(ns, marks[3], marks[1], {limit=2})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
-- prevrange with positional when mark exists at position
|
||||
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 = get_extmarks(ns, positions[2], positions[1])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #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}
|
||||
@ -282,19 +282,19 @@ describe('API/extmarks', function()
|
||||
end
|
||||
|
||||
local rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3})
|
||||
eq(3, table.getn(rv))
|
||||
eq(3, #rv)
|
||||
|
||||
-- now in reverse
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3})
|
||||
eq(3, table.getn(rv))
|
||||
eq(3, #rv)
|
||||
end)
|
||||
|
||||
it('get_marks works when mark col > upper col', function()
|
||||
@ -798,17 +798,17 @@ describe('API/extmarks', function()
|
||||
|
||||
feed("u")
|
||||
local rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
eq(3, table.getn(rv))
|
||||
eq(3, #rv)
|
||||
|
||||
feed("<c-r>")
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
eq(3, table.getn(rv))
|
||||
eq(3, #rv)
|
||||
|
||||
-- Test updates
|
||||
feed('o<esc>')
|
||||
set_extmark(ns, marks[1], positions[1][1], positions[1][2])
|
||||
rv = get_extmarks(ns, marks[1], marks[1], {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
feed("u")
|
||||
feed("<c-r>")
|
||||
-- old value is NOT kept in history
|
||||
@ -820,10 +820,10 @@ describe('API/extmarks', function()
|
||||
feed("u")
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
-- undo does NOT restore deleted marks
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
feed("<c-r>")
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
end)
|
||||
|
||||
it('undo and redo of marks deleted during edits', function()
|
||||
@ -840,9 +840,9 @@ describe('API/extmarks', function()
|
||||
rv = set_extmark(ns2, marks[1], positions[1][1], positions[1][2])
|
||||
eq(1, rv)
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
rv = get_extmarks(ns2, {0, 0}, {-1, -1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
|
||||
-- Set more marks for testing the ranges
|
||||
set_extmark(ns, marks[2], positions[2][1], positions[2][2])
|
||||
@ -852,32 +852,32 @@ describe('API/extmarks', function()
|
||||
|
||||
-- get_next (limit set)
|
||||
rv = get_extmarks(ns, {0, 0}, positions[2], {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
rv = get_extmarks(ns2, {0, 0}, positions[2], {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
-- get_prev (limit set)
|
||||
rv = get_extmarks(ns, positions[1], {0, 0}, {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
rv = get_extmarks(ns2, positions[1], {0, 0}, {limit=1})
|
||||
eq(1, table.getn(rv))
|
||||
eq(1, #rv)
|
||||
|
||||
-- get_next (no limit)
|
||||
rv = get_extmarks(ns, positions[1], positions[2])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
rv = get_extmarks(ns2, positions[1], positions[2])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
-- get_prev (no limit)
|
||||
rv = get_extmarks(ns, positions[2], positions[1])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
rv = get_extmarks(ns2, positions[2], positions[1])
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
|
||||
curbufmeths.del_extmark(ns, marks[1])
|
||||
rv = get_extmarks(ns, {0, 0}, {-1, -1})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
curbufmeths.del_extmark(ns2, marks[1])
|
||||
rv = get_extmarks(ns2, {0, 0}, {-1, -1})
|
||||
eq(2, table.getn(rv))
|
||||
eq(2, #rv)
|
||||
end)
|
||||
|
||||
it('mark set can create unique identifiers', function()
|
||||
|
@ -172,7 +172,7 @@ describe('env.c', function()
|
||||
i = i + 1
|
||||
name = cimp.os_getenvname_at_index(i)
|
||||
end
|
||||
eq(true, (table.getn(names)) > 0)
|
||||
eq(true, #names > 0)
|
||||
eq(true, found_name)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user