add Range:difference
All checks were successful
NeoVim tests / plenary-tests (push) Successful in 9s
All checks were successful
NeoVim tests / plenary-tests (push) Successful in 9s
This commit is contained in:
@@ -422,6 +422,30 @@ describe('Range', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('difference', function()
|
||||
withbuf({ 'line one', 'and line two' }, function()
|
||||
local range_outer = Range.new(Pos.new(nil, 2, 1), Pos.new(nil, 2, 12), 'v')
|
||||
local range_inner = Range.new(Pos.new(nil, 2, 5), Pos.new(nil, 2, 8), 'v')
|
||||
|
||||
assert.are.same(range_outer:text(), 'and line two')
|
||||
assert.are.same(range_inner:text(), 'line')
|
||||
|
||||
local left, right = range_outer:difference(range_inner)
|
||||
assert.are.same(left:text(), 'and ')
|
||||
assert.are.same(right:text(), ' two')
|
||||
|
||||
left, right = range_inner:difference(range_outer)
|
||||
assert.are.same(left:text(), 'and ')
|
||||
assert.are.same(right:text(), ' two')
|
||||
|
||||
left, right = range_outer:difference(range_outer)
|
||||
assert.are.same(left:is_empty(), true)
|
||||
assert.are.same(left:text(), '')
|
||||
assert.are.same(right:is_empty(), true)
|
||||
assert.are.same(right:text(), '')
|
||||
end)
|
||||
end)
|
||||
|
||||
it('shrink', function()
|
||||
withbuf({ 'line one', 'and line two' }, function()
|
||||
local range = Range.new(Pos.new(nil, 2, 3), Pos.new(nil, 3, 5), 'v')
|
||||
|
||||
Reference in New Issue
Block a user