mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
JS beautifier: fix loop construct, fixes #3510
As JavaScript is the only language supported by the beautifier, and [CodeCombat is in the process of converting things to while (true)](https://github.com/codecombat/codecombat/issues/3510#issuecomment-201965310), I guess adding this quick hack to the view's code should suffice for now. Hopefully, the non-standard `loop` construct will be removed from other languages before they receive beautifier support.
If this doesn't seem good, I can move this hack to `aether.beautify`, where it is possible to perform this substitution in a language-aware way (i.e. inside Aether's JavaScript implementation's [`beautify` method](418ccf2414/src/languages/javascript.coffee (L137)
)). Seeing as the `loop` construct is specific to CodeCombat, I'm not sure if that would be a good idea. Passing an options object with a flag to support the `loop` construct seems a bit overkill.
Let me know what works best for you.
This commit is contained in:
parent
539d0b01cc
commit
8326b5e182
1 changed files with 1 additions and 1 deletions
|
@ -1193,7 +1193,7 @@ module.exports = class SpellView extends CocoView
|
||||||
onSpellBeautify: (e) ->
|
onSpellBeautify: (e) ->
|
||||||
return unless @spellThang and (@ace.isFocused() or e.spell is @spell)
|
return unless @spellThang and (@ace.isFocused() or e.spell is @spell)
|
||||||
ugly = @getSource()
|
ugly = @getSource()
|
||||||
pretty = @spellThang.aether.beautify ugly
|
pretty = @spellThang.aether.beautify(ugly.replace /\bloop\b/g, 'while (__COCO_LOOP_CONSTRUCT__)').replace /while \(__COCO_LOOP_CONSTRUCT__\)/g, 'loop'
|
||||||
@ace.setValue pretty
|
@ace.setValue pretty
|
||||||
|
|
||||||
onMaximizeToggled: (e) ->
|
onMaximizeToggled: (e) ->
|
||||||
|
|
Loading…
Reference in a new issue