1
0
forked from aniani/vim

patch 9.0.1686: undotree() only works for the current buffer

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: #4001
closes: #12292

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Devin J. Pohly <djpohly@gmail.com>
This commit is contained in:
Devin J. Pohly
2023-04-23 20:26:59 -05:00
committed by Christian Brabandt
parent 422b9dcbfa
commit 5fee111149
7 changed files with 82 additions and 21 deletions

View File

@@ -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