mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Tested and cleaned up comment detection for space disablement sensitivity.
This commit is contained in:
parent
c7eadb5670
commit
b116321deb
1 changed files with 9 additions and 19 deletions
|
@ -216,21 +216,9 @@ module.exports = class SpellView extends CocoView
|
||||||
name: 'disable-spaces'
|
name: 'disable-spaces'
|
||||||
bindKey: 'Space'
|
bindKey: 'Space'
|
||||||
exec: =>
|
exec: =>
|
||||||
cursor = @ace.getCursorPosition()
|
return @ace.execCommand 'insertstring', ' ' unless LevelOptions[@options.level.get('slug')]?.disableSpaces
|
||||||
sentance = @aceDoc.getLine(cursor.row)
|
line = @aceDoc.getLine @ace.getCursorPosition().row
|
||||||
|
return @ace.execCommand 'insertstring', ' ' if @singleLineCommentRegex().test line
|
||||||
commentStarts =
|
|
||||||
javascript: '//'
|
|
||||||
python: '#'
|
|
||||||
coffeescript: '#'
|
|
||||||
clojure: ';'
|
|
||||||
lua: '--'
|
|
||||||
io: '//'
|
|
||||||
commentStart = commentStarts[@spell.language] or '//'
|
|
||||||
if(flg=/#{commentStart}/.test sentance)
|
|
||||||
@ace.execCommand 'insertstring', ' '
|
|
||||||
else
|
|
||||||
@ace.execCommand 'insertstring', ' ' unless LevelOptions[@options.level.get('slug')]?.disableSpaces
|
|
||||||
|
|
||||||
addCommand
|
addCommand
|
||||||
name: 'throttle-backspaces'
|
name: 'throttle-backspaces'
|
||||||
|
@ -797,7 +785,9 @@ module.exports = class SpellView extends CocoView
|
||||||
@recompile()
|
@recompile()
|
||||||
|
|
||||||
singleLineCommentRegex: ->
|
singleLineCommentRegex: ->
|
||||||
return @_singleLineCommentRegex if @_singleLineCommentRegex
|
if @_singleLineCommentRegex
|
||||||
|
@_singleLineCommentRegex.lastIndex = 0
|
||||||
|
return @_singleLineCommentRegex
|
||||||
commentStarts =
|
commentStarts =
|
||||||
javascript: '//'
|
javascript: '//'
|
||||||
python: '#'
|
python: '#'
|
||||||
|
@ -806,8 +796,8 @@ module.exports = class SpellView extends CocoView
|
||||||
lua: '--'
|
lua: '--'
|
||||||
io: '//'
|
io: '//'
|
||||||
commentStart = commentStarts[@spell.language] or '//'
|
commentStart = commentStarts[@spell.language] or '//'
|
||||||
@_singleLineCommentRegexp ?= new RegExp "[ \t]*#{commentStart}[^\"'\n]*", 'g'
|
@_singleLineCommentRegex = new RegExp "[ \t]*#{commentStart}[^\"'\n]*", 'g'
|
||||||
@_singleLineCommentRegexp
|
@_singleLineCommentRegex
|
||||||
|
|
||||||
preload: ->
|
preload: ->
|
||||||
# Send this code over to the God for preloading, but don't change the cast state.
|
# Send this code over to the God for preloading, but don't change the cast state.
|
||||||
|
|
Loading…
Reference in a new issue