0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 7.4.1810

Problem:    Sending DETACH after a channel was closed isn't useful.
Solution:   Only add DETACH for a netbeans channel.
This commit is contained in:
Bram Moolenaar
2016-04-30 17:06:31 +02:00
parent 868cfc19bb
commit 715d285d79
3 changed files with 10 additions and 14 deletions

View File

@@ -2595,7 +2595,7 @@ channel_free_all(void)
#endif #endif
/* Sent when the channel is found closed when reading. */ /* Sent when the netbeans channel is found closed when reading. */
#define DETACH_MSG_RAW "DETACH\n" #define DETACH_MSG_RAW "DETACH\n"
/* Buffer size for reading incoming messages. */ /* Buffer size for reading incoming messages. */
@@ -2766,7 +2766,7 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
} }
static void static void
channel_close_on_error(channel_T *channel, int part, char *func) channel_close_on_error(channel_T *channel, char *func)
{ {
/* Do not call emsg(), most likely the other end just exited. */ /* Do not call emsg(), most likely the other end just exited. */
ch_errors(channel, "%s(): Cannot read from channel", func); ch_errors(channel, "%s(): Cannot read from channel", func);
@@ -2780,10 +2780,9 @@ channel_close_on_error(channel_T *channel, int part, char *func)
* -> ui_breakcheck * -> ui_breakcheck
* -> gui event loop or select loop * -> gui event loop or select loop
* -> channel_read() * -> channel_read()
* Don't send "DETACH" for a JS or JSON channel. * Only send "DETACH" for a netbeans channel.
*/ */
if (channel->ch_part[part].ch_mode == MODE_RAW if (channel->ch_nb_close_cb != NULL)
|| channel->ch_part[part].ch_mode == MODE_NL)
channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW, channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW,
(int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT "); (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
@@ -2847,7 +2846,7 @@ channel_read(channel_T *channel, int part, char *func)
/* Reading a disconnection (readlen == 0), or an error. */ /* Reading a disconnection (readlen == 0), or an error. */
if (readlen <= 0) if (readlen <= 0)
channel_close_on_error(channel, part, func); channel_close_on_error(channel, func);
#if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK) #if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK)
/* signal the main loop that there is something to read */ /* signal the main loop that there is something to read */
@@ -3119,8 +3118,7 @@ channel_handle_events(void)
if (r == CW_READY) if (r == CW_READY)
channel_read(channel, part, "channel_handle_events"); channel_read(channel, part, "channel_handle_events");
else if (r == CW_ERROR) else if (r == CW_ERROR)
channel_close_on_error(channel, part, channel_close_on_error(channel, "channel_handle_events()");
"channel_handle_events()");
} }
} }
} }

View File

@@ -1056,13 +1056,10 @@ func Test_out_close_cb()
let s:counter = 1 let s:counter = 1
let s:msg1 = '' let s:msg1 = ''
let s:msg2 = ''
let s:closemsg = 0 let s:closemsg = 0
func! OutHandler(chan, msg) func! OutHandler(chan, msg)
if s:counter == 1 if s:counter == 1
let s:msg1 = a:msg let s:msg1 = a:msg
else
let s:msg2 = a:msg
endif endif
let s:counter += 1 let s:counter += 1
endfunc endfunc
@@ -1075,10 +1072,9 @@ func Test_out_close_cb()
\ 'close_cb': 'CloseHandler'}) \ 'close_cb': 'CloseHandler'})
call assert_equal("run", job_status(job)) call assert_equal("run", job_status(job))
try try
call s:waitFor('s:closemsg != 0 && s:msg2 != ""') call s:waitFor('s:closemsg != 0 && s:msg1 != ""')
call assert_equal('quit', s:msg1) call assert_equal('quit', s:msg1)
call assert_equal('DETACH', s:msg2) call assert_equal(2, s:closemsg)
call assert_equal(3, s:closemsg)
finally finally
call job_stop(job) call job_stop(job)
delfunc OutHandler delfunc OutHandler

View File

@@ -753,6 +753,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 */
/**/
1810,
/**/ /**/
1809, 1809,
/**/ /**/