summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale.vim2
-rw-r--r--autoload/ale/engine.vim6
-rw-r--r--autoload/ale/events.vim14
-rw-r--r--autoload/ale/util.vim10
-rw-r--r--test/test_quitting_variable.vader8
5 files changed, 20 insertions, 20 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index f31446cb..859bb5b8 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -21,7 +21,7 @@ let s:timestamp_map = {}
" If the function throws an exception, then the function will not be called
" for a while, and 0 will be returned instead.
function! ale#CallWithCooldown(timestamp_key, func, arglist) abort
- let l:now = ale#util#ClockMilliseconds()
+ let l:now = ale#events#ClockMilliseconds()
if l:now < get(s:timestamp_map, a:timestamp_key, -1)
return 0
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 563c37a2..714c75b1 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -779,7 +779,7 @@ endfunction
" The time taken will be a very rough approximation, and more time may be
" permitted than is specified.
function! ale#engine#WaitForJobs(deadline) abort
- let l:start_time = ale#util#ClockMilliseconds()
+ let l:start_time = ale#events#ClockMilliseconds()
if l:start_time == 0
throw 'Failed to read milliseconds from the clock!'
@@ -810,7 +810,7 @@ function! ale#engine#WaitForJobs(deadline) abort
for l:job_id in l:job_list
if ale#job#IsRunning(l:job_id)
- let l:now = ale#util#ClockMilliseconds()
+ let l:now = ale#events#ClockMilliseconds()
if l:now - l:start_time > a:deadline
" Stop waiting after a timeout, so we don't wait forever.
@@ -847,7 +847,7 @@ function! ale#engine#WaitForJobs(deadline) abort
if l:has_new_jobs
" We have to wait more. Offset the timeout by the time taken so far.
- let l:now = ale#util#ClockMilliseconds()
+ let l:now = ale#events#ClockMilliseconds()
let l:new_deadline = a:deadline - (l:now - l:start_time)
if l:new_deadline <= 0
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim
index a12ca049..7cdc2e8e 100644
--- a/autoload/ale/events.vim
+++ b/autoload/ale/events.vim
@@ -1,15 +1,25 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: ALE functions for autocmd events.
+" Get the number of milliseconds since some vague, but consistent, point in
+" the past.
+"
+" This function can be used for timing execution, etc.
+"
+" The time will be returned as a Number.
+function! ale#events#ClockMilliseconds() abort
+ return float2nr(reltimefloat(reltime()) * 1000)
+endfunction
+
function! ale#events#QuitEvent(buffer) abort
" Remember when ALE is quitting for BufWrite, etc.
- call setbufvar(a:buffer, 'ale_quitting', ale#util#ClockMilliseconds())
+ call setbufvar(a:buffer, 'ale_quitting', ale#events#ClockMilliseconds())
endfunction
function! ale#events#QuitRecently(buffer) abort
let l:time = getbufvar(a:buffer, 'ale_quitting', 0)
- return l:time && ale#util#ClockMilliseconds() - l:time < 1000
+ return l:time && ale#events#ClockMilliseconds() - l:time < 1000
endfunction
function! ale#events#SaveEvent(buffer) abort
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 4e789b72..c01b6dd0 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -241,16 +241,6 @@ function! ale#util#InSandbox() abort
return 0
endfunction
-" Get the number of milliseconds since some vague, but consistent, point in
-" the past.
-"
-" This function can be used for timing execution, etc.
-"
-" The time will be returned as a Number.
-function! ale#util#ClockMilliseconds() abort
- return float2nr(reltimefloat(reltime()) * 1000)
-endfunction
-
" Given a single line, or a List of lines, and a single pattern, or a List
" of patterns, return all of the matches for the lines(s) from the given
" patterns, using matchlist().
diff --git a/test/test_quitting_variable.vader b/test/test_quitting_variable.vader
index bef344a8..38b43bb4 100644
--- a/test/test_quitting_variable.vader
+++ b/test/test_quitting_variable.vader
@@ -11,12 +11,12 @@ After:
unlet! b:time_before
Execute(QuitEvent should set b:ale_quitting some time from the clock):
- let b:time_before = ale#util#ClockMilliseconds()
+ let b:time_before = ale#events#ClockMilliseconds()
call ale#events#QuitEvent(bufnr(''))
Assert b:ale_quitting >= b:time_before
- Assert b:ale_quitting <= ale#util#ClockMilliseconds()
+ Assert b:ale_quitting <= ale#events#ClockMilliseconds()
Execute(EnterEvent should set b:ale_quitting to 0):
let b:ale_quitting = 1
@@ -29,11 +29,11 @@ Execute(The QuitRecently function should work when the variable isn't set):
AssertEqual 0, ale#events#QuitRecently(bufnr(''))
Execute(The QuitRecently function should return 1 when ALE quit recently):
- let b:ale_quitting = ale#util#ClockMilliseconds()
+ let b:ale_quitting = ale#events#ClockMilliseconds()
AssertEqual 1, ale#events#QuitRecently(bufnr(''))
Execute(The QuitRecently function should return 0 when a second has passed):
- let b:ale_quitting = ale#util#ClockMilliseconds() - 1001
+ let b:ale_quitting = ale#events#ClockMilliseconds() - 1001
AssertEqual 0, ale#events#QuitRecently(bufnr(''))