diff options
-rw-r--r-- | src/channel.c | 1 | ||||
-rw-r--r-- | src/testdir/test_channel.py | 19 | ||||
-rw-r--r-- | src/testdir/test_channel.vim | 29 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 48 insertions, 3 deletions
diff --git a/src/channel.c b/src/channel.c index 50dd18087c..af282cdae4 100644 --- a/src/channel.c +++ b/src/channel.c @@ -786,6 +786,7 @@ channel_get_json(int ch_idx, int id, typval_T **rettv) if ((id > 0 && tv->v_type == VAR_NUMBER && tv->vval.v_number == id) || (id <= 0 && (tv->v_type != VAR_NUMBER + || tv->vval.v_number == 0 || tv->vval.v_number != channel->ch_block_id))) { *rettv = item->value; diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py index 039a9de91e..311fbc07c8 100644 --- a/src/testdir/test_channel.py +++ b/src/testdir/test_channel.py @@ -130,6 +130,16 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): elif decoded[1] == 'eval-result': # Send back the last received eval result. response = last_eval + elif decoded[1] == 'call me': + cmd = '[0,"we called you"]' + print("sending: {}".format(cmd)) + self.request.sendall(cmd.encode('utf-8')) + response = "ok" + elif decoded[1] == 'call me again': + cmd = '[0,"we did call you"]' + print("sending: {}".format(cmd)) + self.request.sendall(cmd.encode('utf-8')) + response = "" elif decoded[1] == '!quit!': # we're done self.server.shutdown() @@ -140,9 +150,12 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): else: response = "what?" - encoded = json.dumps([decoded[0], response]) - print("sending: {}".format(encoded)) - self.request.sendall(encoded.encode('utf-8')) + if response == "": + print("no response") + else: + encoded = json.dumps([decoded[0], response]) + print("sending: {}".format(encoded)) + self.request.sendall(encoded.encode('utf-8')) # Negative numbers are used for "eval" responses. elif decoded[0] < 0: diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 819370348f..d77778a3e7 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -204,6 +204,35 @@ func Test_server_crash() call s:run_server('s:server_crash') endfunc +let s:reply = "" +func s:Handler(chan, msg) + let s:reply = a:msg +endfunc + +func s:channel_handler(port) + let chopt = copy(s:chopt) + let chopt['callback'] = 's:Handler' + let handle = ch_open('localhost:' . a:port, chopt) + if handle < 0 + call assert_false(1, "Can't open channel") + return + endif + + " Test that it works while waiting on a numbered message. + call assert_equal('ok', ch_sendexpr(handle, 'call me')) + sleep 10m + call assert_equal('we called you', s:reply) + + " Test that it works while not waiting on a numbered message. + call ch_sendexpr(handle, 'call me again', 0) + sleep 10m + call assert_equal('we did call you', s:reply) +endfunc + +func Test_channel_handler() + call s:run_server('s:channel_handler') +endfunc + " Test that trying to connect to a non-existing port fails quickly. func Test_connect_waittime() let start = reltime() diff --git a/src/version.c b/src/version.c index e6dbc9e0dc..9a77db0bd3 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1299, +/**/ 1298, /**/ 1297, |