Mercurial > vim
diff src/testdir/test_statusline.vim @ 16740:dc85d49349f7 v8.1.1372
patch 8.1.1372: when evaluating 'statusline' the current window is unknown
commit https://github.com/vim/vim/commit/1c6fd1e100fd0457375642ec50d483bcc0f61bb2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 23 22:11:59 2019 +0200
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 #4406, closes #3299)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 May 2019 22:15:04 +0200 |
parents | 97e15f5b0082 |
children | 64eea864dff6 |
line wrap: on
line diff
--- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -29,7 +29,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 +220,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 +336,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:-