mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 18:54:44 +08:00
Conditionally skip calls to jedi_vim.show_call_signatures
Skip calls to `jedi_vim.show_call_signatures` if the (position of the) current function's argument did not change (by means of comma positions before and after the cursor). Ref: https://github.com/davidhalter/jedi-vim/pull/420
This commit is contained in:
@@ -367,13 +367,47 @@ function! jedi#do_popup_on_dot_in_highlight()
|
||||
endfunc
|
||||
|
||||
|
||||
let s:show_call_signatures_last = [0, 0, '']
|
||||
function! jedi#show_call_signatures()
|
||||
let [line, col] = [line('.'), col('.')]
|
||||
let curline = getline(line)
|
||||
let reload_signatures = 1
|
||||
|
||||
" Caching. On the same line only.
|
||||
if line == s:show_call_signatures_last[0]
|
||||
" Check if the number of commas before or after the cursor has
|
||||
" not changed: this means that the argument position was not
|
||||
" changed and we can skip repainting.
|
||||
let prevcol = s:show_call_signatures_last[1]
|
||||
let prevline = s:show_call_signatures_last[2]
|
||||
if substitute(curline[:col-2], '[^,]', '', 'g')
|
||||
\ == substitute(prevline[:prevcol-2], '[^,]', '', 'g')
|
||||
\ && substitute(curline[(col-2):], '[^,]', '', 'g')
|
||||
\ == substitute(prevline[(prevcol-2):], '[^,]', '', 'g')
|
||||
let reload_signatures = 0
|
||||
endif
|
||||
endif
|
||||
let s:show_call_signatures_last = [line, col, curline]
|
||||
|
||||
if reload_signatures
|
||||
PythonJedi jedi_vim.show_call_signatures()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! jedi#clear_call_signatures()
|
||||
let s:show_call_signatures_last = [0, 0, '']
|
||||
PythonJedi jedi_vim.clear_call_signatures()
|
||||
endfunction
|
||||
|
||||
|
||||
function! jedi#configure_call_signatures()
|
||||
augroup jedi_call_signatures
|
||||
au!
|
||||
if g:jedi#show_call_signatures == 2 " Command line call signatures
|
||||
autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col()
|
||||
endif
|
||||
autocmd InsertLeave <buffer> PythonJedi jedi_vim.clear_call_signatures()
|
||||
autocmd InsertLeave <buffer> call jedi#clear_call_signatures()
|
||||
if g:jedi#show_call_signatures_delay > 0
|
||||
autocmd InsertEnter <buffer> let b:_jedi_orig_updatetime = &updatetime
|
||||
\ | let &updatetime = g:jedi#show_call_signatures_delay
|
||||
@@ -381,9 +415,9 @@ function! jedi#configure_call_signatures()
|
||||
\ | let &updatetime = b:_jedi_orig_updatetime
|
||||
\ | unlet b:_jedi_orig_updatetime
|
||||
\ | endif
|
||||
autocmd CursorHoldI <buffer> PythonJedi jedi_vim.show_call_signatures()
|
||||
autocmd CursorHoldI <buffer> call jedi#show_call_signatures()
|
||||
else
|
||||
autocmd CursorMovedI <buffer> PythonJedi jedi_vim.show_call_signatures()
|
||||
autocmd CursorMovedI <buffer> call jedi#show_call_signatures()
|
||||
endif
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user