patch 9.1.1442: tests: Test_diff_fold_redraw() is insufficient

Problem:  tests: Test_diff_fold_redraw() is insufficient
          (after v9.1.1439, Christ van Willegen)
Solution: improve the test (Gary Johnson)

The original Test_diff_fold_redraw() function, added 2025-06-08 at patch
9.1.1439, had a bug and didn't do a very good job of testing the fold
behavior.  This new version is simpler and more thorough.

The bug was that it checked the fold state of one window twice instead
of checking both windows.

closes: #17492

Signed-off-by: Gary Johnson <garyjohn@spocom.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Gary Johnson
2025-06-09 20:19:35 +02:00
committed by Christian Brabandt
parent 09a62e6f64
commit 69565e3618
2 changed files with 16 additions and 20 deletions

View File

@ -52,32 +52,26 @@ endfunc
" Test for diff folding redraw after last diff is resolved " Test for diff folding redraw after last diff is resolved
func Test_diff_fold_redraw() func Test_diff_fold_redraw()
" Set up two files with the minimal case " Set up two files with a minimal case.
call writefile(['Paragraph 1', '', 'Paragraph 2', '', 'Paragraph 3'], 'Xfile1') call writefile(['Paragraph 1', '', 'Paragraph 2', '', 'Paragraph 3'], 'Xfile1')
call writefile(['Paragraph 1', '', 'Paragraph 3'], 'Xfile2') call writefile(['Paragraph 1', '', 'Paragraph 3'], 'Xfile2')
" Open in diff mode " Open in diff mode.
exe 'edit Xfile1' edit Xfile1
exe 'vert diffsplit Xfile2' vert diffsplit Xfile2
" Ensure both windows are in diff mode and folds are enabled " Go to the diff and apply :diffput to copy Paragraph 2 to Xfile2.
set foldmethod=diff wincmd l
set foldenable 3
diffput
" Go to the diff and apply dp to copy Paragraph 2 to Xfile2 " Check that the folds in both windows are closed and extend from the first
normal! ]c " line of the buffer to the last line of the buffer.
normal! dp call assert_equal(1, foldclosed(line("$")))
wincmd h
call assert_equal(1, foldclosed(line("$")))
" Redraw and check folds " Clean up.
redraw!
let win1_fold = foldclosed(1)
let win2_fold = foldclosed(1)
" Both windows should be fully folded (foldclosed returns 1 for top fold)
call assert_equal(1, win1_fold)
call assert_equal(1, win2_fold)
" Clean up
bwipe! bwipe!
bwipe! bwipe!
call delete('Xfile1') call delete('Xfile1')

View File

@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1442,
/**/ /**/
1441, 1441,
/**/ /**/