mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 7.4.1303
Problem: A Funcref is not accepted as a callback. Solution: Make a Funcref work. (Damien)
This commit is contained in:
parent
6119e6156e
commit
b6a4fee37e
21
src/eval.c
21
src/eval.c
@ -9871,12 +9871,13 @@ f_ch_open(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
if (argvars[1].v_type == VAR_DICT)
|
if (argvars[1].v_type == VAR_DICT)
|
||||||
{
|
{
|
||||||
/* parse argdict */
|
dict_T *dict = argvars[1].vval.v_dict;
|
||||||
dict_T *dict = argvars[1].vval.v_dict;
|
dictitem_T *item;
|
||||||
|
|
||||||
if (dict_find(dict, (char_u *)"mode", -1) != NULL)
|
/* parse argdict */
|
||||||
|
if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
|
||||||
{
|
{
|
||||||
mode = get_dict_string(dict, (char_u *)"mode", FALSE);
|
mode = get_tv_string(&item->di_tv);
|
||||||
if (STRCMP(mode, "raw") == 0)
|
if (STRCMP(mode, "raw") == 0)
|
||||||
ch_mode = MODE_RAW;
|
ch_mode = MODE_RAW;
|
||||||
else if (STRCMP(mode, "js") == 0)
|
else if (STRCMP(mode, "js") == 0)
|
||||||
@ -9889,12 +9890,12 @@ f_ch_open(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dict_find(dict, (char_u *)"waittime", -1) != NULL)
|
if ((item = dict_find(dict, (char_u *)"waittime", -1)) != NULL)
|
||||||
waittime = get_dict_number(dict, (char_u *)"waittime");
|
waittime = get_tv_number(&item->di_tv);
|
||||||
if (dict_find(dict, (char_u *)"timeout", -1) != NULL)
|
if ((item = dict_find(dict, (char_u *)"timeout", -1)) != NULL)
|
||||||
timeout = get_dict_number(dict, (char_u *)"timeout");
|
timeout = get_tv_number(&item->di_tv);
|
||||||
if (dict_find(dict, (char_u *)"callback", -1) != NULL)
|
if ((item = dict_find(dict, (char_u *)"callback", -1)) != NULL)
|
||||||
callback = get_dict_string(dict, (char_u *)"callback", FALSE);
|
callback = get_callback(&item->di_tv);
|
||||||
}
|
}
|
||||||
if (waittime < 0 || timeout < 0)
|
if (waittime < 0 || timeout < 0)
|
||||||
{
|
{
|
||||||
|
@ -118,6 +118,13 @@ func s:communicate(port)
|
|||||||
call assert_equal(handle, s:responseHandle)
|
call assert_equal(handle, s:responseHandle)
|
||||||
call assert_equal('got it', s:responseMsg)
|
call assert_equal('got it', s:responseMsg)
|
||||||
|
|
||||||
|
let s:responseHandle = -1
|
||||||
|
let s:responseMsg = ''
|
||||||
|
call ch_sendexpr(handle, 'hello!', function('s:RequestHandler'))
|
||||||
|
sleep 10m
|
||||||
|
call assert_equal(handle, s:responseHandle)
|
||||||
|
call assert_equal('got it', s:responseMsg)
|
||||||
|
|
||||||
" Send an eval request that works.
|
" Send an eval request that works.
|
||||||
call assert_equal('ok', ch_sendexpr(handle, 'eval-works'))
|
call assert_equal('ok', ch_sendexpr(handle, 'eval-works'))
|
||||||
sleep 10m
|
sleep 10m
|
||||||
@ -206,13 +213,12 @@ endfunc
|
|||||||
|
|
||||||
let s:reply = ""
|
let s:reply = ""
|
||||||
func s:Handler(chan, msg)
|
func s:Handler(chan, msg)
|
||||||
|
unlet s:reply
|
||||||
let s:reply = a:msg
|
let s:reply = a:msg
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func s:channel_handler(port)
|
func s:channel_handler(port)
|
||||||
let chopt = copy(s:chopt)
|
let handle = ch_open('localhost:' . a:port, s:chopt)
|
||||||
let chopt['callback'] = 's:Handler'
|
|
||||||
let handle = ch_open('localhost:' . a:port, chopt)
|
|
||||||
if handle < 0
|
if handle < 0
|
||||||
call assert_false(1, "Can't open channel")
|
call assert_false(1, "Can't open channel")
|
||||||
return
|
return
|
||||||
@ -230,7 +236,11 @@ func s:channel_handler(port)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_channel_handler()
|
func Test_channel_handler()
|
||||||
|
let s:chopt.callback = 's:Handler'
|
||||||
call s:run_server('s:channel_handler')
|
call s:run_server('s:channel_handler')
|
||||||
|
let s:chopt.callback = function('s:Handler')
|
||||||
|
call s:run_server('s:channel_handler')
|
||||||
|
unlet s:chopt.callback
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test that trying to connect to a non-existing port fails quickly.
|
" Test that trying to connect to a non-existing port fails quickly.
|
||||||
|
@ -747,6 +747,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1303,
|
||||||
/**/
|
/**/
|
||||||
1302,
|
1302,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user