Merge pull request #479 from blueyed/fix-cached-signature-call

Handle parenthesis with show_call_signatures' cache
This commit is contained in:
Dave Halter
2015-10-18 21:45:18 +02:00
2 changed files with 23 additions and 9 deletions

View File

@@ -376,15 +376,15 @@ function! jedi#show_call_signatures()
" Caching. On the same line only. " Caching. On the same line only.
if line == s:show_call_signatures_last[0] if line == s:show_call_signatures_last[0]
" Check if the number of commas before or after the cursor has " Check if the number of commas and parenthesis before or after the
" not changed: this means that the argument position was not " cursor has not changed since the last call, which means that the
" changed and we can skip repainting. " argument position was not changed and we can skip repainting.
let prevcol = s:show_call_signatures_last[1] let prevcol = s:show_call_signatures_last[1]
let prevline = s:show_call_signatures_last[2] let prevline = s:show_call_signatures_last[2]
if substitute(curline[:col-2], '[^,]', '', 'g') if substitute(curline[:col-2], '[^,()]', '', 'g')
\ == substitute(prevline[:prevcol-2], '[^,]', '', 'g') \ == substitute(prevline[:prevcol-2], '[^,()]', '', 'g')
\ && substitute(curline[(col-2):], '[^,]', '', 'g') \ && substitute(curline[(col-2):], '[^,()]', '', 'g')
\ == substitute(prevline[(prevcol-2):], '[^,]', '', 'g') \ == substitute(prevline[(prevcol-2):], '[^,()]', '', 'g')
let reload_signatures = 0 let reload_signatures = 0
endif endif
endif endif
@@ -396,6 +396,12 @@ function! jedi#show_call_signatures()
endfunction 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() function! jedi#configure_call_signatures()
augroup jedi_call_signatures augroup jedi_call_signatures
au! au!
@@ -403,7 +409,7 @@ function! jedi#configure_call_signatures()
autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col() autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col()
endif endif
autocmd InsertEnter <buffer> let s:show_call_signatures_last = [0, 0, ''] autocmd InsertEnter <buffer> let s:show_call_signatures_last = [0, 0, '']
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 if g:jedi#show_call_signatures_delay > 0
autocmd InsertEnter <buffer> let b:_jedi_orig_updatetime = &updatetime autocmd InsertEnter <buffer> let b:_jedi_orig_updatetime = &updatetime
\ | let &updatetime = g:jedi#show_call_signatures_delay \ | let &updatetime = g:jedi#show_call_signatures_delay

View File

@@ -17,10 +17,18 @@ describe 'signatures'
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`=' Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
doautocmd InsertLeave doautocmd InsertLeave
Expect getline(1) == '' Expect getline(1) == ''
end end
it 'simple after CursorHoldI with only parenthesis'
noautocmd normal o
doautocmd CursorHoldI
noautocmd normal iabs(
doautocmd CursorHoldI
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
end
it 'no signature' it 'no signature'
normal ostr normal ostr
Python jedi_vim.show_call_signatures() Python jedi_vim.show_call_signatures()