Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong cursor position with one-line snippets #203

Closed
UnkindPartition opened this issue Jun 17, 2015 · 8 comments
Closed

Wrong cursor position with one-line snippets #203

UnkindPartition opened this issue Jun 17, 2015 · 8 comments

Comments

@UnkindPartition
Copy link

One-line snippets such as

snippet lang
        {-# LANGUAGE ${1} #-}

no longer work on Fedora 22 (vim-enhanced-7.4.640-4.fc22.x86_64).

Namely, after expansion, the cursor stays on the initial comment, not at the end or at ${1}.

Multiline snippets seem to work fine.

@ajzafar
Copy link
Collaborator

ajzafar commented Jun 18, 2015

@feuerbach I can't reproduce this. Could you make sure you're up to date on SnipMate? Are you using the version 0 parser or the version 1 parser? Could you also share your vimrc, a list of other plugins you're using, and the output of :echo b:snip_state right after you've expanded the snippet? I'm not entirely sure why you're experiencing this, so hopefully more information will illuminate things.

@UnkindPartition
Copy link
Author

I am running the most recent master of snipmate. I was able to reproduce this with a pristine vim setup that has only snipmate and its dependencies installed. .vimrc only contains

execute pathogen#infect()

However, systemwide vim plugins may be active. These appear to be:

getscriptPlugin.vim
gzip.vim
matchparen.vim
netrwPlugin.vim
rrhelper.vim
spellfile.vim
tarPlugin.vim
tohtml.vim
vimballPlugin.vim
zipPlugin.vim

I tried disabling them by changing runtimepath, but then snipmate stops working at all.

So, I start vim, and in the empty buffer type date<Tab>. The date appears, and the cursor stays on the first column.

If I then execute

:echo b:snip_state

I get

E121: Undefined variable: b:snip_state
E15: Invalid expression: b:snip_state

@ajzafar
Copy link
Collaborator

ajzafar commented Jun 18, 2015

What is your Vim :version?

@UnkindPartition
Copy link
Author

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar  2 2015 08:37:50)
Included patches: 1-207, 209-640
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+acl             -clientserver    +cscope          +emacs_tags      +folding         +keymap          +menu            +mouse_netterm   +netbeans_intg   -python3         -sniff           -tcl             +virtualedit     +writebackup
+arabic          -clipboard       +cursorbind      +eval            -footer          +langmap         +mksession       +mouse_sgr       +path_extra      +quickfix        +startuptime     +terminfo        +visual          -X11
+autocmd         +cmdline_compl   +cursorshape     +ex_extra        +fork()          +libcall         +modify_fname    -mouse_sysmouse  +perl            +reltime         +statusline      +termresponse    +visualextra     -xfontset
-balloon_eval    +cmdline_hist    +dialog_con      +extra_search    +gettext         +linebreak       +mouse           +mouse_urxvt     +persistent_undo +rightleft       -sun_workshop    +textobjects     +viminfo         -xim
-browse          +cmdline_info    +diff            +farsi           -hangul_input    +lispindent      -mouseshape      +mouse_xterm     +postscript      +ruby/dyn        +syntax          +title           +vreplace        -xsmp
++builtin_terms  +comments        +digraphs        +file_in_path    +iconv           +listcmds        +mouse_dec       +multi_byte      +printer         +scrollbind      +tag_binary      -toolbar         +wildignore      -xterm_clipboard
+byte_offset     +conceal         -dnd             +find_in_path    +insert_expand   +localmap        +mouse_gpm       +multi_lang      +profile         +signs           +tag_old_static  +user_commands   +wildmenu        -xterm_save
+cindent         +cryptv          -ebcdic          +float           +jumplist        -lua             -mouse_jsbterm   -mzscheme        +python/dyn      +smartindent     -tag_any_white   +vertsplit       +windows         -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Werror=format-security -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags  -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new
-dtags  -fstack-protector -L/usr/local/lib  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

@ajzafar
Copy link
Collaborator

ajzafar commented Jun 19, 2015

Hmm I'm still unable to reproduce using Vim 7.4.640 and no configuration other than loading SnipMate. Do you get the undefined variable error when expanding a snippet with multiple tab stops? That variable doesn't exist for very long with snippets containing only the zero tab stop.

@UnkindPartition
Copy link
Author

No, with a multitab snippet I get

{'cur_stop': {'update_objects': [], 'col': 1, 'placeholder': 9, 'line': 1, 'mirrors': []}, 'stop_len': 9, 'remove': function('<SNR>38_state_remove'), 'start_col': 1, 'changed': 0, 'update_changes': function('<SNR>38_state_update_changes'),
 'stop_no': 1, 'old_mirrors': [], 'find_update_objects': function('<SNR>38_state_find_update_objects'), 'stop_count': 4, 'stops': {'0': {'col': 6, 'placeholder': 0, 'line': 2, 'mirrors': []}, '1': {...}, '2': {'col': 2, 'placeholder': 0, '
line': 2, 'mirrors': []}, '3': {...}}, 'update_mirrors': function('<SNR>38_state_update_mirrors'), 'jump_stop': function('<SNR>38_state_jump_stop'), 'prev_len': 18, 'end_col': 10, 'set_stop': function('<SNR>38_state_set_stop'), 'mirrors':
[...], 'remove_nested': function('<SNR>38_state_remove_nested'), 'select_word': function('<SNR>38_state_select_word'), 'find_next_stop': function('<SNR>38_state_find_next_stop'), 'update': function('<SNR>38_state_update')}

(This is after expanding the case snippet from vim-snippets/snippets/haskell.snippets.)

BTW, with that snippet, here's what I got:

snippet-bug

You can see how the cursor stayed at the beginning of the line and, because of that, the selection is wrong (but spans the right number of characters).

ajzafar added a commit that referenced this issue Jul 1, 2015
While the new version is a lot simpler, the old version should still
work. It doesn't in some places for some reason. See issue #203.
@ajzafar
Copy link
Collaborator

ajzafar commented Jul 1, 2015

With access to a Fedora machine, I was able to reproduce this and track down the problem. For whatever reason, the version of Vim that Fedora ships has problems with a regex used in the legacy parser. Tweaking it a bit, it should work everywhere now. Worth mentioning, the version 1 parser had no problems on Fedora.

Thank you for the report!

@ajzafar ajzafar closed this as completed Jul 1, 2015
@UnkindPartition
Copy link
Author

Thank you! This was driving me crazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants