forked from aniani/vim
patch 7.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.
This commit is contained in:
@@ -2330,6 +2330,7 @@ arglistid([{winnr} [, {tabnr}]])
|
|||||||
With {winnr} only use this window in the current tab page.
|
With {winnr} only use this window in the current tab page.
|
||||||
With {winnr} and {tabnr} use the window in the specified tab
|
With {winnr} and {tabnr} use the window in the specified tab
|
||||||
page.
|
page.
|
||||||
|
{winnr} can be the window number or the window ID.
|
||||||
|
|
||||||
*argv()*
|
*argv()*
|
||||||
argv([{nr}]) The result is the {nr}th file in the argument list of the
|
argv([{nr}]) The result is the {nr}th file in the argument list of the
|
||||||
@@ -3987,6 +3988,7 @@ getcwd([{winnr} [, {tabnr}]])
|
|||||||
in the current tab page.
|
in the current tab page.
|
||||||
With {winnr} and {tabnr} return the local current directory of
|
With {winnr} and {tabnr} return the local current directory of
|
||||||
the window in the specified tab page.
|
the window in the specified tab page.
|
||||||
|
{winnr} can be the window number or the window ID.
|
||||||
Return an empty string if the arguments are invalid.
|
Return an empty string if the arguments are invalid.
|
||||||
|
|
||||||
getfsize({fname}) *getfsize()*
|
getfsize({fname}) *getfsize()*
|
||||||
@@ -4083,7 +4085,9 @@ getline({lnum} [, {end}])
|
|||||||
|
|
||||||
getloclist({nr}) *getloclist()*
|
getloclist({nr}) *getloclist()*
|
||||||
Returns a list with all the entries in the location list for
|
Returns a list with all the entries in the location list for
|
||||||
window {nr}. When {nr} is zero the current window is used.
|
window {nr}. {nr} can be the window number or the window ID.
|
||||||
|
When {nr} is zero the current window is used.
|
||||||
|
|
||||||
For a location list window, the displayed location list is
|
For a location list window, the displayed location list is
|
||||||
returned. For an invalid window number {nr}, an empty list is
|
returned. For an invalid window number {nr}, an empty list is
|
||||||
returned. Otherwise, same as |getqflist()|.
|
returned. Otherwise, same as |getqflist()|.
|
||||||
@@ -4217,6 +4221,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
|
|||||||
Note that {varname} must be the name without "w:".
|
Note that {varname} must be the name without "w:".
|
||||||
Tabs are numbered starting with one. For the current tabpage
|
Tabs are numbered starting with one. For the current tabpage
|
||||||
use |getwinvar()|.
|
use |getwinvar()|.
|
||||||
|
{winnr} can be the window number or the window ID.
|
||||||
When {winnr} is zero the current window is used.
|
When {winnr} is zero the current window is used.
|
||||||
This also works for a global option, buffer-local option and
|
This also works for a global option, buffer-local option and
|
||||||
window-local option, but it doesn't work for a global variable
|
window-local option, but it doesn't work for a global variable
|
||||||
@@ -4341,6 +4346,7 @@ haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
|
|||||||
With {winnr} use this window in the current tab page.
|
With {winnr} use this window in the current tab page.
|
||||||
With {winnr} and {tabnr} use the window in the specified tab
|
With {winnr} and {tabnr} use the window in the specified tab
|
||||||
page.
|
page.
|
||||||
|
{winnr} can be the window number or the window ID.
|
||||||
Return 0 if the arguments are invalid.
|
Return 0 if the arguments are invalid.
|
||||||
|
|
||||||
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
|
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
|
||||||
@@ -6287,9 +6293,11 @@ setline({lnum}, {text}) *setline()*
|
|||||||
|
|
||||||
setloclist({nr}, {list} [, {action}]) *setloclist()*
|
setloclist({nr}, {list} [, {action}]) *setloclist()*
|
||||||
Create or replace or add to the location list for window {nr}.
|
Create or replace or add to the location list for window {nr}.
|
||||||
When {nr} is zero the current window is used. For a location
|
{nr} can be the window number or the window ID.
|
||||||
list window, the displayed location list is modified. For an
|
When {nr} is zero the current window is used.
|
||||||
invalid window number {nr}, -1 is returned.
|
|
||||||
|
For a location list window, the displayed location list is
|
||||||
|
modified. For an invalid window number {nr}, -1 is returned.
|
||||||
Otherwise, same as |setqflist()|.
|
Otherwise, same as |setqflist()|.
|
||||||
Also see |location-list|.
|
Also see |location-list|.
|
||||||
|
|
||||||
@@ -6456,6 +6464,7 @@ settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
|
|||||||
{val}.
|
{val}.
|
||||||
Tabs are numbered starting with one. For the current tabpage
|
Tabs are numbered starting with one. For the current tabpage
|
||||||
use |setwinvar()|.
|
use |setwinvar()|.
|
||||||
|
{winnr} can be the window number or the window ID.
|
||||||
When {winnr} is zero the current window is used.
|
When {winnr} is zero the current window is used.
|
||||||
This also works for a global or local buffer option, but it
|
This also works for a global or local buffer option, but it
|
||||||
doesn't work for a global or local buffer variable.
|
doesn't work for a global or local buffer variable.
|
||||||
@@ -7528,9 +7537,11 @@ win_id2win({expr}) *win_id2win()*
|
|||||||
|
|
||||||
*winbufnr()*
|
*winbufnr()*
|
||||||
winbufnr({nr}) The result is a Number, which is the number of the buffer
|
winbufnr({nr}) The result is a Number, which is the number of the buffer
|
||||||
associated with window {nr}. When {nr} is zero, the number of
|
associated with window {nr}. {nr} can be the window number or
|
||||||
the buffer in the current window is returned. When window
|
the window ID.
|
||||||
{nr} doesn't exist, -1 is returned.
|
When {nr} is zero, the number of the buffer in the current
|
||||||
|
window is returned.
|
||||||
|
When window {nr} doesn't exist, -1 is returned.
|
||||||
Example: >
|
Example: >
|
||||||
:echo "The file in the current window is " . bufname(winbufnr(0))
|
:echo "The file in the current window is " . bufname(winbufnr(0))
|
||||||
<
|
<
|
||||||
@@ -7541,6 +7552,7 @@ wincol() The result is a Number, which is the virtual column of the
|
|||||||
|
|
||||||
winheight({nr}) *winheight()*
|
winheight({nr}) *winheight()*
|
||||||
The result is a Number, which is the height of window {nr}.
|
The result is a Number, which is the height of window {nr}.
|
||||||
|
{nr} can be the window number or the window ID.
|
||||||
When {nr} is zero, the height of the current window is
|
When {nr} is zero, the height of the current window is
|
||||||
returned. When window {nr} doesn't exist, -1 is returned.
|
returned. When window {nr} doesn't exist, -1 is returned.
|
||||||
An existing window always has a height of zero or more.
|
An existing window always has a height of zero or more.
|
||||||
@@ -7620,6 +7632,7 @@ winsaveview() Returns a |Dictionary| that contains information to restore
|
|||||||
|
|
||||||
winwidth({nr}) *winwidth()*
|
winwidth({nr}) *winwidth()*
|
||||||
The result is a Number, which is the width of window {nr}.
|
The result is a Number, which is the width of window {nr}.
|
||||||
|
{nr} can be the window number or the window ID.
|
||||||
When {nr} is zero, the width of the current window is
|
When {nr} is zero, the width of the current window is
|
||||||
returned. When window {nr} doesn't exist, -1 is returned.
|
returned. When window {nr} doesn't exist, -1 is returned.
|
||||||
An existing window always has a width of zero or more.
|
An existing window always has a width of zero or more.
|
||||||
|
11
src/eval.c
11
src/eval.c
@@ -13566,11 +13566,18 @@ find_win_by_nr(
|
|||||||
|
|
||||||
for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin;
|
for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin;
|
||||||
wp != NULL; wp = wp->w_next)
|
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;
|
break;
|
||||||
|
if (nr >= LOWEST_WIN_ID)
|
||||||
|
return NULL;
|
||||||
return wp;
|
return wp;
|
||||||
#else
|
#else
|
||||||
if (nr == 0 || nr == 1)
|
if (nr == 0 || nr == 1 || nr == curwin->w_id)
|
||||||
return curwin;
|
return curwin;
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -3,17 +3,22 @@
|
|||||||
func Test_win_getid()
|
func Test_win_getid()
|
||||||
edit one
|
edit one
|
||||||
let id1 = win_getid()
|
let id1 = win_getid()
|
||||||
|
let w:one = 'one'
|
||||||
split two
|
split two
|
||||||
let id2 = win_getid()
|
let id2 = win_getid()
|
||||||
let bufnr2 = bufnr('%')
|
let bufnr2 = bufnr('%')
|
||||||
|
let w:two = 'two'
|
||||||
split three
|
split three
|
||||||
let id3 = win_getid()
|
let id3 = win_getid()
|
||||||
|
let w:three = 'three'
|
||||||
tabnew
|
tabnew
|
||||||
edit four
|
edit four
|
||||||
let id4 = win_getid()
|
let id4 = win_getid()
|
||||||
|
let w:four = 'four'
|
||||||
split five
|
split five
|
||||||
let id5 = win_getid()
|
let id5 = win_getid()
|
||||||
let bufnr5 = bufnr('%')
|
let bufnr5 = bufnr('%')
|
||||||
|
let w:five = 'five'
|
||||||
tabnext
|
tabnext
|
||||||
|
|
||||||
wincmd w
|
wincmd w
|
||||||
@@ -28,6 +33,9 @@ func Test_win_getid()
|
|||||||
call assert_equal("three", expand("%"))
|
call assert_equal("three", expand("%"))
|
||||||
call assert_equal(id3, win_getid())
|
call assert_equal(id3, win_getid())
|
||||||
let nr3 = winnr()
|
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
|
tabnext
|
||||||
call assert_equal("five", expand("%"))
|
call assert_equal("five", expand("%"))
|
||||||
call assert_equal(id5, win_getid())
|
call assert_equal(id5, win_getid())
|
||||||
@@ -36,7 +44,14 @@ func Test_win_getid()
|
|||||||
call assert_equal("four", expand("%"))
|
call assert_equal("four", expand("%"))
|
||||||
call assert_equal(id4, win_getid())
|
call assert_equal(id4, win_getid())
|
||||||
let nr4 = winnr()
|
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
|
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"
|
exe nr1 . "wincmd w"
|
||||||
call assert_equal(id1, win_getid())
|
call assert_equal(id1, win_getid())
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1895,
|
||||||
/**/
|
/**/
|
||||||
1894,
|
1894,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2334,4 +2334,7 @@ int vim_main2(int argc, char **argv);
|
|||||||
#define DIP_OPT 0x10 /* also use "opt" directory in 'packpath' */
|
#define DIP_OPT 0x10 /* also use "opt" directory in 'packpath' */
|
||||||
#define DIP_NORTP 0x20 /* do not use 'runtimepath' */
|
#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 */
|
#endif /* VIM__H */
|
||||||
|
@@ -4422,7 +4422,7 @@ buf_jump_open_tab(buf_T *buf)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
* Allocate a window structure and link it in the window list when "hidden" is
|
||||||
|
Reference in New Issue
Block a user