     @messages.hide()
     editor = atom.workspace.getActiveTextEditor()
     if editor
-      uri = editor.getPath()
-      if @isIdrisFile(uri)
+      if @isIdrisFile editor.getPath()
         @statusbar.show()
-        @loadFile uri
+        @loadFile editor
       else
         @statusbar.hide()
 

    @messages.clear()
    @messages.hide()
    @localChanges = false
    if @isIdrisFile(editor.getURI())
      @loadFile editor.getURI()

  idrisFileChanged: (editor) ->
    @localChanges = editor.isModified()
    if @localChanges
      @statusbar.setStatus 'Idris: local modifications'
    else if @isIdrisFile(editor.getURI())
      @loadFile editor.getURI()

  idrisFileClosed: (editor) ->
    @idrisBuffers -= 1

    cursorPosition = editor.getLastCursor().getCurrentWordBufferRange()
    editor.getTextInBufferRange cursorPosition

  loadFile: (editor) ->
    uri = editor.getURI()
    console.log 'Loading ' + uri
    @messages.clear()
    @model.load uri, (err, message, progress) =>
