diff --git a/Frameworks/DocumentWindow/src/DocumentSaveHelper.mm b/Frameworks/DocumentWindow/src/DocumentSaveHelper.mm index 9e5bdc7b..cff648db 100644 --- a/Frameworks/DocumentWindow/src/DocumentSaveHelper.mm +++ b/Frameworks/DocumentWindow/src/DocumentSaveHelper.mm @@ -204,7 +204,11 @@ namespace - (void)didSaveDocument:(document::document_ptr const&)aDocument success:(BOOL)flag error:(std::string const&)aMessage usingFilter:(oak::uuid_t const&)aFilter { D(DBF_DocumentController_SaveHelper, bug("‘%s’, success %s, user abort %s\n", aDocument->path().c_str(), BSTR(flag), BSTR(self.userAbort));); - if(!flag && !self.userAbort) + if(flag) + { + [[NSNotificationCenter defaultCenter] postNotificationName:@"OakDocumentNotificationDidSave" object:self userInfo:@{ @"window" : self.window }]; + } + else if(!self.userAbort) { [self.window.attachedSheet orderOut:self]; if(aFilter) diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index 3737d847..8baa3b2f 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -524,6 +524,7 @@ static std::string shell_quote (std::vector paths) [self registerForDraggedTypes:[[self class] dropTypes]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentWillSave:) name:@"OakDocumentNotificationWillSave" object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentDidSave:) name:@"OakDocumentNotificationDidSave" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDefaultsDidChange:) name:NSUserDefaultsDidChangeNotification object:[NSUserDefaults standardUserDefaults]]; } return self; @@ -548,6 +549,20 @@ static std::string shell_quote (std::vector paths) document->set_folded(layout->folded_as_string()); } +- (void)documentDidSave:(NSNotification*)aNotification +{ + NSWindow* window = [[aNotification userInfo] objectForKey:@"window"]; + if(window != self.window) + return; + + D(DBF_Document, bug("search for ‘did save’ hooks in scope ‘%s’\n", to_s(editor->scope(to_s([self scopeAttributes]))).c_str());); + citerate(item, bundles::query(bundles::kFieldSemanticClass, "callback.document.did-save", editor->scope(to_s([self scopeAttributes])))) + { + D(DBF_Document, bug("%s\n", (*item)->name().c_str());); + [self performBundleItem:*item]; + } +} + - (void)reflectDocumentSize { if(document && layout && [self enclosingScrollView]) diff --git a/Frameworks/document/src/document.cc b/Frameworks/document/src/document.cc index bd7c5e10..bbe2fac8 100644 --- a/Frameworks/document/src/document.cc +++ b/Frameworks/document/src/document.cc @@ -613,13 +613,6 @@ namespace document check_modified(revision(), revision()); mark_pristine(); broadcast(callback_t::did_save); - - D(DBF_Document, bug("search for ‘did save’ hooks in scope ‘%s’\n", to_s(scope()).c_str());); - citerate(item, bundles::query(bundles::kFieldSemanticClass, "callback.document.did-save", scope())) - { - D(DBF_Document, bug("%s\n", (*item)->name().c_str());); - document::run(parse_command(*item), buffer(), ng::ranges_t(), shared_from_this()); - } } if(_is_on_disk)