More cleanup for correctness and simplicity
The jedi completer now won't hang on <C-Space>
This commit is contained in:
parent
bdc93974af
commit
edbcb3abfe
@ -21,7 +21,7 @@
|
|||||||
import vim
|
import vim
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from completers.completer import Completer
|
from completers.completer import Completer
|
||||||
from vimsupport import CurrentLineAndColumn
|
import vimsupport
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from os.path import join, abspath, dirname
|
from os.path import join, abspath, dirname
|
||||||
@ -49,9 +49,7 @@ class JediCompleter( Completer ):
|
|||||||
super( JediCompleter, self ).__init__()
|
super( JediCompleter, self ).__init__()
|
||||||
self._query_ready = Event()
|
self._query_ready = Event()
|
||||||
self._candidates_ready = Event()
|
self._candidates_ready = Event()
|
||||||
self._query = None
|
|
||||||
self._candidates = None
|
self._candidates = None
|
||||||
self._exit = False
|
|
||||||
self._start_completion_thread()
|
self._start_completion_thread()
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +64,7 @@ class JediCompleter( Completer ):
|
|||||||
return [ 'python' ]
|
return [ 'python' ]
|
||||||
|
|
||||||
|
|
||||||
def CandidatesForQueryAsyncInner( self, query ):
|
def CandidatesForQueryAsyncInner( self, unused_query ):
|
||||||
self._query = query
|
|
||||||
self._candidates = None
|
self._candidates = None
|
||||||
self._candidates_ready.clear()
|
self._candidates_ready.clear()
|
||||||
self._query_ready.set()
|
self._query_ready.set()
|
||||||
@ -89,20 +86,12 @@ class JediCompleter( Completer ):
|
|||||||
while True:
|
while True:
|
||||||
WaitAndClear( self._query_ready )
|
WaitAndClear( self._query_ready )
|
||||||
|
|
||||||
if self._exit:
|
|
||||||
return
|
|
||||||
|
|
||||||
filename = vim.current.buffer.name
|
filename = vim.current.buffer.name
|
||||||
query = self._query
|
line, column = vimsupport.CurrentLineAndColumn()
|
||||||
line, column = CurrentLineAndColumn()
|
# Jedi expects lines to start at 1, not 0
|
||||||
lines = map( str, vim.current.buffer )
|
line += 1
|
||||||
if query is not None and lines[ line ]:
|
contents = '\n'.join( vim.current.buffer )
|
||||||
before, after = lines[ line ].rsplit( '.', 1 )
|
script = Script( contents, line, column, filename )
|
||||||
lines[ line ] = before + '.'
|
|
||||||
column = len( before ) + 1
|
|
||||||
|
|
||||||
source = '\n'.join( lines )
|
|
||||||
script = Script( source, line + 1, column, filename )
|
|
||||||
|
|
||||||
self._candidates = [ { 'word': str( completion.word ),
|
self._candidates = [ { 'word': str( completion.word ),
|
||||||
'menu': str( completion.description ),
|
'menu': str( completion.description ),
|
||||||
@ -113,7 +102,7 @@ class JediCompleter( Completer ):
|
|||||||
|
|
||||||
|
|
||||||
def WaitAndClear( event, timeout=None ):
|
def WaitAndClear( event, timeout=None ):
|
||||||
ret = event.wait( timeout )
|
flag_is_set = event.wait( timeout )
|
||||||
if ret:
|
if flag_is_set:
|
||||||
event.clear()
|
event.clear()
|
||||||
return ret
|
return flag_is_set
|
||||||
|
Loading…
Reference in New Issue
Block a user