comparison src/channel.c @ 9969:176e34b0d678 v7.4.2258

commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 26 17:58:53 2016 +0200 patch 7.4.2258 Problem: Two JSON messages are sent without a separator. Solution: Separate messages with a NL. (closes https://github.com/vim/vim/issues/1001)
author Christian Brabandt <cb@256bit.org>
date Fri, 26 Aug 2016 18:00:08 +0200
parents 9560a2eb7968
children 3b4b2ac811f0
comparison
equal deleted inserted replaced
9968:7171d7dd51b0 9969:176e34b0d678
2163 if (argv[id_idx].v_type == VAR_NUMBER) 2163 if (argv[id_idx].v_type == VAR_NUMBER)
2164 { 2164 {
2165 int id = argv[id_idx].vval.v_number; 2165 int id = argv[id_idx].vval.v_number;
2166 2166
2167 if (tv != NULL) 2167 if (tv != NULL)
2168 json = json_encode_nr_expr(id, tv, options); 2168 json = json_encode_nr_expr(id, tv, options | JSON_NL);
2169 if (tv == NULL || (json != NULL && *json == NUL)) 2169 if (tv == NULL || (json != NULL && *json == NUL))
2170 { 2170 {
2171 /* If evaluation failed or the result can't be encoded 2171 /* If evaluation failed or the result can't be encoded
2172 * then return the string "ERROR". */ 2172 * then return the string "ERROR". */
2173 vim_free(json); 2173 vim_free(json);
2174 free_tv(tv); 2174 free_tv(tv);
2175 err_tv.v_type = VAR_STRING; 2175 err_tv.v_type = VAR_STRING;
2176 err_tv.vval.v_string = (char_u *)"ERROR"; 2176 err_tv.vval.v_string = (char_u *)"ERROR";
2177 tv = &err_tv; 2177 tv = &err_tv;
2178 json = json_encode_nr_expr(id, tv, options); 2178 json = json_encode_nr_expr(id, tv, options | JSON_NL);
2179 } 2179 }
2180 if (json != NULL) 2180 if (json != NULL)
2181 { 2181 {
2182 channel_send(channel, 2182 channel_send(channel,
2183 part == PART_SOCK ? PART_SOCK : PART_IN, 2183 part == PART_SOCK ? PART_SOCK : PART_IN,
3498 return; 3498 return;
3499 } 3499 }
3500 3500
3501 id = ++channel->ch_last_msg_id; 3501 id = ++channel->ch_last_msg_id;
3502 text = json_encode_nr_expr(id, &argvars[1], 3502 text = json_encode_nr_expr(id, &argvars[1],
3503 ch_mode == MODE_JS ? JSON_JS : 0); 3503 (ch_mode == MODE_JS ? JSON_JS : 0) | JSON_NL);
3504 if (text == NULL) 3504 if (text == NULL)
3505 return; 3505 return;
3506 3506
3507 channel = send_common(argvars, text, id, eval, &opt, 3507 channel = send_common(argvars, text, id, eval, &opt,
3508 eval ? "ch_evalexpr" : "ch_sendexpr", &part_read); 3508 eval ? "ch_evalexpr" : "ch_sendexpr", &part_read);