Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MacVim/gui_macvim.m
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
static CFAbsoluteTime lastTime = 0;

CFAbsoluteTime nowTime = CFAbsoluteTimeGetCurrent();
if (nowTime - lastTime > 0.2) {
if (nowTime - lastTime > 1.0 / 30) {
[[MMBackend sharedInstance] update];
lastTime = nowTime;
}
Expand Down Expand Up @@ -2301,7 +2301,7 @@ static int vimModMaskToEventModifierFlags(int mods)
0,
dispatch_get_main_queue());
dispatch_source_set_event_handler(s, ^{
channel_read(channel, part, "gui_macvim_add_channel");
channel_may_read(channel, part, "gui_macvim_add_channel");
});
dispatch_resume(s);
return s;
Expand Down
22 changes: 16 additions & 6 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
# define fd_close(sd) close(sd)
#endif

#ifndef FEAT_GUI_MACVIM
static void channel_read(channel_T *channel, ch_part_T part, char *func);
#endif

/* Whether a redraw is needed for appending a line to a buffer. */
static int channel_need_redraw = FALSE;
Expand Down Expand Up @@ -3271,11 +3269,7 @@ channel_close_now(channel_T *channel)
* "part" is PART_SOCK, PART_OUT or PART_ERR.
* The data is put in the read queue. No callbacks are invoked here.
*/
#ifndef FEAT_GUI_MACVIM
static void
#else
void
#endif
channel_read(channel_T *channel, ch_part_T part, char *func)
{
static char_u *buf = NULL;
Expand Down Expand Up @@ -3561,6 +3555,22 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw)
free_job_options(&opt);
}

# ifdef FEAT_GUI_MACVIM
/*
* Read from channel "channel" in dispatch event handler.
* Channel may be already read out elsewhere before the handler invoked
* after an event arrived, so should be checked again.
*/
void
channel_may_read(channel_T *channel, ch_part_T part, char *func)
{
sock_T fd = channel->ch_part[part].ch_fd;

if (fd != INVALID_FD && channel_wait(channel, fd, 0) == CW_READY)
channel_read(channel, part, func);
}
# endif

# if defined(WIN32) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \
|| defined(PROTO)
/*
Expand Down
4 changes: 1 addition & 3 deletions src/proto/channel.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void channel_clear(channel_T *channel);
void channel_free_all(void);
char_u *channel_read_block(channel_T *channel, ch_part_T part, int timeout);
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
void channel_may_read(channel_T *channel, ch_part_T part, char *func);
channel_T *channel_fd2channel(sock_T fd, ch_part_T *partp);
void channel_handle_events(int only_keep_open);
int channel_any_keep_open(void);
Expand Down Expand Up @@ -71,7 +72,4 @@ job_T *job_start(typval_T *argvars, jobopt_T *opt_arg);
char *job_status(job_T *job);
void job_info(job_T *job, dict_T *dict);
int job_stop(job_T *job, typval_T *argvars, char *type);
#ifdef FEAT_GUI_MACVIM
void channel_read(channel_T *channel, ch_part_T part, char *func);
#endif
/* vim: set ft=c : */