Skip to content

Commit 0ba75a9

Browse files
committed
patch 7.4.1360
Problem: Can't remove a callback with ch_setoptions(). Solution: When passing zero or an empty string remove the callback.
1 parent 1f6ef66 commit 0ba75a9

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

src/channel.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,6 @@ channel_set_job(channel_T *channel, job_T *job)
748748
channel->ch_job = job;
749749
}
750750

751-
/*
752-
* Set the callback for channel "channel".
753-
*/
754-
void
755-
channel_set_callback(channel_T *channel, char_u *callback)
756-
{
757-
vim_free(channel->ch_callback);
758-
channel->ch_callback = vim_strsave(callback);
759-
}
760-
761751
/*
762752
* Set various properties from an "options" argument.
763753
*/
@@ -769,9 +759,14 @@ channel_set_options(channel_T *channel, jobopt_T *options)
769759
if (options->jo_set & JO_TIMEOUT)
770760
channel->ch_timeout = options->jo_timeout;
771761

772-
if ((options->jo_set & JO_CALLBACK)
773-
&& options->jo_callback != NULL && *options->jo_callback != NUL)
774-
channel_set_callback(channel, options->jo_callback);
762+
if (options->jo_set & JO_CALLBACK)
763+
{
764+
vim_free(channel->ch_callback);
765+
if (options->jo_callback != NULL && *options->jo_callback != NUL)
766+
channel->ch_callback = vim_strsave(options->jo_callback);
767+
else
768+
channel->ch_callback = NULL;
769+
}
775770
}
776771

777772
/*

src/proto/channel.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ void channel_gui_register_all(void);
1010
channel_T *channel_open(char *hostname, int port_in, int waittime, void (*close_cb)(void));
1111
void channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err);
1212
void channel_set_job(channel_T *channel, job_T *job);
13-
void channel_set_callback(channel_T *channel, char_u *callback);
1413
void channel_set_options(channel_T *channel, jobopt_T *options);
1514
void channel_set_req_callback(channel_T *channel, char_u *callback, int id);
1615
char_u *channel_get(channel_T *channel);

src/testdir/test_channel.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func s:communicate(port)
149149
call ch_setoptions(handle, {'timeout': 1111})
150150
call assert_fails("call ch_setoptions(handle, {'waittime': 111})", "E475")
151151
call assert_fails("call ch_setoptions(handle, {'mode': 'json'})", "E475")
152+
call ch_setoptions(handle, {'callback': ''})
152153

153154
" Send an eval request that works.
154155
call assert_equal('ok', ch_sendexpr(handle, 'eval-works'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ static char *(features[]) =
747747

748748
static int included_patches[] =
749749
{ /* Add new patch number below this line */
750+
/**/
751+
1360,
750752
/**/
751753
1359,
752754
/**/

0 commit comments

Comments
 (0)