mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Fix refresh/undo for commands causing document saving
Since saving is asynchronous the scoped refresh/undo helper would do “cleanup” before the command ran and potentially made document changes. Commands executed at a lower level (i.e. by editor_t via macros) presently still has this issue. This should be fixed when macros are refactored (this isn’t the only issue related to macros). Closes #450.
This commit is contained in:
@@ -925,6 +925,41 @@ namespace
|
||||
[DocumentSaveHelper trySaveDocuments:documentsToSave forWindow:self.window defaultDirectory:self.untitledSavePath completionHandler:nil];
|
||||
}
|
||||
|
||||
- (void)bundleItemPreExec:(pre_exec::type)preExec completionHandler:(void(^)(BOOL success))callback
|
||||
{
|
||||
std::vector<document::document_ptr> documentsToSave;
|
||||
switch(preExec)
|
||||
{
|
||||
case pre_exec::save_document:
|
||||
{
|
||||
if(_selectedDocument && (_selectedDocument->is_modified() || !_selectedDocument->is_on_disk()))
|
||||
documentsToSave.push_back(_selectedDocument);
|
||||
}
|
||||
break;
|
||||
|
||||
case pre_exec::save_project:
|
||||
{
|
||||
for(auto document : _documents)
|
||||
{
|
||||
if(document->is_modified() && document->path() != NULL_STR)
|
||||
documentsToSave.push_back(document);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(!documentsToSave.empty())
|
||||
{
|
||||
[DocumentSaveHelper trySaveDocuments:documentsToSave forWindow:self.window defaultDirectory:self.untitledSavePath completionHandler:^(BOOL success){
|
||||
callback(success);
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
callback(YES);
|
||||
}
|
||||
}
|
||||
|
||||
// ================
|
||||
// = Window Title =
|
||||
// ================
|
||||
|
||||
Reference in New Issue
Block a user