       applescript.execString(script)
 
   previewProject: ->
-    script = 'tell application "CodeKit" to preview in browser'
+    script = 'tell application \"CodeKit\" to preview in browser'
     applescript.execString(script)
 
   refreshProject: ->
-    script = 'tell application "CodeKit" to refresh browsers'
+    newPanel = atom.workspace.getActivePaneItem()
+    if newPanel
+      if newPanel.buffer
+        if newPanel.buffer.file
+          script = "tell application \"CodeKit\" to select project containing path \"#{newPanel.buffer.file.path}\""
+          applescript.execString(script)
+    script = 'tell application \"CodeKit\" to refresh browsers'
     applescript.execString(script)
 
   addProject: ->

    autoQuit:
      title: 'Auto Quit Codekit'
      description: 'Auto quit Codekit when Atom window is closed'
      type: 'boolean'
      default: true


    applescript.execString(script)

  switchProject: (newPanel) ->
    if atom.config.get('codekit-commands.autoSwitch')
        if newPanel
          if newPanel.buffer
            if newPanel.buffer.file
              script = "tell application \"CodeKit\" to select project containing path \"#{newPanel.buffer.file.path}\""
              applescript.execString(script)

  pauseProject: ->
    if atom.config.get('codekit-commands.autoPause')
