Skip to content

Commit d22cb61

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 8610e74 + ec68a99 commit d22cb61

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

src/channel.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,8 +2376,9 @@ may_invoke_callback(channel_T *channel, int part)
23762376
typval_T *listtv = NULL;
23772377
typval_T argv[CH_JSON_MAX_ARGS];
23782378
int seq_nr = -1;
2379-
ch_mode_T ch_mode = channel->ch_part[part].ch_mode;
2380-
cbq_T *cbhead = &channel->ch_part[part].ch_cb_head;
2379+
chanpart_T *ch_part = &channel->ch_part[part];
2380+
ch_mode_T ch_mode = ch_part->ch_mode;
2381+
cbq_T *cbhead = &ch_part->ch_cb_head;
23812382
cbq_T *cbitem;
23822383
char_u *callback = NULL;
23832384
partial_T *partial = NULL;
@@ -2397,22 +2398,22 @@ may_invoke_callback(channel_T *channel, int part)
23972398
callback = cbitem->cq_callback;
23982399
partial = cbitem->cq_partial;
23992400
}
2400-
else if (channel->ch_part[part].ch_callback != NULL)
2401+
else if (ch_part->ch_callback != NULL)
24012402
{
2402-
callback = channel->ch_part[part].ch_callback;
2403-
partial = channel->ch_part[part].ch_partial;
2403+
callback = ch_part->ch_callback;
2404+
partial = ch_part->ch_partial;
24042405
}
24052406
else
24062407
{
24072408
callback = channel->ch_callback;
24082409
partial = channel->ch_partial;
24092410
}
24102411

2411-
buffer = channel->ch_part[part].ch_bufref.br_buf;
2412-
if (buffer != NULL && !bufref_valid(&channel->ch_part[part].ch_bufref))
2412+
buffer = ch_part->ch_bufref.br_buf;
2413+
if (buffer != NULL && !bufref_valid(&ch_part->ch_bufref))
24132414
{
24142415
/* buffer was wiped out */
2415-
channel->ch_part[part].ch_bufref.br_buf = NULL;
2416+
ch_part->ch_bufref.br_buf = NULL;
24162417
buffer = NULL;
24172418
}
24182419

@@ -2473,7 +2474,7 @@ may_invoke_callback(channel_T *channel, int part)
24732474

24742475
if (ch_mode == MODE_NL)
24752476
{
2476-
char_u *nl;
2477+
char_u *nl = NULL;
24772478
char_u *buf;
24782479
readq_T *node;
24792480

@@ -2486,10 +2487,25 @@ may_invoke_callback(channel_T *channel, int part)
24862487
if (nl != NULL)
24872488
break;
24882489
if (channel_collapse(channel, part, TRUE) == FAIL)
2490+
{
2491+
if (ch_part->ch_fd == INVALID_FD && node->rq_buflen > 0)
2492+
break;
24892493
return FALSE; /* incomplete message */
2494+
}
24902495
}
24912496
buf = node->rq_buffer;
24922497

2498+
if (nl == NULL)
2499+
{
2500+
/* Flush remaining message that is missing a NL. */
2501+
buf = vim_realloc(buf, node->rq_buflen + 1);
2502+
if (buf == NULL)
2503+
return FALSE;
2504+
node->rq_buffer = buf;
2505+
nl = buf + node->rq_buflen++;
2506+
*nl = NUL;
2507+
}
2508+
24932509
/* Convert NUL to NL, the internal representation. */
24942510
for (p = buf; p < nl && p < buf + node->rq_buflen; ++p)
24952511
if (*p == NUL)

src/testdir/test_channel.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,27 @@ func Test_raw_passes_nul()
14841484
bwipe!
14851485
endfunc
14861486

1487+
func MyLineCountCb(ch, msg)
1488+
let g:linecount += 1
1489+
endfunc
1490+
1491+
func Test_read_nonl_line()
1492+
if !has('job')
1493+
return
1494+
endif
1495+
1496+
let g:linecount = 0
1497+
if has('win32')
1498+
" workaround: 'shellescape' does improper escaping double quotes
1499+
let arg = 'import sys;sys.stdout.write(\"1\n2\n3\")'
1500+
else
1501+
let arg = 'import sys;sys.stdout.write("1\n2\n3")'
1502+
endif
1503+
call job_start([s:python, '-c', arg], {'callback': 'MyLineCountCb'})
1504+
call WaitFor('3 <= g:linecount')
1505+
call assert_equal(3, g:linecount)
1506+
endfunc
1507+
14871508
function Ch_test_close_lambda(port)
14881509
let handle = ch_open('localhost:' . a:port, s:chopt)
14891510
if ch_status(handle) == "fail"

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
22,
782784
/**/
783785
21,
784786
/**/

0 commit comments

Comments
 (0)