patch 7.4.2258
Problem: Two JSON messages are sent without a separator.
Solution: Separate messages with a NL. (closes #1001)
diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index b5a912c..07a2241 100644
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -38,15 +38,15 @@
print("received: {0}".format(received))
# We may receive two messages at once. Take the part up to the
- # matching "]" (recognized by finding "][").
+ # newline, which should be after the matching "]".
todo = received
while todo != '':
- splitidx = todo.find('][')
+ splitidx = todo.find('\n')
if splitidx < 0:
used = todo
todo = ''
else:
- used = todo[:splitidx + 1]
+ used = todo[:splitidx]
todo = todo[splitidx + 1:]
if used != received:
print("using: {0}".format(used))
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index fff9ebd..9640244 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -55,6 +55,17 @@
call WaitFor('exists("g:split")')
call assert_equal(123, g:split)
+ " string with ][ should work
+ call assert_equal('this][that', ch_evalexpr(handle, 'echo this][that'))
+
+ " sending three messages quickly then reading should work
+ for i in range(3)
+ call ch_sendexpr(handle, 'echo hello ' . i)
+ endfor
+ call assert_equal('hello 0', ch_read(handle)[1])
+ call assert_equal('hello 1', ch_read(handle)[1])
+ call assert_equal('hello 2', ch_read(handle)[1])
+
" Request that triggers sending two ex commands. These will usually be
" handled before getting the response, but it's not guaranteed, thus wait a
" tiny bit for the commands to get executed.