1
mirror of https://github.com/neovim/neovim.git synced 2025-01-02 17:33:28 -07:00

vim-patch:9.0.1195: restoring KeyTyped when building statusline not tested

Problem:    Restoring KeyTyped when building statusline not tested.
Solution:   Add a test.  Clean up and fix other tests. (closes )

378e6c03f9
This commit is contained in:
zeertzjq 2023-01-14 19:52:44 +08:00
parent f95ad61a89
commit d98e4e4b2e
5 changed files with 139 additions and 9 deletions

View File

@ -569,22 +569,41 @@ func Test_statusline_showcmd()
CheckScreendump CheckScreendump
let lines =<< trim END let lines =<< trim END
func MyStatusLine()
return '%S'
endfunc
set laststatus=2 set laststatus=2
set statusline=%S set statusline=%!MyStatusLine()
set showcmdloc=statusline set showcmdloc=statusline
call setline(1, ['a', 'b', 'c']) call setline(1, ['a', 'b', 'c'])
set foldopen+=jump
1,2fold
3
END END
call writefile(lines, 'XTest_statusline', 'D') call writefile(lines, 'XTest_statusline', 'D')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6}) let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
call feedkeys("\<C-V>Gl", "xt")
call term_sendkeys(buf, "g")
call VerifyScreenDump(buf, 'Test_statusline_showcmd_1', {}) call VerifyScreenDump(buf, 'Test_statusline_showcmd_1', {})
call feedkeys("\<Esc>1234", "xt") " typing "gg" should open the fold
call term_sendkeys(buf, "g")
call VerifyScreenDump(buf, 'Test_statusline_showcmd_2', {}) call VerifyScreenDump(buf, 'Test_statusline_showcmd_2', {})
call feedkeys("\<Esc>:set statusline=\<CR>:\<CR>1234", "xt") call term_sendkeys(buf, "\<C-V>Gl")
call VerifyScreenDump(buf, 'Test_statusline_showcmd_3', {}) call VerifyScreenDump(buf, 'Test_statusline_showcmd_3', {})
call term_sendkeys(buf, "\<Esc>1234")
call VerifyScreenDump(buf, 'Test_statusline_showcmd_4', {})
call term_sendkeys(buf, "\<Esc>:set statusline=\<CR>")
call term_sendkeys(buf, ":\<CR>")
call term_sendkeys(buf, "1234")
call VerifyScreenDump(buf, 'Test_statusline_showcmd_5', {})
call StopVimInTerminal(buf)
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -167,19 +167,41 @@ func Test_tabline_showcmd()
CheckScreendump CheckScreendump
let lines =<< trim END let lines =<< trim END
func MyTabLine()
return '%S'
endfunc
set showtabline=2 set showtabline=2
set tabline=%!MyTabLine()
set showcmdloc=tabline set showcmdloc=tabline
call setline(1, ['a', 'b', 'c']) call setline(1, ['a', 'b', 'c'])
set foldopen+=jump
1,2fold
3
END END
call writefile(lines, 'XTest_tabline', 'D') call writefile(lines, 'XTest_tabline', 'D')
let buf = RunVimInTerminal('-S XTest_tabline', {'rows': 6}) let buf = RunVimInTerminal('-S XTest_tabline', {'rows': 6})
call feedkeys("\<C-V>Gl", "xt") call term_sendkeys(buf, "g")
call VerifyScreenDump(buf, 'Test_tabline_showcmd_1', {}) call VerifyScreenDump(buf, 'Test_tabline_showcmd_1', {})
call feedkeys("\<Esc>1234", "xt") " typing "gg" should open the fold
call term_sendkeys(buf, "g")
call VerifyScreenDump(buf, 'Test_tabline_showcmd_2', {}) call VerifyScreenDump(buf, 'Test_tabline_showcmd_2', {})
call term_sendkeys(buf, "\<C-V>Gl")
call VerifyScreenDump(buf, 'Test_tabline_showcmd_3', {})
call term_sendkeys(buf, "\<Esc>1234")
call VerifyScreenDump(buf, 'Test_tabline_showcmd_4', {})
call term_sendkeys(buf, "\<Esc>:set tabline=\<CR>")
call term_sendkeys(buf, ":\<CR>")
call term_sendkeys(buf, "1234")
call VerifyScreenDump(buf, 'Test_tabline_showcmd_5', {})
call StopVimInTerminal(buf)
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -1761,6 +1761,8 @@ function Test_splitkeep_callback()
call term_sendkeys(buf, ":quit\<CR>Gt") call term_sendkeys(buf, ":quit\<CR>Gt")
call VerifyScreenDump(buf, 'Test_splitkeep_callback_4', {}) call VerifyScreenDump(buf, 'Test_splitkeep_callback_4', {})
call StopVimInTerminal(buf)
endfunc endfunc
function Test_splitkeep_fold() function Test_splitkeep_fold()
@ -1791,6 +1793,8 @@ function Test_splitkeep_fold()
call term_sendkeys(buf, ":wincmd k\<CR>:quit\<CR>") call term_sendkeys(buf, ":wincmd k\<CR>:quit\<CR>")
call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {}) call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {})
call StopVimInTerminal(buf)
endfunction endfunction
function Test_splitkeep_status() function Test_splitkeep_status()
@ -1809,6 +1813,8 @@ function Test_splitkeep_status()
call term_sendkeys(buf, ":call win_move_statusline(win, 1)\<CR>") call term_sendkeys(buf, ":call win_move_statusline(win, 1)\<CR>")
call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {}) call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {})
call StopVimInTerminal(buf)
endfunction endfunction
function Test_new_help_window_on_error() function Test_new_help_window_on_error()

