mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
689e0daa95
commit
b1731fe1b5
@ -3654,10 +3654,10 @@ static linenr_T get_address(exarg_T *eap,
|
||||
n = 1;
|
||||
else
|
||||
n = getdigits(&cmd);
|
||||
if (addr_type == ADDR_LOADED_BUFFERS || addr_type == ADDR_BUFFERS)
|
||||
if (addr_type == ADDR_LOADED_BUFFERS || addr_type == ADDR_BUFFERS) {
|
||||
lnum = compute_buffer_local_count(
|
||||
addr_type, lnum, (i == '-') ? -1 * n : n);
|
||||
else {
|
||||
} else {
|
||||
// Relative line addressing, need to adjust for folded lines
|
||||
// now, but only do it after the first address.
|
||||
if (addr_type == ADDR_LINES && (i == '-' || i == '+')
|
||||
|
@ -1438,13 +1438,16 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2,
|
||||
} else {
|
||||
/* 5. fold is below line1 and contains line2; need to
|
||||
* correct nested folds too */
|
||||
foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
|
||||
line2 - fp->fd_top, amount,
|
||||
amount_after + (fp->fd_top - top));
|
||||
if (amount == MAXLNUM) {
|
||||
foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
|
||||
line2 - fp->fd_top, amount,
|
||||
amount_after + (fp->fd_top - top));
|
||||
fp->fd_len -= line2 - fp->fd_top + 1;
|
||||
fp->fd_top = line1;
|
||||
} else {
|
||||
foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
|
||||
line2 - fp->fd_top, amount,
|
||||
amount_after - amount);
|
||||
fp->fd_len += amount_after - amount;
|
||||
fp->fd_top += amount;
|
||||
}
|
||||
|
47
test/functional/normal/fold_spec.lua
Normal file
47
test/functional/normal/fold_spec.lua
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user