Mercurial > vim
comparison src/channel.c @ 8667:8c80c21a1885 v7.4.1623
commit https://github.com/vim/vim/commit/e9d6a298df6108e2044b1f0da5a2712f0c51c7d9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 20 19:31:33 2016 +0100
patch 7.4.1623
Problem: All Channels share the message ID, it keeps getting bigger.
Solution: Use a message ID per channel.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 20 Mar 2016 19:45:04 +0100 |
parents | c70eea7a7677 |
children | 06848fe9c816 |
comparison
equal
deleted
inserted
replaced
8666:678da5faa602 | 8667:8c80c21a1885 |
---|---|
2293 } | 2293 } |
2294 return FAIL; | 2294 return FAIL; |
2295 } | 2295 } |
2296 | 2296 |
2297 /* | 2297 /* |
2298 * Return a unique ID to be used in a message. | |
2299 */ | |
2300 int | |
2301 channel_get_id(void) | |
2302 { | |
2303 static int next_id = 1; | |
2304 | |
2305 return next_id++; | |
2306 } | |
2307 | |
2308 /* | |
2309 * Read from channel "channel" for as long as there is something to read. | 2298 * Read from channel "channel" for as long as there is something to read. |
2310 * "part" is PART_SOCK, PART_OUT or PART_ERR. | 2299 * "part" is PART_SOCK, PART_OUT or PART_ERR. |
2311 * The data is put in the read queue. | 2300 * The data is put in the read queue. |
2312 */ | 2301 */ |
2313 void | 2302 void |
2785 { | 2774 { |
2786 EMSG(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); | 2775 EMSG(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); |
2787 return; | 2776 return; |
2788 } | 2777 } |
2789 | 2778 |
2790 id = channel_get_id(); | 2779 id = ++channel->ch_last_msg_id; |
2791 text = json_encode_nr_expr(id, &argvars[1], | 2780 text = json_encode_nr_expr(id, &argvars[1], |
2792 ch_mode == MODE_JS ? JSON_JS : 0); | 2781 ch_mode == MODE_JS ? JSON_JS : 0); |
2793 if (text == NULL) | 2782 if (text == NULL) |
2794 return; | 2783 return; |
2795 | 2784 |