mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:20:04 +08:00
fix(timers): fix timers checking
This commit is contained in:
parent
26addd7078
commit
8762d5c9a1
@ -44,16 +44,6 @@ function! s:close_flygrep_win() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if has('timers')
|
|
||||||
function! s:timer_start(...) abort
|
|
||||||
return call('timer_start', a:000)
|
|
||||||
endfunction
|
|
||||||
function! s:timer_stop(...) abort
|
|
||||||
return call('timer_stop', a:000)
|
|
||||||
endfunction
|
|
||||||
else
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Init local options: {{{
|
" Init local options: {{{
|
||||||
let s:grep_expr = ''
|
let s:grep_expr = ''
|
||||||
let [
|
let [
|
||||||
@ -97,7 +87,7 @@ let s:complete_input_history_num = [0,0]
|
|||||||
" grep local funcs:{{{
|
" grep local funcs:{{{
|
||||||
" @vimlint(EVL103, 1, a:timer)
|
" @vimlint(EVL103, 1, a:timer)
|
||||||
let s:current_grep_pattern = ''
|
let s:current_grep_pattern = ''
|
||||||
function! s:grep_timer(timer) abort
|
function! s:grep_timer(...) abort
|
||||||
if s:grep_mode ==# 'expr'
|
if s:grep_mode ==# 'expr'
|
||||||
let s:current_grep_pattern = join(split(s:grep_expr), '.*')
|
let s:current_grep_pattern = join(split(s:grep_expr), '.*')
|
||||||
else
|
else
|
||||||
@ -213,8 +203,12 @@ function! s:flygrep(expr) abort
|
|||||||
hi def link FlyGrepPattern MoreMsg
|
hi def link FlyGrepPattern MoreMsg
|
||||||
let s:hi_id = s:matchadd('FlyGrepPattern', s:expr_to_pattern(a:expr), 2)
|
let s:hi_id = s:matchadd('FlyGrepPattern', s:expr_to_pattern(a:expr), 2)
|
||||||
let s:grep_expr = a:expr
|
let s:grep_expr = a:expr
|
||||||
call s:timer_stop(s:grep_timer_id)
|
if has('timers')
|
||||||
let s:grep_timer_id = s:timer_start(200, function('s:grep_timer'), {'repeat' : 1})
|
call timer_stop(s:grep_timer_id)
|
||||||
|
let s:grep_timer_id = timer_start(200, function('s:grep_timer'), {'repeat' : 1})
|
||||||
|
else
|
||||||
|
call s:grep_timer()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
@ -254,11 +248,15 @@ function! s:filter(expr) abort
|
|||||||
hi def link FlyGrepPattern MoreMsg
|
hi def link FlyGrepPattern MoreMsg
|
||||||
let s:hi_id = s:matchadd('FlyGrepPattern', s:expr_to_pattern(a:expr), 2)
|
let s:hi_id = s:matchadd('FlyGrepPattern', s:expr_to_pattern(a:expr), 2)
|
||||||
let s:grep_expr = a:expr
|
let s:grep_expr = a:expr
|
||||||
let s:grep_timer_id = s:timer_start(200, function('s:filter_timer'), {'repeat' : 1})
|
if has('timers')
|
||||||
|
let s:grep_timer_id = timer_start(200, function('s:filter_timer'), {'repeat' : 1})
|
||||||
|
else
|
||||||
|
call s:filter_timer()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" @vimlint(EVL103, 1, a:timer)
|
" @vimlint(EVL103, 1, a:timer)
|
||||||
function! s:filter_timer(timer) abort
|
function! s:filter_timer(...) abort
|
||||||
let cmd = s:get_filter_cmd(join(split(s:grep_expr), '.*'))
|
let cmd = s:get_filter_cmd(join(split(s:grep_expr), '.*'))
|
||||||
let s:grepid = s:JOB.start(cmd, {
|
let s:grepid = s:JOB.start(cmd, {
|
||||||
\ 'on_stdout' : function('s:grep_stdout'),
|
\ 'on_stdout' : function('s:grep_stdout'),
|
||||||
@ -353,8 +351,10 @@ function! s:close_buffer() abort
|
|||||||
if s:grepid > 0
|
if s:grepid > 0
|
||||||
call s:JOB.stop(s:grepid)
|
call s:JOB.stop(s:grepid)
|
||||||
endif
|
endif
|
||||||
call s:timer_stop(s:grep_timer_id)
|
if has('timers')
|
||||||
call s:timer_stop(s:preview_timer_id)
|
call timer_stop(s:grep_timer_id)
|
||||||
|
call timer_stop(s:preview_timer_id)
|
||||||
|
endif
|
||||||
if s:preview_able == 1
|
if s:preview_able == 1
|
||||||
for id in s:previewd_bufnrs
|
for id in s:previewd_bufnrs
|
||||||
try
|
try
|
||||||
@ -380,8 +380,10 @@ function! s:close_grep_job() abort
|
|||||||
endtry
|
endtry
|
||||||
let s:std_line = 0
|
let s:std_line = 0
|
||||||
endif
|
endif
|
||||||
call s:timer_stop(s:grep_timer_id)
|
if has('timers')
|
||||||
call s:timer_stop(s:preview_timer_id)
|
call timer_stop(s:grep_timer_id)
|
||||||
|
call timer_stop(s:preview_timer_id)
|
||||||
|
endif
|
||||||
noautocmd normal! gg"_dG
|
noautocmd normal! gg"_dG
|
||||||
call s:update_statusline()
|
call s:update_statusline()
|
||||||
let s:complete_input_history_num = [0,0]
|
let s:complete_input_history_num = [0,0]
|
||||||
@ -714,7 +716,7 @@ if exists('*nvim_open_win') && exists('*nvim_win_set_buf')
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:preview_timer(timer) abort
|
function! s:preview_timer(...) abort
|
||||||
for id in filter(s:previewd_bufnrs, 'bufexists(v:val) && buflisted(v:val)')
|
for id in filter(s:previewd_bufnrs, 'bufexists(v:val) && buflisted(v:val)')
|
||||||
exe 'silent bd ' . id
|
exe 'silent bd ' . id
|
||||||
endfor
|
endfor
|
||||||
@ -738,10 +740,16 @@ endif
|
|||||||
" @vimlint(EVL103, 0, a:timer)
|
" @vimlint(EVL103, 0, a:timer)
|
||||||
|
|
||||||
|
|
||||||
function! s:preview() abort
|
if has('timers')
|
||||||
call s:timer_stop(s:preview_timer_id)
|
function! s:preview() abort
|
||||||
let s:preview_timer_id = s:timer_start(200, function('s:preview_timer'), {'repeat' : 1})
|
call timer_stop(s:preview_timer_id)
|
||||||
endfunction
|
let s:preview_timer_id = timer_start(200, function('s:preview_timer'), {'repeat' : 1})
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:preview() abort
|
||||||
|
call s:preview_timer()
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
let s:grep_mode = 'expr'
|
let s:grep_mode = 'expr'
|
||||||
function! s:toggle_expr_mode() abort
|
function! s:toggle_expr_mode() abort
|
||||||
|
Loading…
Reference in New Issue
Block a user