Mercurial > vim
diff src/channel.c @ 28467:3beb14b12bbd v8.2.4758
patch 8.2.4758: when using an LSP channel want to get the message ID
Commit: https://github.com/vim/vim/commit/3b470ae88f034d3741832ab1cc51a5bb8edaf4c6
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Apr 16 10:41:27 2022 +0100
patch 8.2.4758: when using an LSP channel want to get the message ID
Problem: When using an LSP channel want to get the message ID.
Solution: Have ch_sendexpr() return the ID. (Yegappan Lakshmanan,
closes #10202)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 Apr 2022 11:45:03 +0200 |
parents | 4dcccb2673fe |
children | 9f8563d05629 |
line wrap: on
line diff
--- a/src/channel.c +++ b/src/channel.c @@ -4520,6 +4520,7 @@ ch_expr_common(typval_T *argvars, typval 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 { 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 } } 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); + } } /*