summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-06-04 18:49:36 +0200
committerBram Moolenaar <Bram@vim.org>2016-06-04 18:49:36 +0200
commit888ccac8902cee186fbd47e971881f6d9b19c068 (patch)
treed7180b8cc4b4ecfea5880e3f2971742a9689dae8 /src
parent511972d810ea490955161ff5097ec2f57919ceaf (diff)
patch 7.4.1895v7.4.1895
Problem: Cannot use a window ID where a window number is expected. Solution: Add LOWEST_WIN_ID, so that the window ID can be used where a number is expected.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c11
-rw-r--r--src/testdir/test_window_id.vim15
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h3
-rw-r--r--src/window.c2
5 files changed, 30 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index 2a7a0906f9..4825e8be8a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -13566,11 +13566,18 @@ find_win_by_nr(
for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin;
wp != NULL; wp = wp->w_next)
- if (--nr <= 0)
+ if (nr >= LOWEST_WIN_ID)
+ {
+ if (wp->w_id == nr)
+ return wp;
+ }
+ else if (--nr <= 0)
break;
+ if (nr >= LOWEST_WIN_ID)
+ return NULL;
return wp;
#else
- if (nr == 0 || nr == 1)
+ if (nr == 0 || nr == 1 || nr == curwin->w_id)
return curwin;
return NULL;
#endif
diff --git a/src/testdir/test_window_id.vim b/src/testdir/test_window_id.vim
index fa3ebd757e..66656e1d0a 100644
--- a/src/testdir/test_window_id.vim
+++ b/src/testdir/test_window_id.vim
@@ -3,17 +3,22 @@
func Test_win_getid()
edit one
let id1 = win_getid()
+ let w:one = 'one'
split two
let id2 = win_getid()
let bufnr2 = bufnr('%')
+ let w:two = 'two'
split three
let id3 = win_getid()
+ let w:three = 'three'
tabnew
edit four
let id4 = win_getid()
+ let w:four = 'four'
split five
let id5 = win_getid()
let bufnr5 = bufnr('%')
+ let w:five = 'five'
tabnext
wincmd w
@@ -28,6 +33,9 @@ func Test_win_getid()
call assert_equal("three", expand("%"))
call assert_equal(id3, win_getid())
let nr3 = winnr()
+ call assert_equal('one', getwinvar(id1, 'one'))
+ call assert_equal('two', getwinvar(id2, 'two'))
+ call assert_equal('three', getwinvar(id3, 'three'))
tabnext
call assert_equal("five", expand("%"))
call assert_equal(id5, win_getid())
@@ -36,7 +44,14 @@ func Test_win_getid()
call assert_equal("four", expand("%"))
call assert_equal(id4, win_getid())
let nr4 = winnr()
+ call assert_equal('four', getwinvar(id4, 'four'))
+ call assert_equal('five', getwinvar(id5, 'five'))
+ call settabwinvar(1, id2, 'two', '2')
+ call setwinvar(id4, 'four', '4')
tabnext
+ call assert_equal('4', gettabwinvar(2, id4, 'four'))
+ call assert_equal('five', gettabwinvar(2, id5, 'five'))
+ call assert_equal('2', getwinvar(id2, 'two'))
exe nr1 . "wincmd w"
call assert_equal(id1, win_getid())
diff --git a/src/version.c b/src/version.c
index b83cb33236..1e7c2f290d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1895,
+/**/
1894,
/**/
1893,
diff --git a/src/vim.h b/src/vim.h
index fb991dcfa4..d573cea1ff 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2334,4 +2334,7 @@ int vim_main2(int argc, char **argv);
#define DIP_OPT 0x10 /* also use "opt" directory in 'packpath' */
#define DIP_NORTP 0x20 /* do not use 'runtimepath' */
+/* Lowest number used for window ID. Cannot have this many windows. */
+#define LOWEST_WIN_ID 1000
+
#endif /* VIM__H */
diff --git a/src/window.c b/src/window.c
index 01da765b46..2dc2554672 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4422,7 +4422,7 @@ buf_jump_open_tab(buf_T *buf)
}
#endif
-static int last_win_id = 0;
+static int last_win_id = LOWEST_WIN_ID - 1;
/*
* Allocate a window structure and link it in the window list when "hidden" is