mirror of
https://github.com/vim/vim.git
synced 2025-10-15 07:14:09 -04:00
patch 8.1.1984: more functions can be used as methods
Problem: More functions can be used as methods. Solution: Make various functions usable as a method.
This commit is contained in:
@@ -48,6 +48,7 @@ func WriteScript(name)
|
||||
\ 'new',
|
||||
\ 'set buftype=prompt',
|
||||
\ 'call prompt_setcallback(bufnr(""), function("TextEntered"))',
|
||||
\ 'eval bufnr("")->prompt_setprompt("cmd: ")',
|
||||
\ 'startinsert',
|
||||
\ ], a:name)
|
||||
endfunc
|
||||
@@ -60,10 +61,10 @@ func Test_prompt_basic()
|
||||
call WriteScript(scriptName)
|
||||
|
||||
let buf = RunVimInTerminal('-S ' . scriptName, {})
|
||||
call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
|
||||
|
||||
call term_sendkeys(buf, "hello\<CR>")
|
||||
call WaitForAssert({-> assert_equal('% hello', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd: hello', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))})
|
||||
call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))})
|
||||
|
||||
@@ -82,19 +83,19 @@ func Test_prompt_editing()
|
||||
call WriteScript(scriptName)
|
||||
|
||||
let buf = RunVimInTerminal('-S ' . scriptName, {})
|
||||
call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
|
||||
|
||||
let bs = "\<BS>"
|
||||
call term_sendkeys(buf, "hello" . bs . bs)
|
||||
call WaitForAssert({-> assert_equal('% hel', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd: hel', term_getline(buf, 1))})
|
||||
|
||||
let left = "\<Left>"
|
||||
call term_sendkeys(buf, left . left . left . bs . '-')
|
||||
call WaitForAssert({-> assert_equal('% -hel', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd: -hel', term_getline(buf, 1))})
|
||||
|
||||
let end = "\<End>"
|
||||
call term_sendkeys(buf, end . "x")
|
||||
call WaitForAssert({-> assert_equal('% -helx', term_getline(buf, 1))})
|
||||
call WaitForAssert({-> assert_equal('cmd: -helx', term_getline(buf, 1))})
|
||||
|
||||
call term_sendkeys(buf, "\<C-U>exit\<CR>")
|
||||
call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
|
||||
@@ -113,8 +114,8 @@ func Test_prompt_garbage_collect()
|
||||
|
||||
new
|
||||
set buftype=prompt
|
||||
call prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}]))
|
||||
call prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}]))
|
||||
eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
|
||||
eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
|
||||
call test_garbagecollect_now()
|
||||
" Must not crash
|
||||
call feedkeys("\<CR>\<C-C>", 'xt')
|
||||
|
Reference in New Issue
Block a user