Skip to content

Commit 715d285

Browse files
committed
patch 7.4.1810
Problem: Sending DETACH after a channel was closed isn't useful. Solution: Only add DETACH for a netbeans channel.
1 parent 868cfc1 commit 715d285

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/channel.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,7 @@ channel_free_all(void)
25952595
#endif
25962596

25972597

2598-
/* Sent when the channel is found closed when reading. */
2598+
/* Sent when the netbeans channel is found closed when reading. */
25992599
#define DETACH_MSG_RAW "DETACH\n"
26002600

26012601
/* Buffer size for reading incoming messages. */
@@ -2766,7 +2766,7 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
27662766
}
27672767

27682768
static void
2769-
channel_close_on_error(channel_T *channel, int part, char *func)
2769+
channel_close_on_error(channel_T *channel, char *func)
27702770
{
27712771
/* Do not call emsg(), most likely the other end just exited. */
27722772
ch_errors(channel, "%s(): Cannot read from channel", func);
@@ -2780,10 +2780,9 @@ channel_close_on_error(channel_T *channel, int part, char *func)
27802780
* -> ui_breakcheck
27812781
* -> gui event loop or select loop
27822782
* -> channel_read()
2783-
* Don't send "DETACH" for a JS or JSON channel.
2783+
* Only send "DETACH" for a netbeans channel.
27842784
*/
2785-
if (channel->ch_part[part].ch_mode == MODE_RAW
2786-
|| channel->ch_part[part].ch_mode == MODE_NL)
2785+
if (channel->ch_nb_close_cb != NULL)
27872786
channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW,
27882787
(int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
27892788

@@ -2847,7 +2846,7 @@ channel_read(channel_T *channel, int part, char *func)
28472846

28482847
/* Reading a disconnection (readlen == 0), or an error. */
28492848
if (readlen <= 0)
2850-
channel_close_on_error(channel, part, func);
2849+
channel_close_on_error(channel, func);
28512850

28522851
#if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK)
28532852
/* signal the main loop that there is something to read */
@@ -3119,8 +3118,7 @@ channel_handle_events(void)
31193118
if (r == CW_READY)
31203119
channel_read(channel, part, "channel_handle_events");
31213120
else if (r == CW_ERROR)
3122-
channel_close_on_error(channel, part,
3123-
"channel_handle_events()");
3121+
channel_close_on_error(channel, "channel_handle_events()");
31243122
}
31253123
}
31263124
}

src/testdir/test_channel.vim

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,13 +1056,10 @@ func Test_out_close_cb()
10561056

10571057
let s:counter = 1
10581058
let s:msg1 = ''
1059-
let s:msg2 = ''
10601059
let s:closemsg = 0
10611060
func! OutHandler(chan, msg)
10621061
if s:counter == 1
10631062
let s:msg1 = a:msg
1064-
else
1065-
let s:msg2 = a:msg
10661063
endif
10671064
let s:counter += 1
10681065
endfunc
@@ -1075,10 +1072,9 @@ func Test_out_close_cb()
10751072
\ 'close_cb': 'CloseHandler'})
10761073
call assert_equal("run", job_status(job))
10771074
try
1078-
call s:waitFor('s:closemsg != 0 && s:msg2 != ""')
1075+
call s:waitFor('s:closemsg != 0 && s:msg1 != ""')
10791076
call assert_equal('quit', s:msg1)
1080-
call assert_equal('DETACH', s:msg2)
1081-
call assert_equal(3, s:closemsg)
1077+
call assert_equal(2, s:closemsg)
10821078
finally
10831079
call job_stop(job)
10841080
delfunc OutHandler

src/version.c

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

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
1810,
756758
/**/
757759
1809,
758760
/**/

0 commit comments

Comments
 (0)