   notify:(msg, style, details)->
 
     notification.destroy() if notification
-    
+
     style or= 'error' if details
-    
+
     notification = new KDNotificationView
       title     : msg or "Something went wrong"
       type      : "mini"


    file.on "fs.save.started", =>
      @lastContentsSentForSave = @getContents()
  
  ###
  FS REQUESTS
  ###
        
  requestSave:->

    contents = @getContents()

    fontSize            : @getFontSize()
    tabSize             : @getTabSize()
    softWrap            : @getSoftWrap()

  ###
  SETTERS
  ###

  setContents:(contents)-> @editor.getSession().setValue contents

  setTheme:(themeName)->
    themeName or= @appStorage.getValue 'theme', 'merbivore_soft'
    require ["ace/theme/#{themeName}"], (callback) =>
      @editor.setTheme "ace/theme/#{themeName}"
      @appStorage.setValue 'theme', themeName, =>
        callback

  setSyntax:(mode)->

    file = @getData()
    mode or= file.syntax

    unless mode
      ext  = @utils.getFileExtension file.path
      for name, [language, extensions] of __aceSettings.syntaxAssociations
        if ///^(?:#{extensions})$///i.test ext
          mode = name
      mode or= "text"

    require ["ace/mode/#{mode}"], ({Mode})=>
      @editor.getSession().setMode new Mode
      @syntaxMode = mode

  setUseSoftTabs:(value)->

    @editor.getSession().setUseSoftTabs value
    @appStorage.setValue 'useSoftTabs', value, =>

  setShowGutter:(value)->

    @editor.renderer.setShowGutter value
    @appStorage.setValue 'showGutter', value, =>

  setShowPrintMargin:(value)->

    @editor.setShowPrintMargin value
    @appStorage.setValue 'showPrintMargin', value, =>

  setHighlightActiveLine:(value)->

    @editor.setHighlightActiveLine value
    @appStorage.setValue 'highlightActiveLine', value, =>

  # setHighlightSelectedWord:(value)-> @editor.setHighlightActiveLine value

  setShowInvisibles:(value)->

    @editor.setShowInvisibles value
    @appStorage.setValue 'showInvisibles', value, =>

  setFontSize:(value)->

    @$("editor#{@getId()}").css fontSize : "#{value}px"
    @appStorage.setValue 'fontSize', value, =>

  setTabSize:(value)->

    @editor.getSession().setTabSize value
    @appStorage.setValue 'tabSize', value, =>

  setUseWordWrap:(value)->

    @editor.getSession().setUseWrapMode value
    @appStorage.setValue 'useWordWrap', value, =>

  setSoftWrap:(value)->
    softWrapValueMap =
      'off'  : [ null, 80 ]
      '40'   : [ 40,   40 ]
      '80'   : [ 80,   80 ]
      'free' : [ null, 80 ]

    [limit, margin] = softWrapValueMap[value]

    @editor.getSession().setWrapLimitRange limit, limit
    @editor.renderer.setPrintMarginColumn margin
    @setUseWordWrap no if value is "off"

    @appStorage.setValue 'softWrap', value, =>

  ###
  HELPERS
  ###
