Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d4a37e

Browse filesBrowse files
authored
: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
1 parent c207095 commit 2d4a37e
Copy full SHA for 2d4a37e

File tree

Expand file treeCollapse file tree

4 files changed

+48
-4
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+48
-4
lines changed

‎src/nvim/buffer.c

Copy file name to clipboardExpand all lines: src/nvim/buffer.c
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "nvim/api/vim.h"
3030
#include "nvim/ascii.h"
3131
#include "nvim/assert.h"
32+
#include "nvim/channel.h"
3233
#include "nvim/vim.h"
3334
#include "nvim/buffer.h"
3435
#include "nvim/charset.h"
@@ -2608,9 +2609,10 @@ void buflist_list(exarg_T *eap)
26082609
const int changed_char = (buf->b_flags & BF_READERR)
26092610
? 'x'
26102611
: (bufIsChanged(buf) ? '+' : ' ');
2611-
const int ro_char = !MODIFIABLE(buf)
2612-
? '-'
2613-
: (buf->b_p_ro ? '=' : ' ');
2612+
int ro_char = !MODIFIABLE(buf) ? '-' : (buf->b_p_ro ? '=' : ' ');
2613+
if (buf->terminal) {
2614+
ro_char = channel_job_running((uint64_t)buf->b_p_channel) ? 'R' : 'F';
2615+
}
26142616

26152617
msg_putchar('\n');
26162618
len = vim_snprintf(

‎src/nvim/channel.c

Copy file name to clipboardExpand all lines: src/nvim/channel.c
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,14 @@ static void set_info_event(void **argv)
762762
channel_decref(chan);
763763
}
764764

765+
bool channel_job_running(uint64_t id)
766+
{
767+
Channel *chan = find_channel(id);
768+
return (chan
769+
&& chan->streamtype == kChannelStreamProc
770+
&& !process_is_stopped(&chan->stream.proc));
771+
}
772+
765773
Dictionary channel_info(uint64_t id)
766774
{
767775
Channel *chan = find_channel(id);

‎src/nvim/event/process.h

Copy file name to clipboardExpand all lines: src/nvim/event/process.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data)
5656

5757
static inline bool process_is_stopped(Process *proc)
5858
{
59-
return proc->stopped_time != 0;
59+
bool exited = (proc->status >= 0);
60+
return exited || (proc->stopped_time != 0);
6061
}
6162

6263
#ifdef INCLUDE_GENERATED_DECLARATIONS

‎test/functional/ex_cmds/ls_spec.lua

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local helpers = require('test.functional.helpers')(after_each)
2+
local clear = helpers.clear
3+
local command = helpers.command
4+
local eq = helpers.eq
5+
local eval = helpers.eval
6+
local feed = helpers.feed
7+
local retry = helpers.retry
8+
9+
describe(':ls', function()
10+
before_each(function()
11+
clear()
12+
end)
13+
14+
it('R, F for :terminal buffers', function()
15+
command('edit foo')
16+
command('set hidden')
17+
command('terminal')
18+
command('vsplit')
19+
command('terminal')
20+
feed('iexit<cr>')
21+
retry(nil, 5000, function()
22+
local ls_output = eval('execute("ls")')
23+
-- Normal buffer.
24+
eq('\n 1 h ', string.match(ls_output, '\n *1....'))
25+
-- Terminal buffer [R]unning.
26+
eq('\n 2 #aR', string.match(ls_output, '\n *2....'))
27+
-- Terminal buffer [F]inished.
28+
eq('\n 3 %aF', string.match(ls_output, '\n *3....'))
29+
end)
30+
end)
31+
32+
end)
33+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.