Closed AgentRBY closed 1 year ago
Sorry, I missed the priority of this issue somehow, and I must admit otherLines
is one of the most not tested features of the extension (hope to fix it soon!).
the snippet doesn't work
Not sure why, it should work. I'll look into it tomorrow.
I'm also thinking of renaming displayIfNoLine
property to something else like acceptIfOutsideFile
Hey, @AgentRBY just realized via repository search that displayIfNoLine
was never implemented. I just pushed a lot of fixes & refactors to make otherLines
finally stable. Also remember that you can always use typing snippet with fileStart
location.
I also added skipEmptyLines
for your case:
{
"sequence": "import",
"body": "import { $0 } from '$1'",
"when": {
"locations": [
"lineStart"
],
"otherLines": [
{
"line": -1,
"displayIfNoLine": true,
"skipEmptyLines": true,
"testRegex": "^import(\\s)?({|\\w)$", // If prev line is `import {` or `import Word`
}
]
},
},
Hello 👋
I have this
import
typing snippet:I check to see if the previous line is an import or an empty line. This works fine if there is a string before it, but if there is no string, the snippet doesn't work, even with displayIfNoLine