range: add extmark utilities
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:
@@ -617,4 +617,29 @@ describe('Range', function()
|
||||
}, vim.api.nvim_buf_get_lines(b, 0, -1, false))
|
||||
end)
|
||||
end)
|
||||
|
||||
it('can save to 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())
|
||||
-- change 'jumps' to 'leaps':
|
||||
vim.api.nvim_buf_set_text(extrange.bufnr, 2, 0, 2, 4, { 'leap' })
|
||||
assert.are.same({
|
||||
'The quick brown',
|
||||
'fox',
|
||||
'leaps',
|
||||
'over',
|
||||
'the lazy dog',
|
||||
}, vim.api.nvim_buf_get_lines(extrange.bufnr, 0, -1, false))
|
||||
assert.are.same({ 'fox', 'leaps' }, extrange:range():lines())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user