 
     insertLine: ({text, line, currentRow}) ->
         maxRow = @editSession.getLength()
-        if currentRow + 1 < @codePrefixLength or currentRow + 1 >= maxRow - (@codeSuffixLength - 1)
-            return
+        currentRow = Math.max(currentRow, @codePrefixLength-1)        
+        currentRow = Math.min(currentRow, maxRow-@codeSuffixLength-1  )   
         currentLine = text.getLine currentRow
 
         if @commands.hasOwnProperty line

        @onStudentCodeChange()
        @moveEditorButtonDelay = 30
        setTimeout @moveEditorButtons, @moveEditorButtonDelay
        @editor.gotoLine @findFirstNonCommentLine(@codeConfig.initial)
        return

    setUpInsertButtons: ->

        @codeSuffixLength = 0
        if @wrapCode == true
            if @codePrefix != ""
                @codeText = @codePrefix + @initialText
                @codePrefixLength = @codePrefix.split('\n').length - 1
            if @codeSuffix != ""
                @codeText += '\n' + @codeSuffix
