Adding the cursor identifier on InsertLeave
This should help catch cases where the user jumps to an identifier and then edits it in place; we want to add that new ident to the db ASAP because the user may want to have it completed soon. Still, we're not perfect. If the user just deletes chars with 'x' or 'd' in Vim and therefore never even enters insert mode we are obviously not going to pick up that identifier until the next full file sweep.
This commit is contained in:
parent
b20a24cde9
commit
06d653c60d
@ -140,11 +140,9 @@ endfunction
|
||||
|
||||
|
||||
function! s:OnInsertLeave()
|
||||
" TODO: Also, look at the current identifier under the cursor on InsertLeave
|
||||
" and add it to the identifier database; this should catch the cases where the
|
||||
" user slightly changes a variable name in-place
|
||||
let s:omnifunc_mode = 0
|
||||
call s:UpdateDiagnosticNotifications()
|
||||
py identcomp.AddIdentifierUnderCursor()
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -82,6 +82,20 @@ class IdentifierCompleter( Completer ):
|
||||
self.AddIdentifier( PreviousIdentifier() )
|
||||
|
||||
|
||||
def AddIdentifierUnderCursor( self ):
|
||||
cursor_identifier = vim.eval( 'expand("<cword>")' )
|
||||
if not cursor_identifier:
|
||||
return
|
||||
|
||||
stripped_cursor_identifier = ''.join( ( x for x in
|
||||
cursor_identifier if
|
||||
IsIdentifierChar( x ) ) )
|
||||
if not stripped_cursor_identifier:
|
||||
return
|
||||
|
||||
self.AddIdentifier( stripped_cursor_identifier )
|
||||
|
||||
|
||||
def AddBufferIdentifiers( self ):
|
||||
filetype = vim.eval( "&filetype" )
|
||||
filepath = vim.eval( "expand('%:p')" )
|
||||
|
Loading…
Reference in New Issue
Block a user