fold: foldMoveRange(): fix :move bug #6534

Closes #6540

In #6221 there was a mistake in calculating which folds need to be
re-ordered. When there are no folds after those that have been adjusted,
then `move_end` remains 0. This results in reverse_fold_order()
swapping folds that have been adjusted with uninitialised folds in the
remainder of the grow array.

Add a check in foldMoveRange() to account for this case.
This commit is contained in:
Matthew Malcomson
2017-04-16 20:15:50 +01:00
committed by Justin M. Keyes
parent 77a4f8f235
commit 263849b2dd
2 changed files with 26 additions and 4 deletions

View File

@@ -232,6 +232,25 @@ a
a]], '2,3m0')
eq({1, 2, 0, 0, 0}, get_folds())
end)
it('handles shifting all remaining folds', function()
test_move_indent([[
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a]], '13m7')
eq({1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0}, get_folds())
end)
end)
it('updates correctly on :read', function()
-- luacheck: ignore 621