Fix neovim (again) - incompatible exception behabiour

Neovim does not raise:

* KeyError when accessing a vim dict
* KeyboardInterrupt when ctrl-c at a prompt

Instead it raises some internal subclass of vim.errro which cannot
easily be identified, so we just catch any vim.error.
This commit is contained in:
Ben Jackson 2020-08-24 18:31:47 +01:00
commit ef94b1bc49
2 changed files with 9 additions and 12 deletions

View file

@ -339,7 +339,7 @@ def SelectFromList( prompt, options ):
if selection < 0 or selection >= len( options ):
return None
return options[ selection ]
except KeyboardInterrupt:
except ( KeyboardInterrupt, vim.error ):
return None
@ -353,7 +353,7 @@ def AskForInput( prompt, default_value = None ):
try:
return vim.eval( "input( '{}' {} )".format( Escape( prompt ),
default_option ) )
except KeyboardInterrupt:
except ( KeyboardInterrupt, vim.error ):
return None
@ -732,7 +732,7 @@ def GetVimValue( vim_dict, name, default=None ):
# FIXME: use 'encoding' ?
try:
value = vim_dict[ name ]
except KeyError:
except ( KeyError, vim.error ):
return default
if isinstance( value, bytes ):
@ -743,7 +743,7 @@ def GetVimValue( vim_dict, name, default=None ):
def GetVimList( vim_dict, name, default=None ):
try:
value = vim_dict[ name ]
except KeyError:
except ( KeyError, vim.error ):
return default
if not isinstance( value, collections.abc.Iterable ):