aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/channel_spec.lua
diff options
context:
space:
mode:
authorRaphael <glephunter@gmail.com>2023-12-14 16:08:00 +0800
committerGitHub <noreply@github.com>2023-12-14 16:08:00 +0800
commit619407eb548c7df56bc99b945338e9446f846fbb (patch)
tree7e3b4e11f467c32de90cdc1afa7de08cc725c4e7 /test/functional/terminal/channel_spec.lua
parent36552adb39edff2d909743f16c1f061bc74b5c4e (diff)
downloadrneovim-619407eb548c7df56bc99b945338e9446f846fbb.tar.gz
rneovim-619407eb548c7df56bc99b945338e9446f846fbb.tar.bz2
rneovim-619407eb548c7df56bc99b945338e9446f846fbb.zip
feat(nvim_open_term): convert LF => CRLF (#26384)
Problem: Unlike termopen(), nvim_open_term() PTYs do not carriage-return the cursor on newline ("\n") input. nvim --clean :let chan_id = nvim_open_term(1, {}) :call chansend(chan_id, ["here", "are", "some", "lines"]) Actual behavior: here are some lines Expected behaviour: here are some lines Solution: Add `force_crlf` option, and enable it by default.
Diffstat (limited to 'test/functional/terminal/channel_spec.lua')
-rw-r--r--test/functional/terminal/channel_spec.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
index 6fb1a21561..b9abcd61c8 100644
--- a/test/functional/terminal/channel_spec.lua
+++ b/test/functional/terminal/channel_spec.lua
@@ -192,4 +192,55 @@ describe('no crash when TermOpen autocommand', function()
]]}
assert_alive()
end)
+
+ it('nvim_open_term({force_crlf=true}) converts newlines', function()
+ local buf = meths.create_buf(false, true)
+ local win = meths.get_current_win()
+ local term = meths.open_term(buf, {force_crlf = true})
+ screen:try_resize(8, 10)
+ meths.win_set_buf(win, buf)
+ meths.chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest')
+ screen:expect{grid=[[
+ ^here |
+ there |
+ foo |
+ bar |
+ |
+ test |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ meths.chan_send(term, '\nfirst')
+ screen:expect{grid=[[
+ ^here |
+ there |
+ foo |
+ bar |
+ |
+ test |
+ first |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ meths.buf_delete(buf, {force = true})
+ buf = meths.create_buf(false, true)
+ term = meths.open_term(buf, {force_crlf = false})
+ meths.win_set_buf(win, buf)
+ meths.chan_send(term, 'here\nthere')
+ screen:expect{grid=[[
+ ^here |
+ there |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ ]]}
+ end)
end)