Update last effective tab when number of tabs change

Closes #1120
This commit is contained in:
Allan Odgaard
2013-09-15 21:15:18 +02:00
parent 9fe5a058ce
commit 72791ce406

View File

@@ -790,6 +790,19 @@ static id SafeObjectAtIndex (NSArray* array, NSUInteger index)
[modifiedStates addObject:@([self.dataSource tabBarView:self isEditedAtIndex:i])];
}
if(previousShowAsLastTab != 0 && count != tabTitles.count && previousShowAsLastTab < tabTitles.count)
{
// We use tool tip as identifer since this is tilde-abbreviated path and thus more unique than the title
// Ideally we should introduce a real (unique) identifier, like the documents UUID
NSString* tabIdentifier = tabToolTips[previousShowAsLastTab];
if([tabIdentifier isEqualToString:@""])
previousShowAsLastTab = [toolTips indexOfObject:tabTitles[previousShowAsLastTab]];
else previousShowAsLastTab = [toolTips indexOfObject:tabIdentifier];
if(previousShowAsLastTab == NSNotFound)
previousShowAsLastTab = 0;
}
[tabTitles setArray:titles];
[tabToolTips setArray:toolTips];
[tabModifiedStates setArray:modifiedStates];