jedi: refactor completions

This fixes jedi completions backtrace in the scenario where
CASE_SENSITIVE_COMPLETIONS is set.
This commit is contained in:
Sean Farley 2019-10-02 15:01:05 -05:00
parent 67b97b9571
commit 22a078377d

View file

@ -30,14 +30,17 @@ def complete_jedi(prefix, line, start, end, ctx):
return set()
src = builtins.__xonsh__.shell.shell.accumulated_inputs + line
script = jedi.api.Interpreter(src, [ctx], column=end)
script_comp = set()
try:
script_comp = script.completions()
except Exception:
pass
if builtins.__xonsh__.env.get('CASE_SENSITIVE_COMPLETIONS'):
rtn = {x.name_with_symbols for x in script.completions()
if x.name_with_symbols.startswith(prefix)}
rtn = {x.name_with_symbols for x in script_comp
if x.name_with_symbols.startswith(prefix)}
else:
try:
rtn = {x.name_with_symbols for x in script.completions()}
except Exception:
rtn = set()
rtn = {x.name_with_symbols for x in script_comp}
return rtn