aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorprollings <patrickrollings@gmail.com>2016-08-04 14:22:45 +1000
committerJustin M. Keyes <justinkz@gmail.com>2016-08-04 00:22:45 -0400
commit0d93cd6c46e0b81e981197c4446aceb325325b5a (patch)
treebc736baf8ae595cc252dd91c6a7f49cd74fc4f2b /src/nvim/testdir
parent08d11bd42f3cacc66f3d6097ff18c50059079f14 (diff)
downloadrneovim-0d93cd6c46e0b81e981197c4446aceb325325b5a.tar.gz
rneovim-0d93cd6c46e0b81e981197c4446aceb325325b5a.tar.bz2
rneovim-0d93cd6c46e0b81e981197c4446aceb325325b5a.zip
vim-patch:7.4.1557 (#5117)
Problem: Windows cannot be identified. Solution: Add a unique window number to each window and functions to use it. https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test_window_id.vim71
2 files changed, 72 insertions, 0 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 9a0bba83fe..4979aae57a 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -39,6 +39,7 @@ NEW_TESTS = \
test_timers.res \
test_viml.res \
test_visual.res \
+ test_window_id.res \
test_alot.res
SCRIPTS_GUI := test16.out
diff --git a/src/nvim/testdir/test_window_id.vim b/src/nvim/testdir/test_window_id.vim
new file mode 100644
index 0000000000..b9e9f45c49
--- /dev/null
+++ b/src/nvim/testdir/test_window_id.vim
@@ -0,0 +1,71 @@
+" Test using the window ID.
+
+func Test_win_getid()
+ edit one
+ let id1 = win_getid()
+ split two
+ let id2 = win_getid()
+ split three
+ let id3 = win_getid()
+ tabnew
+ edit four
+ let id4 = win_getid()
+ split five
+ let id5 = win_getid()
+ tabnext
+
+ wincmd w
+ call assert_equal("two", expand("%"))
+ call assert_equal(id2, win_getid())
+ let nr2 = winnr()
+ wincmd w
+ call assert_equal("one", expand("%"))
+ call assert_equal(id1, win_getid())
+ let nr1 = winnr()
+ wincmd w
+ call assert_equal("three", expand("%"))
+ call assert_equal(id3, win_getid())
+ let nr3 = winnr()
+ tabnext
+ call assert_equal("five", expand("%"))
+ call assert_equal(id5, win_getid())
+ let nr5 = winnr()
+ wincmd w
+ call assert_equal("four", expand("%"))
+ call assert_equal(id4, win_getid())
+ let nr4 = winnr()
+ tabnext
+
+ exe nr1 . "wincmd w"
+ call assert_equal(id1, win_getid())
+ exe nr2 . "wincmd w"
+ call assert_equal(id2, win_getid())
+ exe nr3 . "wincmd w"
+ call assert_equal(id3, win_getid())
+ tabnext
+ exe nr4 . "wincmd w"
+ call assert_equal(id4, win_getid())
+ exe nr5 . "wincmd w"
+ call assert_equal(id5, win_getid())
+
+ call win_gotoid(id2)
+ call assert_equal("two", expand("%"))
+ call win_gotoid(id4)
+ call assert_equal("four", expand("%"))
+ call win_gotoid(id1)
+ call assert_equal("one", expand("%"))
+ call win_gotoid(id5)
+ call assert_equal("five", expand("%"))
+
+ call assert_equal(0, win_id2win(9999))
+ call assert_equal(nr5, win_id2win(id5))
+ call assert_equal(0, win_id2win(id1))
+ tabnext
+ call assert_equal(nr1, win_id2win(id1))
+
+ call assert_equal([0, 0], win_id2tabwin(9999))
+ call assert_equal([1, nr2], win_id2tabwin(id2))
+ call assert_equal([2, nr4], win_id2tabwin(id4))
+
+ only!
+endfunc