Closed DusanLesan closed 2 years ago
I wouldn't consider the then
statement as standard. It's an optional key word and really comes down to individual coding standards.
@chrisdp You may be right. Is it possible then to make this part dynamic and set it based on user preference?
@TwitchBronBron would know more about if it could or could not be set dynamically.
As for a setting we would have to think how because this falls more in the territory of a linter like BSLint.
Another possibility would be to override the snippet directory location in brightscript plugin settings.
Snippets are defined statically in the extension's package.json so I don't think we can dynamically set these.
However, if you'd like, we can add another differently-named snippet which includes the then
? The current trigger for an if statement without then
is if
. How about we add ift
which would include the then
?
Current: | Trigger word | Snippet |
---|---|---|
if |
if ${1:condition} $0 end if |
|
if-else |
if ${1:condition} $0 else end if |
Proposed additions: | Trigger word | Snippet |
---|---|---|
ift |
if ${1:condition} then $0 end if |
|
ift-else |
if ${1:condition} then $0 else end if |
I do not like that as much as setting my own path to my snippets.json in plugin settings. Could I maybe give higher permissions to snippet folder and stop if from updating without causing plugin update to crash or something
vscode requires that all extension-contributed snippets be defined in the package.json of the extension (here's the line in our project), and vscode does not allow us to reassign those paths at runtime.
You can add your own snippets in vscode directly without the need for any support from our extension.
@TwitchBronBron That is what I need. It is bad experience to have duplicates I do not want but that is the same as if you add ift/ift-else. Thank you for the help and information
You can hide unwanted snippets as well:
Awesome. All is great now
I have seen that in most places adding
then
keyword in everyif
andelse if
is a standard. Could you update your snippets in vscode-brightscript-language/snippets/brightscript.json to includethen
keyword? Furthermore, If Else snippet should have a third jumping point after else.Something like: