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

Autocompletion cuts off last character for parameter replacement. #336

Open
mckinnsb opened this issue Mar 6, 2018 · 8 comments
Open

Autocompletion cuts off last character for parameter replacement. #336

mckinnsb opened this issue Mar 6, 2018 · 8 comments

Comments

@mckinnsb
Copy link

mckinnsb commented Mar 6, 2018

Here's a screencast of what is happening, as it's a little hard to describe:

https://streamable.com/s/jdt9u/llbvcw.gif

I'm using the default omnisharp server, omnisharp-vim, Supertab, and ultisnips.

Basically, when I do parameter completion, it cuts the last character off the parameter and I have to manually delete it every time.

@DasOhmoff
Copy link

Did you find a solution?

@DasOhmoff
Copy link

Did you try to select a suggestion and pressing escape instead of pressing tab or enter or any other key?

@mckinnsb
Copy link
Author

mckinnsb commented Dec 5, 2019 via email

@DasOhmoff
Copy link

Ah, I see.

@nickspoons
Copy link
Member

Hey guys, I did manage to recreate this once, but never found the error (I don't usually use snippets myself). I can try to give it another look - I've always meant to dig into it but never found the time, sorry.

@nickspoons
Copy link
Member

nickspoons commented Dec 6, 2019

Well, I'm really stuck on this. I'm inclined to think it might be a bug in the Vim python package? For some reason that I just can't work out, it is UltiSnips/vim_helper.py#L184 that causes an extra space (or spaces) to be inserted at the start of the argument list:

    buf.cursor = start

That cursor setter contains the real culprit:

        vim.current.window.cursor = pos.line + 1, nbyte

This is the line that is inserting a space, but why? Commenting out line 184 results in correct snippet insertion - but the semi-colon at the end now has whitespace in front it it (possibly from other calls to vim.current.window.cursor?).

The other thing is that all of this only appears to occur when using the UltiSnips trigger, g:UltiSnipsExpandTrigger. Selecting a completion using Vim's native <C-y> seems to work perfectly well - the snippets are inserted as expected.

However attempting to map something else to <C-y> results in the same issue:

inoremap <Tab> <C-y>

This is what makes me think this is a Vim bug - <C-y> works as expected, but spaces are inserted when using it from a mapping.

I'll try to put together a minimal example and raise it as a Vim issue. In the meantime, I recommend using <C-y> as a workaround.

@nosami
Copy link
Contributor

nosami commented Dec 6, 2019

Pretty sure this feature only worked for a small amount of time and was hardly tested.

I somehow managed to talk @markwoodhall into implementing it after I'd already defected to Emacs. He shortly defected to Clojure I believe, leaving nobody actually using this feature :)

@nickspoons
Copy link
Member

@nosami it's actually a great feature and for the most part works really well (except for this annoying issue). I did use it for a while.

The reason I stopped using it was the same reason I always stop using things like autopairs or delimitmate - I find automatically inserted code gets in my way more than it helps. But that's a personal style preference and not a reflection on the feature.

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

4 participants