Clarify arguments with _catch_exception

The whole int/string conversion with `vim.eval` is confusing enough, use
a boolean for `is_eval`.
This commit is contained in:
Daniel Hahler
2016-04-06 17:22:47 +02:00
parent 0d613b5cf9
commit 0f7b743b4e

View File

@@ -62,19 +62,19 @@ def _catch_exception(string, is_eval):
Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`.
"""
e = 'jedi#_vim_exceptions(%s, %s)'
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format(
repr(PythonToVimStr(string, 'UTF-8')), int(is_eval)))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
def vim_command(string):
_catch_exception(string, 0)
_catch_exception(string, False)
def vim_eval(string):
return _catch_exception(string, 1)
return _catch_exception(string, True)
def no_jedi_warning(error=None):