an-cabal/an-rope

Off-by-one error in Line metric

Opened this issue · 1 comments

hawkw commented

See test added in d62ef76.

Test output:

failures:

---- test::line_delete_test_1 stdout ----
        thread 'test::line_delete_test_1' panicked at 'assertion failed: `(left == right)` (left: `Rope["this is
a
multi
"] Branch(8(Branch(8(Leaf("this is\n"), Branch(2(Leaf("a\n"), Leaf("multi\n"))))), Leaf("")))`, right: `"this is\na\nrope"`)', src/test/mod.rs:158

If the range to delete in the test are changed from Line(2)..Line(3) to Line(1)..Line(2), it deletes the expected lines.

hawkw commented

the problem is that deleting a range of lines is Not Trivial, since the behaviour you'd expect is to delete from the start of the first line to the end of the last line