Select last added document when creating multiple tabs at once

When we close a tab then we select the tab to the left, for this reason it makes most sense to select the last tab added, so that ⌘W will effectively go to the “next tab inserted”.

The exception is when we create a new project, here we select the first tab since there are no tabs to the left, so ⌘W will still work as a “next tab” button. Though I may later change this so that the behavior is consistent.
This commit is contained in:
Allan Odgaard
2016-06-26 16:53:15 +02:00
parent e39e744636
commit 41b987e82c

View File

@@ -983,8 +983,8 @@ namespace
tabsToClose = [self disposableDocument];
}
[self insertDocuments:documents atIndex:_selectedTabIndex + 1 selecting:documents.front() andClosing:tabsToClose];
[self openAndSelectDocument:documents.front()];
[self insertDocuments:documents atIndex:_selectedTabIndex + 1 selecting:documents.back() andClosing:tabsToClose];
[self openAndSelectDocument:documents.back()];
if(self.tabBarView && ![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableTabAutoCloseKey])
{
@@ -2743,7 +2743,8 @@ static NSUInteger DisableSessionSavingCount = 0;
static DocumentController* controller_with_documents (std::vector<document::document_ptr> const& documents, oak::uuid_t const& projectUUID = document::kCollectionAny)
{
DocumentController* controller = find_or_create_controller(documents, projectUUID);
[controller insertDocuments:documents atIndex:controller.selectedTabIndex + 1 selecting:documents.front() andClosing:[controller disposableDocument]];
auto documentToSelect = controller.documents.size() <= [controller disposableDocument].size() ? documents.front() : documents.back();
[controller insertDocuments:documents atIndex:controller.selectedTabIndex + 1 selecting:documentToSelect andClosing:[controller disposableDocument]];
return controller;
}