mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Fixed Comment Out My Code for infinite loops for #1788
Fixed the issue for incorrect comments by correcting the syntax per language
This commit is contained in:
parent
031a32ce44
commit
929c89d2ac
2 changed files with 14 additions and 9 deletions
|
@ -783,17 +783,14 @@ module.exports = class SpellView extends CocoView
|
|||
if @_singleLineCommentRegex
|
||||
@_singleLineCommentRegex.lastIndex = 0
|
||||
return @_singleLineCommentRegex
|
||||
commentStarts =
|
||||
javascript: '//'
|
||||
python: '#'
|
||||
coffeescript: '#'
|
||||
clojure: ';'
|
||||
lua: '--'
|
||||
io: '//'
|
||||
commentStart = commentStarts[@spell.language] or '//'
|
||||
@_singleLineCommentRegex = new RegExp "[ \t]*#{commentStart}[^\"'\n]*", 'g'
|
||||
@_singleLineCommentRegex
|
||||
|
||||
|
||||
commentOutMyCode: ->
|
||||
prefix = if @spell.language is 'javascript' then 'return; ' else 'return '
|
||||
comment = prefix + commentStarts[@spell.language]
|
||||
|
||||
preload: ->
|
||||
# Send this code over to the God for preloading, but don't change the cast state.
|
||||
oldSource = @spell.source
|
||||
|
@ -1093,3 +1090,11 @@ module.exports = class SpellView extends CocoView
|
|||
@debugView?.destroy()
|
||||
$(window).off 'resize', @onWindowResize
|
||||
super()
|
||||
|
||||
commentStarts =
|
||||
javascript: '//'
|
||||
python: '#'
|
||||
coffeescript: '#'
|
||||
clojure: ';'
|
||||
lua: '--'
|
||||
io: '//'
|
||||
|
|
|
@ -80,7 +80,7 @@ module.exports = class TomeView extends CocoView
|
|||
onCommentMyCode: (e) ->
|
||||
for spellKey, spell of @spells when spell.canWrite()
|
||||
console.log 'Commenting out', spellKey
|
||||
commentedSource = 'return; // Commented out to stop infinite loop.\n' + spell.getSource()
|
||||
commentedSource = spell.view.commentOutMyCode() + 'Commented out to stop infinite loop.\n' + spell.getSource()
|
||||
spell.view.updateACEText commentedSource
|
||||
spell.view.recompile false
|
||||
@cast()
|
||||
|
|
Loading…
Reference in a new issue