ultisnips crashes on utf-8 encoding

Bug #1268896 reported by Vaibhav Sagar on 2014-01-14
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UltiSnips
Invalid
Undecided
Unassigned

Bug Description

Hi,

Ultisnips throws a UnicodeDecodeError for me when I try it with encoding=utf-8. I have tried this with the 'box' snippet in all.snippets and the 'def' snippet in python.snippets. For example:

box<Tab>

gives me the expanded snippet but also the error:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\__init__.py", line 65, in wrapper
    return f(self, *args, **kwds)
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\__init__.py", line 588, in expand
    if not self._try_expand():
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\__init__.py", line 979, in _try_expand
    self._do_snippet(snippet, before, after)
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\__init__.py", line 961, in _do_snippet
    self._jump()
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\__init__.py", line 824, in _jump
    _vim.select(self._ctab.start, self._ctab.end)
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\_vim.py", line 129, in select
    _unmap_select_mode_mapping()
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\_vim.py", line 218, in _unmap_select_mode_mapping
    all_maps = list(filter(len, eval(r"_tmp_smaps").splitlines()))
  File "C:\Users\Vaibhav\vimfiles\bundle\ultisnips\plugin\UltiSnips\_vim.py", line 107, in eval
    rv = vim.eval(as_vimencoding(s))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 660: invalid start byte

My python version is:
3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)]

If I try setting encoding=ansi then the snippet expands without any error. I think this may be related to vim-airline which I also use.

Thanks!

description: updated
description: updated
SirVer (sirver) wrote :

The problem arises when ultisnips tries to unmap select mode mappings for printable characters. If vim-airline (or you in you .vimrc) is mapping something using :vmap you should probably open a bug report with them telling them to NEVER use :vmap, but always :xmap (see help mapmode-x):

NOTE: Mapping a printable character in Select mode may confuse the user. It's
better to explicitly use :xmap and :smap for printable characters. Or use
:sunmap after defining the mapping.

You can work around your problem, see UltiSnips-warning-smappings.

I can see that this is still a bug in UltiSnips/Vim - somehow the mapped characters are not really printable/decodable the way we get them from Vim - I guess you are using a non ASCII mapping someplace. However, I have no idea how to fix this - I think the problem is that Vim is not reporting the mappings correctly while listing them. Let me know if the work around works for you.

Changed in ultisnips:
status: New → Incomplete
Vaibhav Sagar (vaibhavsagar) wrote :

Thanks for getting back to me so quickly! This didn't work:

let g:UltiSnipsRemoveSelectModeMappings = 1
let g:UltiSnipsMappingsToIgnore = [ "airline"]

but this did:

let g:UltiSnipsRemoveSelectModeMappings = 0

Thanks for your help!

SirVer (sirver) wrote :

Great. I am setting this to invalid since I would not know how to fix ...

Changed in ultisnips:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers