diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-04-16 10:41:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-16 10:41:27 +0100 |
commit | 3b470ae88f034d3741832ab1cc51a5bb8edaf4c6 (patch) | |
tree | 67fd20212576c4297877ba49f31d9cbfa0cbe389 /src/channel.c | |
parent | b9e99e58bbc07a6fd1029db1f31c3ecf283d098b (diff) |
patch 8.2.4758: when using an LSP channel want to get the message IDv8.2.4758
Problem: When using an LSP channel want to get the message ID.
Solution: Have ch_sendexpr() return the ID. (Yegappan Lakshmanan,
closes #10202)
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c index 85089cb186..ef747d0e25 100644 --- a/src/channel.c +++ b/src/channel.c @@ -4520,6 +4520,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) ch_part_T part_read; jobopt_T opt; int timeout; + int callback_present = FALSE; // return an empty string by default rettv->v_type = VAR_STRING; @@ -4546,7 +4547,9 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) { dict_T *d; dictitem_T *di; - int callback_present = FALSE; + + // return an empty dict by default + rettv_dict_alloc(rettv); if (argvars[1].v_type != VAR_DICT) { @@ -4629,6 +4632,14 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) } } free_job_options(&opt); + if (ch_mode == MODE_LSP && !eval && callback_present) + { + // if ch_sendexpr() is used to send a LSP message and a callback + // function is specified, then return the generated identifier for the + // message. The user can use this to cancel the request (if needed). + if (rettv->vval.v_dict != NULL) + dict_add_number(rettv->vval.v_dict, "id", id); + } } /* |