Nested snippets requiring multiple `tab`s to proceed
I have the following two snippets defined (python):
# comprehension
[| for | in |]
# if inline
| if | else |
Running snippet comprehension snippet if inline gives
[| if | else | for | in |]
Saying tab makes the point move to the next hole, but it requires two tabs to leave the first snippet and enter the second hole of the second snippet.
air tab bat tab cap tab drum tab each results in
[a if b else cd for e in |]
air tab bat tab cap tab tab drum tab each results in
[a if b else c for d in e]
Snippet definitions:
{
"ifInlineStatement": {
"definitions": [
{
"scope": {
"langIds": [
"python"
]
},
"body": [
"$val1 if $condition else $val2"
]
}
],
"description": "Inline if statement",
"variables": {
"val1": {
"wrapperScopeType": "value"
}
},
"insertionScopeTypes": [
"statement"
]
}
}
{
"listComprehension": {
"definitions": [
{
"scope": {
"langIds": [
"python"
]
},
"body": [
"[$transformation for $var in $iterable]"
]
}
]
}
}
Not saying this is an ideal solution, but what happens if you replace $val2 with $0 in your inline if snippet?
Changing it to $0 makes it leave the snippet the first time you say tab as expected.
The VSCode behaviour here where it injects an implicit $0 even if you have a snippet hole at the end of the snippet seems undesirable. We should detect this situation and use $0 for the final snippet hole