     @closeCharacter == string
 
   selectionIsWrappedByMatchingBrackets: (selection) ->
+    return false if selection.isEmpty()
     selectedText = selection.getText()
     firstCharacter = selectedText[0]
     lastCharacter = selectedText[ selectedText.length - 1 ]

        false

    _.adviseBefore editor, 'insertNewline', =>
      selection = editor.getSelection()
      return if editor.hasMultipleCursors()
      return unless editor.getSelection().isEmpty()

      if @selectionIsWrappedByMatchingBrackets(selection)
        editor.transact =>
          editor.insertText "\n\n"
          editor.moveCursorUp()

        false

    _.adviseBefore editor, 'backspace', =>
      return if editor.hasMultipleCursors()
      return unless editor.getSelection().isEmpty()

      cursorBufferPosition = editor.getCursorBufferPosition()
      previousCharacter = editor.getTextInBufferRange([cursorBufferPosition.add([0, -1]), cursorBufferPosition])
      nextCharacter = editor.getTextInBufferRange([cursorBufferPosition, cursorBufferPosition.add([0,1])])
      if @pairedCharacters[previousCharacter] is nextCharacter
        editor.transact =>
          editor.moveCursorLeft()
          editor.delete()
