Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated to keep selection better across opening and closing items

  • Loading branch information...
commit 2ba170f70ebefef694c54d7d6771d806af2f73b0 1 parent 93f502c
@markhuot authored
Showing with 21 additions and 11 deletions.
  1. +1 −0  src/MHOpenFiles.h
  2. +14 −6 src/MHOpenFiles.m
  3. +6 −5 src/ProjectTree.mm
View
1  src/MHOpenFiles.h
@@ -15,6 +15,7 @@
NSView *dividerView;
id tabView;
NSInteger draggedIndex;
+ id *selectedItem;
}
+ (MHOpenFiles *)sharedInstance;
View
20 src/MHOpenFiles.m
@@ -103,23 +103,28 @@ - (void)addFile:(NSString *)path
- (void)removeFile:(NSString *)path
{
+ selectedItem = [outlineView itemAtRow:[outlineView selectedRow]];
+
[openFiles removeObject:path];
[outlineView reloadData];
+
+ [self selectFile:selectedItem];
+
[self resizeViews];
}
- (void)selectFile:(NSString *)path
{
- int len = [openFiles count];
+ int len = [outlineView numberOfRows];
int i = 0;
for (i; i<len; i++)
{
- NSString *filePath = [openFiles objectAtIndex:i];
- if ([path isEqualToString:filePath])
+ id rowPath = [outlineView itemAtRow:i];
+ if ([path isEqualToString:rowPath])
{
- [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:(i+1)] byExtendingSelection:NO];
- }
- }
+ [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
+ }
+ }
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
@@ -192,6 +197,7 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toP
}
draggedIndex = [outlineView rowForItem:item]-1;
+ selectedItem = [outlineView itemAtRow:[outlineView selectedRow]];
}
//NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
@@ -226,6 +232,8 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id<NSDraggingInfo>)
[outlineView reloadData];
+ [self selectFile:selectedItem];
+
return YES;
}
View
11 src/ProjectTree.mm
@@ -217,17 +217,18 @@ - (void)ProjectTree_tabBarView:(id)arg1 didOpenTab:(id)tab
}
- (void)ProjectTree_tabBarView:(id)arg1 didCloseTab:(id)tab
{
- [self ProjectTree_tabBarView:arg1 didOpenTab:tab];
+ [self ProjectTree_tabBarView:arg1 didOpenTab:tab];
MHOpenFiles *openFilesClass = [MHOpenFiles objectForTabs:[self valueForKey:@"tabBarView"]];
[openFilesClass removeFile:[tab identifier]];
}
-- (void)ProjectTree_tabBarView:(id)arg1 didSelectTab:(id)arg2
+- (void)ProjectTree_tabBarView:(id)arg1 didSelectTab:(id)tab
{
- [self ProjectTree_tabBarView:arg1 didSelectTab:arg2];
-
- [[MHOpenFiles sharedInstance] selectFile:[arg2 identifier]];
+ [self ProjectTree_tabBarView:arg1 didSelectTab:tab];
+
+ MHOpenFiles *openFilesClass = [MHOpenFiles objectForTabs:[self valueForKey:@"tabBarView"]];
+ [openFilesClass selectFile:[tab identifier]];
}
Please sign in to comment.
Something went wrong with that request. Please try again.