mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test(legacy/prompt_buffer_spec): align script with oldtest more (#22354)
This commit is contained in:
parent
f0ee548137
commit
fec1181ecd
@ -10,8 +10,7 @@ source screendump.vim
|
|||||||
func CanTestPromptBuffer()
|
func CanTestPromptBuffer()
|
||||||
" We need to use a terminal window to be able to feed keys without leaving
|
" We need to use a terminal window to be able to feed keys without leaving
|
||||||
" Insert mode.
|
" Insert mode.
|
||||||
" Nvim's terminal implementation differs from Vim's
|
CheckFeature terminal
|
||||||
" CheckFeature terminal
|
|
||||||
|
|
||||||
" TODO: make the tests work on MS-Windows
|
" TODO: make the tests work on MS-Windows
|
||||||
CheckNotMSWindows
|
CheckNotMSWindows
|
||||||
@ -56,7 +55,6 @@ func WriteScript(name)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_prompt_basic()
|
func Test_prompt_basic()
|
||||||
throw 'skipped: TODO'
|
|
||||||
call CanTestPromptBuffer()
|
call CanTestPromptBuffer()
|
||||||
let scriptName = 'XpromptscriptBasic'
|
let scriptName = 'XpromptscriptBasic'
|
||||||
call WriteScript(scriptName)
|
call WriteScript(scriptName)
|
||||||
@ -77,7 +75,6 @@ func Test_prompt_basic()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_prompt_editing()
|
func Test_prompt_editing()
|
||||||
throw 'skipped: TODO'
|
|
||||||
call CanTestPromptBuffer()
|
call CanTestPromptBuffer()
|
||||||
let scriptName = 'XpromptscriptEditing'
|
let scriptName = 'XpromptscriptEditing'
|
||||||
call WriteScript(scriptName)
|
call WriteScript(scriptName)
|
||||||
@ -108,7 +105,6 @@ func Test_prompt_editing()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_prompt_switch_windows()
|
func Test_prompt_switch_windows()
|
||||||
throw 'skipped: TODO'
|
|
||||||
call CanTestPromptBuffer()
|
call CanTestPromptBuffer()
|
||||||
let scriptName = 'XpromptSwitchWindows'
|
let scriptName = 'XpromptSwitchWindows'
|
||||||
call WriteScript(scriptName)
|
call WriteScript(scriptName)
|
||||||
@ -226,7 +222,6 @@ func Test_prompt_buffer_getbufinfo()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_prompt_while_writing_to_hidden_buffer()
|
func Test_prompt_while_writing_to_hidden_buffer()
|
||||||
throw 'skipped: TODO'
|
|
||||||
call CanTestPromptBuffer()
|
call CanTestPromptBuffer()
|
||||||
CheckUnix
|
CheckUnix
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local feed_command = helpers.feed_command
|
|
||||||
local poke_eventloop = helpers.poke_eventloop
|
local poke_eventloop = helpers.poke_eventloop
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
@ -16,64 +15,74 @@ describe('prompt buffer', function()
|
|||||||
screen = Screen.new(25, 10)
|
screen = Screen.new(25, 10)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
source([[
|
source([[
|
||||||
|
set laststatus=0 nohidden
|
||||||
|
|
||||||
func TextEntered(text)
|
func TextEntered(text)
|
||||||
if a:text == "exit"
|
if a:text == "exit"
|
||||||
|
" Reset &modified to allow the buffer to be closed.
|
||||||
set nomodified
|
set nomodified
|
||||||
stopinsert
|
stopinsert
|
||||||
close
|
close
|
||||||
else
|
else
|
||||||
|
" Add the output above the current prompt.
|
||||||
call append(line("$") - 1, 'Command: "' . a:text . '"')
|
call append(line("$") - 1, 'Command: "' . a:text . '"')
|
||||||
|
" Reset &modified to allow the buffer to be closed.
|
||||||
set nomodified
|
set nomodified
|
||||||
call timer_start(20, {id -> TimerFunc(a:text)})
|
call timer_start(20, {id -> TimerFunc(a:text)})
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func TimerFunc(text)
|
func TimerFunc(text)
|
||||||
|
" Add the output above the current prompt.
|
||||||
call append(line("$") - 1, 'Result: "' . a:text .'"')
|
call append(line("$") - 1, 'Result: "' . a:text .'"')
|
||||||
|
" Reset &modified to allow the buffer to be closed.
|
||||||
|
set nomodified
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func SwitchWindows()
|
func SwitchWindows()
|
||||||
call timer_start(0, {-> execute("wincmd p", "")})
|
call timer_start(0, {-> execute("wincmd p", "")})
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
call setline(1, "other buffer")
|
||||||
|
set nomodified
|
||||||
|
new
|
||||||
|
set buftype=prompt
|
||||||
|
call prompt_setcallback(bufnr(''), function("TextEntered"))
|
||||||
|
eval bufnr("")->prompt_setprompt("cmd: ")
|
||||||
|
startinsert
|
||||||
|
]])
|
||||||
|
screen:expect([[
|
||||||
|
cmd: ^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
[Prompt] [+] |
|
||||||
|
other buffer |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed_command("set noshowmode | set laststatus=0")
|
|
||||||
feed_command("call setline(1, 'other buffer')")
|
|
||||||
feed_command("new")
|
|
||||||
feed_command("set buftype=prompt")
|
|
||||||
feed_command("call prompt_setcallback(bufnr(''), function('TextEntered'))")
|
|
||||||
feed_command("eval bufnr('')->prompt_setprompt('cmd: ')")
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_prompt_basic()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
screen:expect([[
|
|
||||||
^ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
[Prompt] |
|
|
||||||
other buffer |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
|
|
|
||||||
]])
|
|
||||||
feed("i")
|
|
||||||
feed("hello\n")
|
feed("hello\n")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
cmd: hello |
|
cmd: hello |
|
||||||
Command: "hello" |
|
Command: "hello" |
|
||||||
Result: "hello" |
|
Result: "hello" |
|
||||||
cmd: ^ |
|
cmd: ^ |
|
||||||
[Prompt] [+] |
|
[Prompt] |
|
||||||
other buffer |
|
other buffer |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed("exit\n")
|
feed("exit\n")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -90,20 +99,8 @@ describe('prompt buffer', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_prompt_editing()
|
||||||
it('editing', function()
|
it('editing', function()
|
||||||
screen:expect([[
|
|
||||||
^ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
[Prompt] |
|
|
||||||
other buffer |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
|
|
|
||||||
]])
|
|
||||||
feed("i")
|
|
||||||
feed("hello<BS><BS>")
|
feed("hello<BS><BS>")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
cmd: hel^ |
|
cmd: hel^ |
|
||||||
@ -115,7 +112,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed("<Left><Left><Left><BS>-")
|
feed("<Left><Left><Left><BS>-")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -128,7 +125,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed("<C-O>lz")
|
feed("<C-O>lz")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -141,7 +138,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed("<End>x")
|
feed("<End>x")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -154,7 +151,7 @@ describe('prompt buffer', function()
|
|||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
~ |
|
~ |
|
||||||
|
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
feed("<C-U>exit\n")
|
feed("<C-U>exit\n")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -171,21 +168,8 @@ describe('prompt buffer', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_prompt_switch_windows()
|
||||||
it('switch windows', function()
|
it('switch windows', function()
|
||||||
feed_command("set showmode")
|
|
||||||
feed("i")
|
|
||||||
screen:expect([[
|
|
||||||
cmd: ^ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
[Prompt] [+] |
|
|
||||||
other buffer |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
~ |
|
|
||||||
-- INSERT -- |
|
|
||||||
]])
|
|
||||||
feed("<C-O>:call SwitchWindows()<CR>")
|
feed("<C-O>:call SwitchWindows()<CR>")
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
cmd: |
|
cmd: |
|
||||||
@ -227,11 +211,11 @@ describe('prompt buffer', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_prompt_while_writing_to_hidden_buffer()
|
||||||
it('keeps insert mode after aucmd_restbuf in callback', function()
|
it('keeps insert mode after aucmd_restbuf in callback', function()
|
||||||
source [[
|
source [[
|
||||||
let s:buf = nvim_create_buf(1, 1)
|
let s:buf = nvim_create_buf(1, 1)
|
||||||
call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])})
|
call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])})
|
||||||
startinsert
|
|
||||||
]]
|
]]
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq({ mode = "i", blocking = false }, meths.get_mode())
|
eq({ mode = "i", blocking = false }, meths.get_mode())
|
||||||
|
Loading…
Reference in New Issue
Block a user