:ls : show "R", "F" for terminal-jobs #10370

This matches Vim behavior. From `:help :ls` :

    R    a terminal buffer with a running job
    F    a terminal buffer with a finished job
    ?    a terminal buffer without a job: `:terminal NONE`

TODO: implement `:terminal NONE`.

ref #10349
This commit is contained in:
Justin M. Keyes
2019-06-29 21:03:38 +02:00
committed by GitHub
parent c207095445
commit 2d4a37ebab
4 changed files with 48 additions and 4 deletions

View File

@@ -29,6 +29,7 @@
#include "nvim/api/vim.h"
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/channel.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
@@ -2608,9 +2609,10 @@ void buflist_list(exarg_T *eap)
const int changed_char = (buf->b_flags & BF_READERR)
? 'x'
: (bufIsChanged(buf) ? '+' : ' ');
const int ro_char = !MODIFIABLE(buf)
? '-'
: (buf->b_p_ro ? '=' : ' ');
int ro_char = !MODIFIABLE(buf) ? '-' : (buf->b_p_ro ? '=' : ' ');
if (buf->terminal) {
ro_char = channel_job_running((uint64_t)buf->b_p_channel) ? 'R' : 'F';
}
msg_putchar('\n');
len = vim_snprintf(

View File

@@ -762,6 +762,14 @@ static void set_info_event(void **argv)
channel_decref(chan);
}
bool channel_job_running(uint64_t id)
{
Channel *chan = find_channel(id);
return (chan
&& chan->streamtype == kChannelStreamProc
&& !process_is_stopped(&chan->stream.proc));
}
Dictionary channel_info(uint64_t id)
{
Channel *chan = find_channel(id);

View File

@@ -56,7 +56,8 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data)
static inline bool process_is_stopped(Process *proc)
{
return proc->stopped_time != 0;
bool exited = (proc->status >= 0);
return exited || (proc->stopped_time != 0);
}
#ifdef INCLUDE_GENERATED_DECLARATIONS