mirror of
https://github.com/neovim/neovim.git
synced 2026-04-26 01:04:10 +00:00
fix(:ls): check for finished terminal properly (#37303)
Use terminal_running() instead of channel_job_running().
(cherry picked from commit 49d7f694a8)
This commit is contained in:
committed by
github-actions[bot]
parent
9f2b991331
commit
5e7af0ba01
@@ -2904,7 +2904,7 @@ void buflist_list(exarg_T *eap)
|
|||||||
: (bufIsChanged(buf) ? '+' : ' ');
|
: (bufIsChanged(buf) ? '+' : ' ');
|
||||||
int ro_char = !MODIFIABLE(buf) ? '-' : (buf->b_p_ro ? '=' : ' ');
|
int ro_char = !MODIFIABLE(buf) ? '-' : (buf->b_p_ro ? '=' : ' ');
|
||||||
if (buf->terminal) {
|
if (buf->terminal) {
|
||||||
ro_char = channel_job_running((uint64_t)buf->b_p_channel) ? 'R' : 'F';
|
ro_char = terminal_running(buf->terminal) ? 'R' : 'F';
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
|
|||||||
@@ -900,6 +900,8 @@ static void set_info_event(void **argv)
|
|||||||
channel_decref(chan);
|
channel_decref(chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unlike terminal_running(), this returns false immediately after stopping a job.
|
||||||
|
/// However, this always returns false for nvim_open_term() terminals.
|
||||||
bool channel_job_running(uint64_t id)
|
bool channel_job_running(uint64_t id)
|
||||||
{
|
{
|
||||||
Channel *chan = find_channel(id);
|
Channel *chan = find_channel(id);
|
||||||
|
|||||||
@@ -1889,6 +1889,8 @@ void do_wqall(exarg_T *eap)
|
|||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
if (exiting && !eap->forceit
|
if (exiting && !eap->forceit
|
||||||
&& buf->terminal
|
&& buf->terminal
|
||||||
|
// TODO(zeertzjq): this always returns false for nvim_open_term() terminals.
|
||||||
|
// Use terminal_running() instead?
|
||||||
&& channel_job_running((uint64_t)buf->b_p_channel)) {
|
&& channel_job_running((uint64_t)buf->b_p_channel)) {
|
||||||
no_write_message_buf(buf);
|
no_write_message_buf(buf);
|
||||||
error++;
|
error++;
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ describe(':ls', function()
|
|||||||
clear()
|
clear()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('R, F for :terminal buffers', function()
|
--- @param start_running_term fun()
|
||||||
api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
|
--- @param start_finished_term fun()
|
||||||
|
local function test_ls_terminal_buffer(start_running_term, start_finished_term)
|
||||||
command('edit foo')
|
command('edit foo')
|
||||||
command('set hidden')
|
command('set hidden')
|
||||||
command('terminal')
|
start_running_term()
|
||||||
command('vsplit')
|
command('vsplit')
|
||||||
command('terminal')
|
start_finished_term()
|
||||||
feed('iexit<cr>')
|
|
||||||
retry(nil, 5000, function()
|
retry(nil, 5000, function()
|
||||||
local ls_output = eval('execute("ls")')
|
local ls_output = eval('execute("ls")')
|
||||||
-- Normal buffer.
|
-- Normal buffer.
|
||||||
@@ -45,5 +45,25 @@ describe(':ls', function()
|
|||||||
-- Just the [F]inished terminal buffer.
|
-- Just the [F]inished terminal buffer.
|
||||||
eq('\n 3 %aF ', string.match(ls_output, '^\n *3 ... '))
|
eq('\n 3 %aF ', string.match(ls_output, '^\n *3 ... '))
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe('R, F for', function()
|
||||||
|
it('terminal buffers', function()
|
||||||
|
api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
|
||||||
|
test_ls_terminal_buffer(function()
|
||||||
|
command('terminal')
|
||||||
|
end, function()
|
||||||
|
command('terminal')
|
||||||
|
feed('iexit<cr>')
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('nvim_open_term() buffers', function()
|
||||||
|
test_ls_terminal_buffer(function()
|
||||||
|
command('enew | call nvim_open_term(0, {})')
|
||||||
|
end, function()
|
||||||
|
command('enew | call chanclose(nvim_open_term(0, {}))')
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user