feat(terminal): surface exit code via virttext + nvim_get_chan_info #37987

Problem:
When a terminal process exits, "[Process Exited]" text is added
to the buffer contents.

Solution:
- Return `exitcode` field from `nvim_get_chan_info`.
- Show it in the default 'statusline'.
- Show exitcode as virtual text in the terminal buffer.
This commit is contained in:
Ayaan
2026-03-10 17:32:50 +05:30
committed by GitHub
parent 0cc4f53b40
commit c8693051a8
22 changed files with 132 additions and 57 deletions

View File

@@ -16,6 +16,8 @@ local testprg = n.testprg
local exec_lua = n.exec_lua
local api = n.api
local nvim_prog = n.nvim_prog
local retry = t.retry
local eq = t.eq
local M = {}
@@ -221,4 +223,18 @@ function M.screen_expect(screen, s)
screen:expect(s)
end
--- Asserts that the exit code of chan eventually matches the expected exit code
---
--- @param code integer expected exit code
--- @param chan? integer channel id, defaults to current buffer's channel
function M.expect_exitcode(code, chan)
chan = chan or api.nvim_get_option_value('channel', { buf = 0 }) or 0
eq(true, chan > 0, 'Expected a valid channel ID, but got: ' .. chan)
retry(nil, nil, function()
local info = api.nvim_get_chan_info(chan)
eq(code, info.exitcode)
end)
end
return M