feat(terminal): parse current buffer contents in nvim_open_term() (#33720)

When nvim_open_term() is called with a non-empty buffer, the buffer
contents are piped into the PTY.
This commit is contained in:
Gregory Anders
2025-04-30 16:34:23 -05:00
committed by GitHub
parent 6577d72d81
commit 71f3a9c590
9 changed files with 100 additions and 46 deletions

View File

@@ -3773,6 +3773,8 @@ describe('API', function()
},
[102] = { background = Screen.colors.LightMagenta, reverse = true },
[103] = { background = Screen.colors.LightMagenta, bold = true, reverse = true },
[104] = { fg_indexed = true, foreground = tonumber('0xe00000') },
[105] = { fg_indexed = true, foreground = tonumber('0xe0e000') },
}
end)
@@ -3887,6 +3889,24 @@ describe('API', function()
}
eq('ba\024blaherrejösses!', exec_lua [[ return stream ]])
end)
it('parses text from the current buffer', function()
local b = api.nvim_create_buf(true, true)
api.nvim_buf_set_lines(b, 0, -1, true, { '\027[31mHello\000\027[0m', '\027[33mworld\027[0m' })
api.nvim_set_current_buf(b)
screen:expect([[
{18:^^[}[31mHello{18:^@^[}[0m |
{18:^[}[33mworld{18:^[}[0m |
{1:~ }|*32
|
]])
api.nvim_open_term(b, {})
screen:expect([[
{104:^Hello} |
{105:world} |
|*33
]])
end)
end)
describe('nvim_del_mark', function()