aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/prompt_buffer_spec.lua
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2019-05-20 11:57:45 +0900
committererw7 <erw7.github@gmail.com>2020-02-12 15:16:32 +0900
commit4813ad48cd12a03ca50c01ac1b20518bf4df57f2 (patch)
treef0c15d85ef763dc504ac8bace7a1f08bf366feb8 /test/functional/legacy/prompt_buffer_spec.lua
parent58ec72f9fdfd186e5154ce82be1da7c65b9c8ea0 (diff)
downloadrneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.tar.gz
rneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.tar.bz2
rneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.zip
vim-patch:8.1.0027: difficult to make a plugin that feeds a line to a job
Problem: Difficult to make a plugin that feeds a line to a job. Solution: Add the nitial code for the "prompt" buftype. https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787
Diffstat (limited to 'test/functional/legacy/prompt_buffer_spec.lua')
-rw-r--r--test/functional/legacy/prompt_buffer_spec.lua84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua
new file mode 100644
index 0000000000..749e65a985
--- /dev/null
+++ b/test/functional/legacy/prompt_buffer_spec.lua
@@ -0,0 +1,84 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local feed= helpers.feed
+local source = helpers.source
+local clear = helpers.clear
+local feed_command = helpers.feed_command
+
+describe('prompt buffer', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 10)
+ screen:attach()
+ source([[
+ func TextEntered(text)
+ if a:text == "exit"
+ stopinsert
+ close
+ else
+ call append(line("$") - 1, 'Command: "' . a:text . '"')
+ set nomodfied
+ call timer_start(20, {id -> TimerFunc(a:text)})
+ endif
+ endfunc
+
+ func TimerFunc(text)
+ call append(line("$") - 1, 'Result: "' . a:text .'"')
+ endfunc
+ ]])
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('works', function()
+ 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'))")
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ [Scratch] |
+ other buffer |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed_command("startinsert")
+ feed("hello\n")
+ screen:expect([[
+ % hello |
+ Command: "hello" |
+ Result: "hello" |
+ % ^ |
+ [Scratch] |
+ other buffer |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ feed("exit\n")
+ screen:expect([[
+ ^other buffer |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ end)
+
+end)