You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to remove surrounding brackets in a snippet, if I jump out of the insert node that is being surrounded by those brackets, without changing the inner text. A more concrete example: In LaTeX, many commands have optional arguments. If you provide any optional arguments, then you add them inside square braces. If you don't provide any, you omit the square braces. eg \mycommand[opts here]{required here} vs \mycommand{required here}.
What I want is as follows:
When the snippet expands the optional arguments section looks like [...]
After jumping in, if I type some text and jump out, then we get [text]
If after jumping in, I remove all text between the brackets, the brackets disappear. If I type some text before jumping out, the brackets come back.
If after jumping in I jump out without changing the placeholder... text, then the whole [...] bit should disappear.
What I've currently got is two functions nodes, one on either side of an insert node. If the text inside the insert node becomes empty, the function nodes return empty strings. Otherwise they return the bracket characters. In the insert node, I have a callback on the leave event, that sets the text of the node to an empty string, if the text hasn't been changed from the placeholder. This setup has got works for points 1, 2 and 3, but isn't working for point 4. When I jump out of the insert node without changing the default text, the insert node removes its own text, but the brackets don't disappear.
I feel like I'm missing something really obvious but I've been stuck on this for two days. Is it actually possible to do what I want to do? I know that choice nodes are a thing. But I prefer the ergonomics of just hitting tab twice instead of selecting a choice.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to figure out how to remove surrounding brackets in a snippet, if I jump out of the insert node that is being surrounded by those brackets, without changing the inner text. A more concrete example: In LaTeX, many commands have optional arguments. If you provide any optional arguments, then you add them inside square braces. If you don't provide any, you omit the square braces. eg
\mycommand[opts here]{required here} vs \mycommand{required here}.What I want is as follows:
[...][text][...]bit should disappear.What I've currently got is two functions nodes, one on either side of an insert node. If the text inside the insert node becomes empty, the function nodes return empty strings. Otherwise they return the bracket characters. In the insert node, I have a callback on the leave event, that sets the text of the node to an empty string, if the text hasn't been changed from the placeholder. This setup has got works for points 1, 2 and 3, but isn't working for point 4. When I jump out of the insert node without changing the default text, the insert node removes its own text, but the brackets don't disappear.
I feel like I'm missing something really obvious but I've been stuck on this for two days. Is it actually possible to do what I want to do? I know that choice nodes are a thing. But I prefer the ergonomics of just hitting tab twice instead of selecting a choice.
Full code in dotfiles
All reactions