Syntax error in code breaks vim

Bug #1255188 reported by Vsevolod Velichko on 2013-11-26
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UltiSnips
Invalid
Undecided
Unassigned

Bug Description

Sometimes when I edit python code and press Esc having invalid syntax (e.g. I've written 'if someCondition:' and pressed esc — next line doesn't have an appropriate indent), ultisnips error window apprears:

Following is the full stack trace:
Traceback (most recent call last):
  File "/home/torkve/vimtemp/my/.vim/bundle/ultisnips/plugin/UltiSnips/__init__.py", line 23, in wrapper
    return f(self, *args, **kwds)
  File "/home/torkve/vimtemp/my/.vim/bundle/ultisnips/plugin/UltiSnips/__init__.py", line 666, in cursor_moved
    if _vim.eval("mode()") not in 'in':
  File "/home/torkve/vimtemp/my/.vim/bundle/ultisnips/plugin/UltiSnips/_vim.py", line 107, in eval
    rv = vim.eval(as_vimencoding(s))
error: invalid expression

After that vim command line ignores all <cr> keystrokes (I can't type :w<cr> or even ZZ anymore) and my status line text turns into 'Pl#statusline', I have to C-z from vim and kill it.

Output of :py import sys; print sys.version:
  2.7.5+ (default, Sep 19 2013, 13:52:09)
  [GCC 4.8.1]

Unfortunately, there's no guaranteed way to reproduce the bug, sometimes it appears, sometimes not, so I can't give a strict way to reproduce it nor detect if any of my plugins affects the ultisnips behaviour.

Plugins I have:
  Shougo/neobundle.vim
  Shougo/vimproc
  Shougo/unite.vim
  Shougo/unite-outline
  tsukkee/unite-help
  ujihisa/unite-colorscheme
  ujihisa/unite-locate
  thinca/vim-unite-history
  osyo-manga/unite-filetype
  osyo-manga/unite-quickfix
  osyo-manga/unite-fold
  tacroe/unite-mark
  joedicastro/vim-powerline
  zhaocai/linepower.vim
  mattn/webapi-vim
  vim-scripts/hexman.vim
  kana/vim-smartinput
  Shougo/neocomplete.vim
  tpope/vim-commentary
  scrooloose/syntastic
  SirVer/ultisnips
  https://code.google.com/p/vim-plugin-viewdoc/
  klen/python-mode
  Yggdroot/indentLine
  alfredodeza/coveragepy.vim
  davidhalter/jedi-vim
  Rykka/colorv.vim
  mhinz/vim-signify
  mhinz/vim-startify
  Shougo/vimfiler
  tpope/vim-characterize
  tpope/vim-fugitive
  tpope/vim-git
  torkve/vim-vcscommand
  junkblocker/patchreview-vim
  joedicastro/vim-markdown
  joedicastro/vim-markdown-extra-preview
  tpope/vim-ragtag
  tyru/current-func-info.vim
  vim-scripts/errormarker.vim
  http://hg.dfrank.ru/vim/bundle/dfrank_util
  http://hg.dfrank.ru/vim/bundle/indexer_development
  http://hg.dfrank.ru/vim/bundle/vimprj
  doxygen-toolkit
  Lokaltog/vim-distinguished
  terryma/vim-multiple-cursors

SirVer (sirver) wrote :

That is a weird error. According to the stack trace, the code vim.eval("mode()") crashes as an invalid expression. Or the reencoding does not work properly. I have two hunches what could be the root cause for this:

1) you are working in some non-latin based language and are hitting some corner case with the vim string encoding facilities. Could that be it?
2) some other plugin interferes with UltiSnips. Could you try to reproduce the error on a minimal install (i.e. only UltiSnips and no other plugins)?

Changed in ultisnips:
status: New → Incomplete
Vsevolod Velichko (torkvemada) wrote :

1. My system locale is Russian, but the cyrillic symbols have never appeared in the code. It could probably be a jedi-vim plugin that uses some non-ascii invisible symbols to make vim display function info in a line above the currently edited.
2. I can try but it's hard, since I still haven't an always-working way to reproduce the bug even with the full set of plugins.

SirVer (sirver) wrote :

1. it seems unlikely that characters in the buffer should disturb ultisnips - be them visible or not.
2. I understand.

I suggest trying the following: edit the as_vimencoding() method in ultisnips (which is defined twice, once for py3 and once for py2) to simply return the string. same for the as utf8 encoding. this will break other things, but if your trouble disappears we know that we have an encoding issue at hand.

Launchpad Janitor (janitor) wrote :

[Expired for UltiSnips because there has been no activity for 60 days.]

Changed in ultisnips:
status: Incomplete → Expired
SirVer (sirver) wrote :

ping?

Changed in ultisnips:
status: Expired → Incomplete
Vsevolod Velichko (torkvemada) wrote :

Oh, I completely forget to respond here, sorry.
I tested your recommendation (about as_vimencoding) for that couple of months and it really fixed the things.

SirVer (sirver) wrote :

great - though this is not a really great fix. I wish I would know a more principled way of fixing this. If you come up with a super stable way of reproducing it, I am all ears. Then I can try to fix it properly.

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