extmarks: better linewise/charwise handling
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m22s
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m22s
This commit is contained in:
@@ -627,7 +627,7 @@ describe('Range', function()
|
||||
'the lazy dog',
|
||||
}, function()
|
||||
-- Construct a range over 'fox jumps'
|
||||
local r = Range.new(Pos.new(nil, 2, 1), Pos.new(nil, 3, Pos.MAX_COL), 'V')
|
||||
local r = Range.new(Pos.new(nil, 2, 1), Pos.new(nil, 3, 5), 'v')
|
||||
local extrange = r:save_to_extmark()
|
||||
assert.are.same({ 'fox', 'jumps' }, extrange:range():lines())
|
||||
-- change 'jumps' to 'leaps':
|
||||
@@ -642,4 +642,29 @@ describe('Range', function()
|
||||
assert.are.same({ 'fox', 'leaps' }, extrange:range():lines())
|
||||
end)
|
||||
end)
|
||||
|
||||
it('can save linewise extmark', function()
|
||||
withbuf({
|
||||
'The quick brown',
|
||||
'fox',
|
||||
'jumps',
|
||||
'over',
|
||||
'the lazy dog',
|
||||
}, function()
|
||||
-- Construct a range over 'fox jumps'
|
||||
local r = Range.new(Pos.new(nil, 2, 1), Pos.new(nil, 3, Pos.MAX_COL), 'V')
|
||||
local extrange = r:save_to_extmark()
|
||||
assert.are.same({ 'fox', 'jumps' }, extrange:range():lines())
|
||||
|
||||
local extmark = vim.api.nvim_buf_get_extmark_by_id(
|
||||
extrange.bufnr,
|
||||
vim.api.nvim_create_namespace 'u.range',
|
||||
extrange.id,
|
||||
{ details = true }
|
||||
)
|
||||
local row0, col0, details = unpack(extmark)
|
||||
assert.are.same({ 1, 0 }, { row0, col0 })
|
||||
assert.are.same({ 3, 0 }, { details.end_row, details.end_col })
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user