         re = /^(.+)\(/
         return re.exec(line)[1]
 
-    insertLine: ({text, currentRow}) ->
-        command = jQuery('#commandToInsert').find(':selected').text()
+    insertLine: ({text, line, currentRow}) ->
+        command = @getCommandFromLine(line)
         if @commands[command]['used'] < @commands[command]['maxUses']
             @commands[command]['used']++
 
-            numberOfInputs = @commands[command]['inputs']
-            inputs = []
             inputsDiv = jQuery('#insertButtons')
-            for i in [1..numberOfInputs] by 1
-                inputs[i - 1] = inputsDiv.find("##{i}").val()
-
-            # Possibly do some input sanitizing here.
-
-            toInsert = "#{command}(#{inputs.join()});"
-            text.insertLines currentRow, [toInsert]
+            text.insertLines currentRow, [text]
 
             if text.getLength() == 2 and text.getLine(currentRow + 1) == ""
                 text.removeNewLine currentRow

                if i != numberOfInputs
                    underscoresForInputs += ', '

            button = jQuery '<button>', {
                id: command,
                text: "#{command}(#{underscoresForInputs})",
                click: (event) ->
                    alert "test"
            }
            buttons.push button.get 0
        buttonField.append buttons

        ###
        playerCodeEditor = @
        return ->
            func.apply playerCodeEditor, arguments
            playerCodeEditor.editor.focus()
            return

