Skip to content

Commit

Permalink
Merge pull request #39 from ardagnir/0.7.2
Browse files Browse the repository at this point in the history
Fix time bugs.
  • Loading branch information
ardagnir authored Oct 9, 2016
2 parents fc1e84b + 6155448 commit f59ff8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion athame.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ char athame_loop(int instream)
else {
while(selected == 0 && !athame_failure)
{
int timeout_msec = get_timeout_msec();
long timeout_msec = get_timeout_msec();
selected = athame_select(instream, vim_term, 0, timeout_msec, 0);
if (waitpid(vim_pid, NULL, WNOHANG) == 0) // Is vim still running?
{
Expand Down
8 changes: 4 additions & 4 deletions athame_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static char* servername;
static int vim_stage = VIM_NOT_STARTED;
static int sent_to_vim = 0;
// Measured in ms since epoch
static int time_to_poll = -1;
static long time_to_poll = -1;
// Number of stale polls since last keypress or change
static int stale_polls = 0;
static int change_since_key=0;
Expand Down Expand Up @@ -436,19 +436,19 @@ static void athame_update_vimline(int row, int col)
updated = 1;
}

static int get_timeout_msec() {
static long get_timeout_msec() {
if (time_to_poll == -1) {
return -1;
}
return MAX(30, time_to_poll - time(NULL) + 5);
return MAX(30, time_to_poll - get_time() + 5);
}


static void request_poll() {
if (stale_polls > 2) {
return;
}
int request_time = get_time() + (change_since_key || stale_polls > 0 ? 500 : 100);
long request_time = get_time() + (change_since_key || stale_polls > 0 ? 500 : 100);
time_to_poll = time_to_poll < 0 ? request_time : MIN(time_to_poll, request_time);
}

Expand Down

0 comments on commit f59ff8d

Please sign in to comment.