Skip to content

Commit 585cd35

Browse files
committed
fixup! fixup! Import smart_auto_mappings: use a timer if available
1 parent 664b7aa commit 585cd35

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

autoload/jedi.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,11 @@ endfunction
588588
function! jedi#smart_auto_mappings(...) abort
589589
" Auto put import statement after from module.name<space> and complete.
590590
if a:0
591+
" Callback from timer.
592+
let pos = getpos('.')
591593
if b:changedtick == s:import_timer[1] + 1
594+
\ && mode() ==# 'i'
595+
\ && s:import_timer[2][1:2] == [pos[1], pos[2]-1]
592596
" Enter characters and start completion.
593597
call feedkeys("import \<C-x>\<C-o>\<C-r>=jedi#complete_opened(1)\<CR>", 'nt')
594598
endif
@@ -601,7 +605,7 @@ function! jedi#smart_auto_mappings(...) abort
601605
endif
602606
let s:import_timer = [
603607
\ timer_start(g:jedi#smart_auto_mappings_delay, function('jedi#smart_auto_mappings')),
604-
\ b:changedtick]
608+
\ b:changedtick, getpos('.')]
605609
else
606610
" Enter characters and start completion.
607611
return "\<space>import \<C-x>\<C-o>\<C-r>=jedi#complete_opened(1)\<CR>"

0 commit comments

Comments
 (0)