Saving visual selection gets stuck when selecting big texts

Bug #1178643 reported by LpZ_squall
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
UltiSnips
Confirmed
High
Unassigned

Bug Description

First of all, I'd like to say a big THANKS for this plugin that I discovered yesterday. It's really easy to use, documentation is precise and quite exhaustive, and the plugin itself is very powerful. Great job !

Well, my problem is that when selecting a quite big amount of text and pressing <tab> to reuse it in a snippet, vim gets stuck in the UltiSnips_SaveLastVisualSelection() function for a while. I don't exactly know what the _visual_content.conserve() function is doing, but an optimization would be welcomed :-).

My use-case is the following very simple C snippet, wrapping the selected text into a vim fold:

  snippet fold "Add a new vim fold" !b
  /*{{{ ${1:topic} */

  ${0:${VISUAL}}

  /*}}} */
  endsnippet

When working on a big C file (> 5k lines) without folds, and that I want to add some with this snippet... well I just can't :-D.

Revision history for this message
SirVer (sirver) wrote :

Well, this is not related to visual, it is related to big edits inside a snippet. The problem is here:

https://github.com/SirVer/ultisnips/blob/master/plugin/UltiSnips/__init__.py#L686

The issue is that Vim is not reporting what changed in a buffer when the cursor moved. But UltiSnips needs this information to update its text objects. So it first tries a bunch of heuristics to figure this out - e.g. if the cursor is on the next line, but further to the left it is likely that the user inserted a newline. But if those heuristic fail, we need to do a full diff of the snippet area before and after - unfortunately this is a very costly operation and very slow as well (both the implementation and python). This is the notable freeze you see.

Unfortunately I have no idea how to improve the situation - if you have any suggestions, shoot.

Changed in ultisnips:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
LpZ_squall (lpz-squall) wrote :

OK, thank you for the explanation.

I'm a C developper and I don't know Python, so if you don't know how to improve the situation, then I probably won't be able to do anything, but I'll may have a look one day...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.