     if File.isDirectory @filename
       File.changeWorkingDirectory @filename
       activeWindow.setTitle _.last @filename.split '/'
-      @ace.getSession().setValue ""
+      @ace.setSession @newSession()
       activeWindow.setDirty false
     else
       if /png|jpe?g|gif/i.test @filename
         App.openURL @filename
       else
         activeWindow.setTitle _.last @filename.split '/'
-        @ace.getSession().setValue File.read @filename
+        @sessions[@filename] or= @newSession File.read @filename
+        @ace.setSession @sessions[@filename]
         activeWindow.setDirty false
     @ace._emit 'open', { @filename }
 

    'Alt-Shift-.'     : 'end'
    'Ctrl-L'          : 'consolelog'

  initialize: ->
    @ace = ace.edit "editor"
    @ace.setTheme require "ace/theme/twilight"

activeWindow = App.activeWindow

ace = require 'ace/ace'

{EditSession} = require 'ace/edit_session'
{UndoManager} = require 'ace/undomanager'

module.exports =
class Editor extends Pane
