patch 9.1.0843: too many strlen() calls in undo.c
Problem: too many strlen() calls in undo.c
Solution: refactor code and remove strlen() calls, update test_undo.vim
and close remaining open swap files (John Marriott)
closes: #15995
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim
index eec0e0b..2e598d3 100644
--- a/src/testdir/test_undo.vim
+++ b/src/testdir/test_undo.vim
@@ -149,7 +149,7 @@
" Drop created windows
set ul&
new
- only!
+ bw!
endfunc
func Test_global_local_undolevels()
@@ -193,6 +193,7 @@
" Drop created windows
set ul&
new
+ bw! one two
only!
endfunc
@@ -253,7 +254,7 @@
later 1h
call assert_equal('123-abc', getline(1))
- close!
+ bw!
endfunc
func Test_undolist()
@@ -274,7 +275,16 @@
call feedkeys('achange3\<Esc>', 'xt')
let a = execute('undolist')
call assert_match("^\nnumber changes when *saved\n *2 *2 *.*\n *3 *2 .*$", a)
- close!
+
+ " 3 save number
+ if has("persistent_undo")
+ setl undofile
+ w Xundolist.txt
+ defer delete('Xundolist.txt')
+ let lastline = execute('undolist')->split("\n")[-1]
+ call assert_match("ago 1", lastline)
+ endif
+ bw!
endfunc
func Test_U_command()
@@ -286,7 +296,7 @@
call assert_equal('', getline(1))
norm! U
call assert_equal('change1change2', getline(1))
- close!
+ bw!
endfunc
func Test_undojoin()
@@ -393,7 +403,7 @@
call feedkeys("u", 'x')
call assert_equal(['a', 'b', 'c', '12', 'd'], getline(2, '$'))
- close!
+ bw!
endfunc
func Test_undofile_earlier()