summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_tabpage.vim
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
commit00c068502d170f9f9b59c4a68aa12e8835859f6c (patch)
tree2047fc01b8c70326d9b87b47a575e7e5f2141b62 /src/testdir/test_tabpage.vim
parentAdding upstream version 2:9.1.0016. (diff)
downloadvim-00c068502d170f9f9b59c4a68aa12e8835859f6c.tar.xz
vim-00c068502d170f9f9b59c4a68aa12e8835859f6c.zip
Adding upstream version 2:9.1.0199.upstream/2%9.1.0199
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/testdir/test_tabpage.vim')
-rw-r--r--src/testdir/test_tabpage.vim96
1 files changed, 92 insertions, 4 deletions
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 906fefc..a531f19 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -156,14 +156,85 @@ func Test_tabpage_drop()
tab split f3
normal! gt
call assert_equal(1, tabpagenr())
+ tab drop f4
+ call assert_equal(1, tabpagenr('#'))
tab drop f3
- call assert_equal(3, tabpagenr())
- call assert_equal(1, tabpagenr('#'))
+ call assert_equal(4, tabpagenr())
+ call assert_equal(2, tabpagenr('#'))
+ bwipe!
bwipe!
bwipe!
bwipe!
call assert_equal(1, tabpagenr('$'))
+
+ call assert_equal(1, winnr('$'))
+ call assert_equal('', bufname(''))
+ call writefile(['L1', 'L2'], 'Xdropfile', 'D')
+
+ " Test for ':tab drop single-file': reuse current buffer
+ let expected_nr = bufnr()
+ tab drop Xdropfile
+ call assert_equal(1, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ bwipe!
+
+ " Test for ':tab drop single-file': not reuse modified buffer
+ set modified
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile
+ call assert_equal(2, tabpagenr())
+ call assert_equal(2, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ bwipe!
+
+ " Test for ':tab drop single-file': multiple tabs already exist
+ tab split f2
+ tab split f3
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile
+ call assert_equal(4, tabpagenr())
+ call assert_equal(4, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': reuse current buffer
+ let expected_nr = bufnr()
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(1, tabpagenr())
+ call assert_equal(4, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': not reuse modified buffer
+ set modified
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(2, tabpagenr())
+ call assert_equal(5, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': multiple tabs already exist
+ tab split f2
+ tab split f3
+ let expected_nr = bufnr() + 1
+ tab drop a b c
+ call assert_equal(4, tabpagenr())
+ call assert_equal(6, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ let expected_nr = bufnr() + 3
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(5, tabpagenr())
+ call assert_equal(8, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
endfunc
" Test autocommands
@@ -260,14 +331,14 @@ function Test_tabpage_with_autocmd_tab_drop()
let s:li = []
tab drop test1
- call assert_equal(['BufLeave', 'BufEnter'], s:li)
+ call assert_equal(['BufEnter'], s:li)
let s:li = []
tab drop test2 test3
call assert_equal([
\ 'TabLeave', 'TabEnter', 'TabLeave', 'TabEnter',
\ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter',
- \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
+ \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter', 'BufEnter'], s:li)
autocmd! TestTabpageGroup
augroup! TestTabpageGroup
@@ -922,4 +993,21 @@ func Test_tabpage_drop_tabmove()
bwipe!
endfunc
+" Test that settabvar() shouldn't change the last accessed tabpage.
+func Test_lastused_tabpage_settabvar()
+ tabonly!
+ tabnew
+ tabnew
+ tabnew
+ call assert_equal(3, tabpagenr('#'))
+
+ call settabvar(2, 'myvar', 'tabval')
+ call assert_equal('tabval', gettabvar(2, 'myvar'))
+ call assert_equal(3, tabpagenr('#'))
+
+ bwipe!
+ bwipe!
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab