hsnips
hsnips copied to clipboard
Strange behavior in big file
If you write a snippet like
snippet `(\\?)(B[A-Z])` "test" A
\``rv=m[2]``
endsnippet
And in a $ ... $ pair, put your cursor close to the second $, and typing ""+"B"+"Z"+“Space” fast, you will possibly get:
$ ... \BZ\BZ $
With your cursor between two \BZ.
This strange behavior usually don't occur in small files. But when there are many lines of words after your $ ... $, it will.
According to my test,
- 250 lines and 28000 words after the $ ... $ is enough to make this strange behavior occur.
- 1000 lines and 120000 words after the $ ... $, make the snippet very lag. It takes about 1 seconds to trigger and complete a snippet.
- Even with no other snippets, and no something like "context math(context)", this behavior still occurs.
- But if not in $ ... $, or the cursor is in $ ... $ but not close to the second $, then there is no lag and no strange behavior.
I guess that, the cursor close to the second $, somehow makes the engine unknown that the line is over. Then the engine scans all the texts after the cursor, which leads to lag. And it's not surprising that lag will make a double \BZ.
It could be related to a performance issue happening, as you mentioned you needed to type it fast. Your computer might be powerful enough that you can write fast in small files, and it won't trigger the error. However, when the file gets large, and the resources are more intensely used, writing fast breaks code evaluation.
See: #8