mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
fix(folds): fix fold remains when :delete makes buffer empty (#19673)
This commit is contained in:
@@ -421,12 +421,12 @@ void deleted_lines(linenr_T lnum, linenr_T count)
|
|||||||
/// be triggered to display the cursor.
|
/// be triggered to display the cursor.
|
||||||
void deleted_lines_mark(linenr_T lnum, long count)
|
void deleted_lines_mark(linenr_T lnum, long count)
|
||||||
{
|
{
|
||||||
// if we deleted the entire buffer, we need to implicitly add a new empty line
|
|
||||||
bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
|
bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
|
||||||
|
|
||||||
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM,
|
mark_adjust(lnum, (linenr_T)(lnum + count - 1), MAXLNUM, -(linenr_T)count, kExtmarkNOOP);
|
||||||
-(linenr_T)count + (made_empty?1:0),
|
// if we deleted the entire buffer, we need to implicitly add a new empty line
|
||||||
kExtmarkUndo);
|
extmark_adjust(curbuf, lnum, (linenr_T)(lnum + count - 1), MAXLNUM,
|
||||||
|
-(linenr_T)count + (made_empty ? 1 : 0), kExtmarkUndo);
|
||||||
changed_lines(lnum, 0, lnum + (linenr_T)count, (linenr_T)(-count), true);
|
changed_lines(lnum, 0, lnum + (linenr_T)count, (linenr_T)(-count), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1904,4 +1904,11 @@ describe("folded lines", function()
|
|||||||
describe('without ext_multigrid', function()
|
describe('without ext_multigrid', function()
|
||||||
with_ext_multigrid(false)
|
with_ext_multigrid(false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('no folds remains if :delete makes buffer empty #19671', function()
|
||||||
|
funcs.setline(1, {'foo', 'bar', 'baz'})
|
||||||
|
command('2,3fold')
|
||||||
|
command('%delete')
|
||||||
|
eq(0, funcs.foldlevel(1))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user