aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal')
-rw-r--r--test/functional/terminal/scrollback_spec.lua70
-rw-r--r--test/functional/terminal/tui_spec.lua42
2 files changed, 110 insertions, 2 deletions
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index b932c58430..11bdc73a47 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -12,6 +12,8 @@ local curbufmeths = helpers.curbufmeths
local nvim = helpers.nvim
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
+local exec_lua = helpers.exec_lua
+local assert_alive = helpers.assert_alive
describe(':terminal scrollback', function()
local screen
@@ -527,3 +529,71 @@ describe("'scrollback' option", function()
end)
end)
+
+describe("pending scrollback line handling", function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(30, 7)
+ screen:attach()
+ screen:set_default_attr_ids {
+ [1] = {foreground = Screen.colors.Brown},
+ [2] = {reverse = true},
+ [3] = {bold = true},
+ }
+ end)
+
+ it("does not crash after setting 'number' #14891", function()
+ exec_lua [[
+ local a = vim.api
+ local buf = a.nvim_create_buf(true, true)
+ local chan = a.nvim_open_term(buf, {})
+ a.nvim_win_set_option(0, "number", true)
+ a.nvim_chan_send(chan, ("a\n"):rep(11) .. "a")
+ a.nvim_win_set_buf(0, buf)
+ ]]
+ screen:expect [[
+ {1: 1 }^a |
+ {1: 2 } a |
+ {1: 3 } a |
+ {1: 4 } a |
+ {1: 5 } a |
+ {1: 6 } a |
+ |
+ ]]
+ feed('G')
+ screen:expect [[
+ {1: 7 } a |
+ {1: 8 } a |
+ {1: 9 } a |
+ {1: 10 } a |
+ {1: 11 } a |
+ {1: 12 } ^a |
+ |
+ ]]
+ assert_alive()
+ end)
+
+ it("does not crash after nvim_buf_call #14891", function()
+ exec_lua [[
+ local a = vim.api
+ local bufnr = a.nvim_create_buf(false, true)
+ a.nvim_buf_call(bufnr, function()
+ vim.fn.termopen({"echo", ("hi\n"):rep(11)})
+ end)
+ a.nvim_win_set_buf(0, bufnr)
+ vim.cmd("startinsert")
+ ]]
+ screen:expect [[
+ hi |
+ hi |
+ hi |
+ |
+ |
+ [Process exited 0]{2: } |
+ {3:-- TERMINAL --} |
+ ]]
+ assert_alive()
+ end)
+end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 6b9586b4de..7113cc1b49 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -677,8 +677,8 @@ describe('TUI', function()
item 2997 |
item 2998 |
item 2999 |
- item 3000 en{1:d} |
- {5:[No Name] [+] 3000,13 Bot}|
+ item 3000 en{1:d}d |
+ {5:[No Name] [+] 5999,13 Bot}|
|
{3:-- TERMINAL --} |
]])
@@ -765,6 +765,44 @@ describe('TUI', function()
]])
end)
+ it('paste: streamed paste with isolated "stop paste" code', function()
+ child_session:request('nvim_exec_lua', [[
+ _G.paste_phases = {}
+ vim.paste = (function(overridden)
+ return function(lines, phase)
+ table.insert(_G.paste_phases, phase)
+ overridden(lines, phase)
+ end
+ end)(vim.paste)
+ ]], {})
+ feed_data('i')
+ feed_data('\027[200~pasted') -- phase 1
+ screen:expect([[
+ pasted{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]])
+ feed_data(' from terminal') -- phase 2
+ screen:expect([[
+ pasted from terminal{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]])
+ -- Send isolated "stop paste" sequence.
+ feed_data('\027[201~') -- phase 3
+ screen:expect_unchanged()
+ local _, rv = child_session:request('nvim_exec_lua', [[return _G.paste_phases]], {})
+ eq({1, 2, 3}, rv)
+ end)
+
it('allows termguicolors to be set at runtime', function()
screen:set_option('rgb', true)
screen:set_default_attr_ids({