hsnips
hsnips copied to clipboard
Scope behavoir becomes random after a while
The snippet which is intended in the context of math can be triggered even when it is in the text mode after using it for a while.
The scope is defined as
global
function math(context) {
return context.scopes.some(s => s.startsWith("meta.math"));
}
endglobal
Here is an example of such unexpected behavior (note that the scope is always text.tex.latex
, yet the snippet is triggered automatically)
The snippet triggered here is (though it does not matter, every snippet can be triggered)
context math(context)
snippet `([\s])([A-Za-z])([\w]) ` "auto subscript" A
``rv=' '+m[2]+'_{'+m[3]+'} '``
endsnippet
It is difficult to reproduce this because once I restart vscode, everything becomes normal. But if I continue to use it for a while, this random behavior starts again.
Any comment for this or can I do something to show more debug info when this happens?
when you input "is", because there is $ before is and $ after is, so hsnip think you are in math mode. try to use\ ( and\) instead of $.
I don't think so @A6669 . Maybe hscopes recognize the environment by getting textmate scopes
. I met the same problem recently and I'm looking forward to the solution.
I don't think so @A6669 . Maybe hscopes recognize the environment by getting
textmate scopes
. I met the same problem recently and I'm looking forward to the solution.
you use \(\ ) or $?
Mostly $$
.
But you see , that problem emerges randomly. In most cases, it works normally.
And after I reload VSCode, the problem disappears in the same position.
Mostly
$$
. But you see , that problem emerges randomly. In most cases, it works normally. And after I reload VSCode, the problem disappears in the same position.
try https://github.com/OrangeX4/hsnips
It's a good idea but the principles are different. hscope
uses textmate scope
while hsnips for math
uses regex.
Anyway I hope that the reason can be found. 👀
I have the same exact behavior as described by @yfzhao20. Both in that, the bug is seemingly random (the same action, the same position will only sometimes work) and that the bug is only fixed by restarting vscode. The only difference is I use \(\) instead of $$ but clearly, this does not make a difference. I have had no other issues with the extension thus far so I hope this can be fixed as it is one of my favorite extensions.
I have the same exact behavior as described by @yfzhao20. Both in that, the bug is seemingly random (the same action, the same position will only sometimes work) and that the bug is only fixed by restarting vscode. The only difference is I use () instead of $$ but clearly, this does not make a difference. I have had no other issues with the extension thus far so I hope this can be fixed as it is one of my favorite extensions.
Maybe it is a bug in vscode.
@A6669 Using \(\)
doesn't work too. I used \(\)
for a long time, and I still ran into this problem. Everything is fine after restarting VSCode though.
Is there any progress on this issue? I keep encountering it even with other contexts such as fenced code blocks in quarto markdown, i.e.
global
function r_code(context) {
return context.scopes.some(s => s.startsWith("meta.embedded.block.r"));
}
endglobal
Sometimes snippet that are defined only in fenced blocks start expanding even in regular text, hence it seems to me that it is more general than simply math environments being broken..
This is really annoying, given that snippet expansion is a big part of my workflow.. If there are no workaround to this bug, I might consider returning to neovim and Ultisnips.
Should be greatly improved as of latest patch, if there are new issues please open a new issue or reopen this one.