aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-06-25 21:07:49 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-07-04 10:05:34 -0400
commitedaff441de1015068d7cee64c222f3c65fcd7dc6 (patch)
treef086b4aba319e5b225efeeccd4f73185b34fab7b /src/nvim/testdir
parent43a2e5fe4b4e107a53ccd5edbf2f3c0a97d79f6e (diff)
downloadrneovim-edaff441de1015068d7cee64c222f3c65fcd7dc6.tar.gz
rneovim-edaff441de1015068d7cee64c222f3c65fcd7dc6.tar.bz2
rneovim-edaff441de1015068d7cee64c222f3c65fcd7dc6.zip
vim-patch:8.1.1372: when evaluating 'statusline' the current window is unknown
Problem: When evaluating 'statusline' the current window is unknown. (Daniel Hahler) Solution: Set "g:actual_curwin" for %{} items. Set "g:statusline_winid" when evaluationg %!. (closes vim/vim#4406, closes vim/vim#3299) https://github.com/vim/vim/commit/1c6fd1e100fd0457375642ec50d483bcc0f61bb2
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_statusline.vim24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim
index 66b6e6c05c..8c81ec3431 100644
--- a/src/nvim/testdir/test_statusline.vim
+++ b/src/nvim/testdir/test_statusline.vim
@@ -7,6 +7,7 @@
" %X
source view_util.vim
+source term_util.vim
func s:get_statusline()
return ScreenLines(&lines - 1, &columns)[0]
@@ -29,7 +30,9 @@ endfunc
" Function used to display syntax group.
func SyntaxItem()
- return synIDattr(synID(line("."),col("."),1),"name")
+ call assert_equal(s:expected_curbuf, g:actual_curbuf)
+ call assert_equal(s:expected_curwin, g:actual_curwin)
+ return synIDattr(synID(line("."), col("."),1), "name")
endfunc
func Test_caught_error_in_statusline()
@@ -218,6 +221,8 @@ func Test_statusline()
"%{: Evaluate expression between '%{' and '}' and substitute result.
syntax on
+ let s:expected_curbuf = string(bufnr(''))
+ let s:expected_curwin = string(win_getid())
set statusline=%{SyntaxItem()}
call assert_match('^vimNumber\s*$', s:get_statusline())
s/^/"/
@@ -332,6 +337,23 @@ func Test_statusline()
set statusline=%!2*3+1
call assert_match('7\s*$', s:get_statusline())
+ func GetNested()
+ call assert_equal(string(win_getid()), g:actual_curwin)
+ call assert_equal(string(bufnr('')), g:actual_curbuf)
+ return 'nested'
+ endfunc
+ func GetStatusLine()
+ call assert_equal(win_getid(), g:statusline_winid)
+ return 'the %{GetNested()} line'
+ endfunc
+ set statusline=%!GetStatusLine()
+ call assert_match('the nested line', s:get_statusline())
+ call assert_false(exists('g:actual_curwin'))
+ call assert_false(exists('g:actual_curbuf'))
+ call assert_false(exists('g:statusline_winid'))
+ delfunc GetNested
+ delfunc GetStatusLine
+
" Check statusline in current and non-current window
" with the 'fillchars' option.
set fillchars=stl:^,stlnc:=,vert:\|,fold:-,diff:-