         ###
             This function is triggered after the text in the ace editor is changed.
         ###
-        startRow = changeEvent.data.range.start.row
-        text = @editSession.getLine startRow
-        # alert "Text Left:\n#{text}"
+        if @scanTextID
+            window.clearTimeout @scanTextID
+            delete @scanTextID
+        @scanTextID = window.setTimeout @scanTextCallback.bind(@), 1500
         return true
+
+    scanTextCallback: ->
+        @scanText()
+        @UpdateCommandsStatus()
 
     scanText: ->
         ###


    deleteLine: ({text, currentRow}) ->
        line = text.getLine currentRow
        if line != ""
            command = @getCommandFromLine line
            @commands[command]['usesRemaining']++
            @UpdateCommandsStatus()
        if text.getLength() == 1
            text.insertLines currentRow + 1, ["\n"]
            text.removeNewLine currentRow
        text.removeLines currentRow, currentRow
        return

    getCommandFromLine: (line) ->
        re = /^(.+)\(/
        return re.exec(line)[1]

    insertLine: ({text, line, currentRow}) ->
        command = @getCommandFromLine(line)
        if @commands[command]['usesRemaining'] > 0
            @commands[command]['usesRemaining']--

            inputsDiv = jQuery('#insertButtons')
            text.insertLines currentRow, [line]

            if text.getLength() == 2 and text.getLine(currentRow + 1) == ""
                text.removeNewLine currentRow

            @UpdateCommandsStatus()
        return

    resetState: ->

                if i != numberOfInputs
                    innerRegex += ","

            re = "^#{command}\\((#{innerRegex})\\)(?:,|.|$)"
            @commands[command]['regex'] = RegExp re
        return

