aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/embed_spec.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-05-02 23:24:37 +0200
committerGitHub <noreply@github.com>2022-05-02 23:24:37 +0200
commitddf7bb24f98b468d2bc6c16c6f300570fc6530f5 (patch)
tree8d2c78c2fa94ee7c7bfd40d7cc2f00bc54801eaf /test/functional/ui/embed_spec.lua
parenta1542b091dd7b919fa8524c1c909ef897dde9299 (diff)
parentad63b94b03c166f37bda477db6cbac2a9583d586 (diff)
downloadrneovim-ddf7bb24f98b468d2bc6c16c6f300570fc6530f5.tar.gz
rneovim-ddf7bb24f98b468d2bc6c16c6f300570fc6530f5.tar.bz2
rneovim-ddf7bb24f98b468d2bc6c16c6f300570fc6530f5.zip
Merge pull request #18357 from bfredl/ui_stdin
feat(ui): allow embedder to emulate "cat data | nvim -" behaviour
Diffstat (limited to 'test/functional/ui/embed_spec.lua')
-rw-r--r--test/functional/ui/embed_spec.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index 8218c8e12d..92f5beebf5 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -1,3 +1,5 @@
+local uv = require'luv'
+
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
@@ -98,3 +100,49 @@ end
describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end)
describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end)
+
+describe('--embed UI', function()
+ it('can pass stdin', function()
+ local pipe = assert(uv.pipe())
+
+ local writer = assert(uv.new_pipe(false))
+ writer:open(pipe.write)
+
+ clear {args_rm={'--headless'}, io_extra=pipe.read}
+
+ -- attach immediately after startup, for early UI
+ local screen = Screen.new(40, 8)
+ screen:attach {stdin_fd=3}
+ screen:set_default_attr_ids {
+ [1] = {bold = true, foreground = Screen.colors.Blue1};
+ [2] = {bold = true};
+ }
+
+ writer:write "hello nvim\nfrom external input\n"
+ writer:shutdown(function() writer:close() end)
+
+ screen:expect{grid=[[
+ ^hello nvim |
+ from external input |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+ -- stdin (rpc input) still works
+ feed 'o'
+ screen:expect{grid=[[
+ hello nvim |
+ ^ |
+ from external input |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- INSERT --} |
+ ]]}
+ end)
+end)