draivin / hsnips

HyperSnips: a powerful snippet engine for VS Code, inspired by vim's UltiSnips
MIT License
148 stars 23 forks source link

Snippets lag depending on position. #187

Closed Alex2134556 closed 5 months ago

Alex2134556 commented 5 months ago

I am unsure why but the snippets lag a lot depending on the position of the document I invoke them.

For example, if I invoke the snippet at the end of the document then it is instantaneous but if I invoke the snippet in the middle then depending on how large the document is, it can take upto a second or two:

https://github.com/draivin/hsnips/assets/95665546/96bd7f99-f848-45b8-9223-e25db42fb266

https://github.com/draivin/hsnips/assets/95665546/70c61e8f-b085-4368-b890-22d1e09795ba

The snippets used are

function text(context) {
            return context.scopes.some(s => s.includes("text")) && !context.scopes.some(s => s.includes("environment.math"));
        }

function math(context) {
            return context.scopes.some(s => s.includes("math")) && !context.scopes.some(s => s.includes("text.normal")) && !context.scopes.some(s => s.includes("definition.label"));
        }

priority 2000000
context math(context) 
snippet norm "norm" iA
\lVert $1 \rVert_{$2}$0
endsnippet 

context !math(context) && text(context)
snippet dm "\[ \]" A
\[ $0 
\] 
endsnippet