   setSelectionRange: (range) ->
     range = Range.fromObj(range)
     @$textArea.get(0).selectionStart = @characterIndexForPosition range.start
-    @$textArea.get(0).selectionEnd = @characterIndexForPosition range.end
+    @$textArea.get(0).selectionEnd   = @characterIndexForPosition range.end
 
   delete: (range) ->
     range = Range.fromObj range
     rangeStartIx = @characterIndexForPosition range.start
-    rangeEndIx = @characterIndexForPosition range.end
+    rangeEndIx   = @characterIndexForPosition range.end
     rangeLength = rangeEndIx - rangeStartIx
     selStartIx = @$textArea.get(0).selectionStart
-    selEndIx = @$textArea.get(0).selectionEnd
-    # TODO: fix layout
-    selStartIx = if selStartIx <= rangeStartIx then selStartIx else
-                                                    if selStartIx < rangeEndIx then rangeStartIx else
-                                                                                    selStartIx - rangeLength
-    selEndIx = if selEndIx <= rangeStartIx then selEndIx else if selEndIx < rangeEndIx then rangeStartIx else selEndIx - rangeLength
+    selEndIx   = @$textArea.get(0).selectionEnd
+
+    selStartIx = switch
+                   when selStartIx <= rangeStartIx then selStartIx
+                   when selStartIx < rangeEndIx    then rangeStartIx
+                   else selStartIx - rangeLength
+    selEndIx   = switch
+                   when selEndIx <= rangeStartIx then selEndIx
+                   when selEndIx < rangeEndIx    then rangeStartIx
+                   else selEndIx - rangeLength
     @setTextInRange range, ''
     @$textArea.get(0).selectionStart = selStartIx
-    @$textArea.get(0).selectionEnd = selEndIx
+    @$textArea.get(0).selectionEnd   = selEndIx
 
   setTextInRange: (range, text) ->
     range = Range.fromObj range
     rangeStartIx = @characterIndexForPosition range.start
-    rangeEndIx = @characterIndexForPosition range.end
+    rangeEndIx   = @characterIndexForPosition range.end
     bufferText = @$textArea.val()
     @setText (bufferText.slice 0, rangeStartIx) + text + (bufferText.slice rangeEndIx, bufferText.length)
 

          @listPaste()
        else
          return true
      return false
    return
  listSelect: ->
    console.log 'list-select'
    ListEdit.selectCmd()
    return
  listCut: ->
    console.log 'list-cut'
    ListEdit.cutCmd()
    return
  listCopy: ->
    console.log 'list-copy'
    ListEdit.copyCmd()
    return
  listPaste: ->
    console.log 'list-paste'
    ListEdit.pasteCmd()
    return
###


  notifications:
    hideTimer: null

    addNotification: (msg, bgColor, duration) ->
      $notification = $('#atom-Emulator .notification')
      $notification.text msg
