     projectDocument.error(String(format: fmt, errorInfo))
   }
 
+  func document(doc:NSDocument, didSave:Bool, contextInfo: UnsafeMutablePointer<Void>) {
+    if contextInfo == &ProjectEditorConfigManagerViewController.PostSaveContextAddConfig {
+      if didSave {
+        didClickAddConfig(nil)
+      }
+    }
+  }
+
   // MARK: - Private methods
 
-  func didClickAddConfig(sender: AnyObject?) {
+  private func didClickAddConfig(sender: AnyObject?) {
     let projectDocument = representedObject as! TulsiProjectDocument
 
     // Adding a config to a project with no bazel packages is disallowed.
     guard let bazelPackages = projectDocument.bazelPackages where !bazelPackages.isEmpty else {
+      // This should be prevented by the UI, so spawn a bug message and beep.
+      projectDocument.info("Bug: Add config invoked on a project with no packages.")
       NSBeep()
       return
     }

    case Add = 0
    case Remove = 1
  }

  @IBOutlet var configArrayController: NSArrayController!
  @IBOutlet weak var addRemoveSegmentedControl: NSSegmentedControl!

      let additionalFilePaths = bazelPackages.map() { "\($0)/BUILD" }
      guard let projectName = projectDocument.projectName,
                generatorConfigFolderURL = projectDocument.generatorConfigFolderURL else {
        projectDocument.saveDocumentWithDelegate(self,
                                                 didSaveSelector: Selector("document:didSave:contextInfo:"),
                                                 contextInfo: &ProjectEditorConfigManagerViewController.PostSaveContextAddConfig)
        return
      }

