From b1731fe1b5d7a9b89acb6c2292b1e3e8f9f33544 Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Tue, 28 Feb 2017 15:19:45 +0000 Subject: vim-patch:8.0.0388 Fix a problem when filtering manually folded lines When foldMarkAdjustRecurse() is called to adjust folds that start inside the range of lines that are being moved and end outside that range, it calculates `amount_after` for its recursive call incorrectly. The calculation assumes that folds inside the changed range are being deleted, but this is not always the case. This means nested folds that start after the changed range of lines are shifted an incorrect amount. We fix this by calculating the `amount_after` differently if the folds inside the changed range are not being deleted. --- test/functional/normal/fold_spec.lua | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/functional/normal/fold_spec.lua (limited to 'test') diff --git a/test/functional/normal/fold_spec.lua b/test/functional/normal/fold_spec.lua new file mode 100644 index 0000000000..a2a2a35a8b --- /dev/null +++ b/test/functional/normal/fold_spec.lua @@ -0,0 +1,47 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local insert = helpers.insert +local feed = helpers.feed +local expect = helpers.expect +local execute = helpers.execute + +describe('Folds', function() + clear() + it('manual folding adjusts with filter', function() + insert([[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20]]) + execute('4,$fold', '%foldopen', '10,$fold', '%foldopen') + execute('1,8! cat') + feed('5ggzdzMGdd') + expect([[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9]]) + end) +end) -- cgit