summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c13
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);
+ }
}
/*