|
54 | 54 | # define fd_close(sd) close(sd) |
55 | 55 | #endif |
56 | 56 |
|
57 | | -#ifndef FEAT_GUI_MACVIM |
58 | 57 | static void channel_read(channel_T *channel, ch_part_T part, char *func); |
59 | | -#endif |
60 | 58 |
|
61 | 59 | /* Whether a redraw is needed for appending a line to a buffer. */ |
62 | 60 | static int channel_need_redraw = FALSE; |
@@ -3271,11 +3269,7 @@ channel_close_now(channel_T *channel) |
3271 | 3269 | * "part" is PART_SOCK, PART_OUT or PART_ERR. |
3272 | 3270 | * The data is put in the read queue. No callbacks are invoked here. |
3273 | 3271 | */ |
3274 | | -#ifndef FEAT_GUI_MACVIM |
3275 | 3272 | static void |
3276 | | -#else |
3277 | | - void |
3278 | | -#endif |
3279 | 3273 | channel_read(channel_T *channel, ch_part_T part, char *func) |
3280 | 3274 | { |
3281 | 3275 | static char_u *buf = NULL; |
@@ -3561,6 +3555,22 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw) |
3561 | 3555 | free_job_options(&opt); |
3562 | 3556 | } |
3563 | 3557 |
|
| 3558 | +# ifdef FEAT_GUI_MACVIM |
| 3559 | +/* |
| 3560 | + * Read from channel "channel" in dispatch event handler. |
| 3561 | + * Channel may be already read out elsewhere before the handler invoked |
| 3562 | + * after an event arrived, so should be checked again. |
| 3563 | + */ |
| 3564 | + void |
| 3565 | +channel_may_read(channel_T *channel, ch_part_T part, char *func) |
| 3566 | +{ |
| 3567 | + sock_T fd = channel->ch_part[part].ch_fd; |
| 3568 | + |
| 3569 | + if (fd != INVALID_FD && channel_wait(channel, fd, 0) == CW_READY) |
| 3570 | + channel_read(channel, part, func); |
| 3571 | +} |
| 3572 | +# endif |
| 3573 | + |
3564 | 3574 | # if defined(WIN32) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ |
3565 | 3575 | || defined(PROTO) |
3566 | 3576 | /* |
|
0 commit comments