View File

@ -76,14 +76,46 @@ describe('statusline', function()
[1] = {background = Screen.colors.LightGrey}, -- Visual [1] = {background = Screen.colors.LightGrey}, -- Visual
[2] = {bold = true}, -- MoreMsg [2] = {bold = true}, -- MoreMsg
[3] = {bold = true, reverse = true}, -- StatusLine [3] = {bold = true, reverse = true}, -- StatusLine
[5] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, -- Folded
}) })
exec([[ exec([[
func MyStatusLine()
return '%S'
endfunc
set showcmd set showcmd
set laststatus=2 set laststatus=2
set statusline=%S set statusline=%S
set showcmdloc=statusline set showcmdloc=statusline
call setline(1, ['a', 'b', 'c']) call setline(1, ['a', 'b', 'c'])
set foldopen+=jump
1,2fold
3
]]) ]])
feed('g')
screen:expect([[
{5:+-- 2 lines: a···································}|
^c |
{0:~ }|
{0:~ }|
{0:~ }|
{3:g }|
|
]])
-- typing "gg" should open the fold
feed('g')
screen:expect([[
^a |
b |
c |
{0:~ }|
{0:~ }|
{3: }|
|
]])
feed('<C-V>Gl') feed('<C-V>Gl')
screen:expect([[ screen:expect([[
{1:a} | {1:a} |
@ -94,6 +126,7 @@ describe('statusline', function()
{3:3x2 }| {3:3x2 }|
{2:-- VISUAL BLOCK --} | {2:-- VISUAL BLOCK --} |
]]) ]])
feed('<Esc>1234') feed('<Esc>1234')
screen:expect([[ screen:expect([[
a | a |
@ -104,7 +137,10 @@ describe('statusline', function()
{3:1234 }| {3:1234 }|
| |
]]) ]])
feed('<Esc>:set statusline=<CR>:<CR>1234')
feed('<Esc>:set statusline=<CR>')
feed(':<CR>')
feed('1234')
screen:expect([[ screen:expect([[
a | a |
b | b |

View File

@ -22,16 +22,49 @@ describe('tabline', function()
[2] = {bold = true}, -- MoreMsg, TabLineSel [2] = {bold = true}, -- MoreMsg, TabLineSel
[3] = {reverse = true}, -- TabLineFill [3] = {reverse = true}, -- TabLineFill
[4] = {background = Screen.colors.LightGrey, underline = true}, -- TabLine [4] = {background = Screen.colors.LightGrey, underline = true}, -- TabLine
[5] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, -- Folded
}) })
exec([[ exec([[
func MyTabLine()
return '%S'
endfunc
set showcmd set showcmd
set showtabline=2 set showtabline=2
set tabline=%!MyTabLine()
set showcmdloc=tabline set showcmdloc=tabline
call setline(1, ['a', 'b', 'c']) call setline(1, ['a', 'b', 'c'])
set foldopen+=jump
1,2fold
3
]]) ]])
feed('g')
screen:expect([[
{3:g }|
{5:+-- 2 lines: a···································}|
^c |
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
-- typing "gg" should open the fold
feed('g')
screen:expect([[
{3: }|
^a |
b |
c |
{0:~ }|
{0:~ }|
|
]])
feed('<C-V>Gl') feed('<C-V>Gl')
screen:expect([[ screen:expect([[
{2: + [No Name] }{3: }{4:3x2}{3: }| {3:3x2 }|
{1:a} | {1:a} |
{1:b} | {1:b} |
{1:c}^ | {1:c}^ |
@ -39,9 +72,10 @@ describe('tabline', function()
{0:~ }| {0:~ }|
{2:-- VISUAL BLOCK --} | {2:-- VISUAL BLOCK --} |
]]) ]])
feed('<Esc>1234') feed('<Esc>1234')
screen:expect([[ screen:expect([[
{2: + [No Name] }{3: }{4:1234}{3: }| {3:1234 }|
a | a |
b | b |
^c | ^c |
@ -49,5 +83,18 @@ describe('tabline', function()
{0:~ }| {0:~ }|
| |
]]) ]])
feed('<Esc>:set tabline=<CR>')
feed(':<CR>')
feed('1234')
screen:expect([[
{2: + [No Name] }{3: }{4:1234}{3: }|
a |
b |
^c |
{0:~ }|
{0:~ }|
: |
]])
end) end)
end) end)