     return @messages
 
   build: ->
+    # get current editor
+    editor = atom.workspace.getActiveTextEditor()
+
     # get path of currently open file
-    filepath = atom.workspace.getActiveTextEditor()?.getPath()
-
+    filepath = editor?.getPath()
 
     # only continue if file is a .pwn file
     return unless filepath? and path.extname(filepath) == '.pwn'
-    #also save it, so the unsaved buffer is included
-    atom.workspace.getActiveTextEditor().save()
+
+    # also save the current file, so the current buffer is included
+    editor.save()
 
     # prepare command and arguments from package settigns
     cmd = atom.config.get('pawn-build.pawnExecutablePath')

        type: 'string'

  activate: (state) ->
    # Activate package
    @subscriptions = new CompositeDisposable
    @subscriptions.add atom.commands.add 'atom-workspace', 'pawn-build:build': => @build()

  deactivate: ->
    # Deactivate package
    @messages?.detatch()
    @subscriptions.dispose()
    @pawnBuildView.destroy()

  serialize: -> undefined

  createOutputPanel: ->
    # create output panel (or return if already exists)
    unless @messages?
      @messages = new MessagePanelView
        title: 'Pawn output'
