Saving visual selection gets stuck when selecting big texts
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_
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.
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.