aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-12 05:51:49 +0800
committerGitHub <noreply@github.com>2023-08-12 05:51:49 +0800
commit6e0c36ba0e6691401726fd4215f89729138ba82f (patch)
treec8eb7c4cfacbd72da41254f3f69b4e97f821ee8b /test
parent278805dfacc865c594c383f6f1fb7eeaf307aa15 (diff)
downloadrneovim-6e0c36ba0e6691401726fd4215f89729138ba82f.tar.gz
rneovim-6e0c36ba0e6691401726fd4215f89729138ba82f.tar.bz2
rneovim-6e0c36ba0e6691401726fd4215f89729138ba82f.zip
vim-patch:9.0.1686: undotree() only works for the current buffer (#24665)
Problem: undotree() only works for the current buffer Solution: Add an optional "buffer number" parameter to undotree(). If omitted, use the current buffer for backwards compatibility. closes: vim/vim#4001 closes: vim/vim#12292 https://github.com/vim/vim/commit/5fee11114975b7405b7ccd3ee8758e54bf559760 Co-authored-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_undo.vim47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim
index 4678a51d60..08a0ba4c39 100644
--- a/test/old/testdir/test_undo.vim
+++ b/test/old/testdir/test_undo.vim
@@ -93,6 +93,53 @@ func FillBuffer()
endfor
endfunc
+func Test_undotree_bufnr()
+ new
+ let buf1 = bufnr()
+
+ normal! Aabc
+ set ul=100
+
+ " Save undo tree without bufnr as ground truth for buffer 1
+ let d1 = undotree()
+
+ new
+ let buf2 = bufnr()
+
+ normal! Adef
+ set ul=100
+
+ normal! Aghi
+ set ul=100
+
+ " Save undo tree without bufnr as ground truth for buffer 2
+ let d2 = undotree()
+
+ " Check undotree() with bufnr argument
+ let d = undotree(buf1)
+ call assert_equal(d1, d)
+ call assert_notequal(d2, d)
+
+ let d = undotree(buf2)
+ call assert_notequal(d1, d)
+ call assert_equal(d2, d)
+
+ " Switch buffers and check again
+ wincmd p
+
+ let d = undotree(buf1)
+ call assert_equal(d1, d)
+
+ let d = undotree(buf2)
+ call assert_notequal(d1, d)
+ call assert_equal(d2, d)
+
+ " Drop created windows
+ set ul&
+ new
+ only!
+endfunc
+
func Test_global_local_undolevels()
new one
set undolevels=5