SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.56k stars 691 forks source link

Does not expand automatic snippets when typing too fast #1484

Open JoachimFavre opened 2 years ago

JoachimFavre commented 2 years ago

When typing too fast, some snippets which should expand automatically do not.

Expected behavior: Have all automatic snippets expanded.

Actual behavior: Some snippets are not expanded.

Steps to reproduce

  1. Use the following snippet for .tex files:
    snippet ( "" iA
    \left( 
    endsnippet
  2. Keep the key "(" pressed.
  3. After some time, we start seeing things like "\left( (\left( ", whereas it should be "\left( \left( \left( ".

Note that you might need to have a rather long line before starting seeing the problem.

More information: I found that when the line I am writing is very small, this problem does not occur often, but the longer the line the more I see it. I have also noticed that the size of the document I am writing and the number of my snippets are other factors which make this problem worse. Also. strangely enough, it also depends on the file extension: the problem needs a much shorter line to appear in a .tex file than in a .txt one (maybe because of syntax colouring?).

All this makes me think that UltiSnips takes too much time to process a key press, and then, when it looks at what was typed since the last update, it skips (voluntarily or not) some key presses. I don't really care if what is on my screen is not exactly up to date with everything I type, as long as, in the end, all text is here and all my snippets are expanded correctly (especially for the ones which should be automatically expanded).

I think that a key buffer could solve my problem. It didn't feel so when I browsed on the internet and through the documentation, but could there be an option in UltiSnips which I am missing? I also think that, if this behaviour is expected (as a tradeoff for speed), I could maybe use a Vim plugin or an external application which would record all my keypresses in a buffer, and give them to UltiSnips or Vim with a minimum time between two key presses; would you have an idea of a tool which could do that (and do you think it could work)?

Note that this post mirrors a question I asked on the Vim StackExchange, following an advice from Vivian De Smedt.


tinkerfond commented 1 year ago

I have the same issue when using ultisnips for .tex files.

OS: Ubuntu 18.04 bionic Kernel: x86_64 Linux 4.15.0-206-generic Vim Version: NVIM v0.6.1 Python: 3.6.9