Skip to content

Commit

Permalink
adde re-selection of groups when exiting search.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarke committed Nov 14, 2022
1 parent 289a27c commit 59f4fd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion MacPass/MPDocument+Search.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ - (void)enterSearchWithContext:(MPEntrySearchContext *)context {
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidEnterSearchNotification object:self];
[self updateSearch:self];
/* clear selection */
self.selectedGroups = nil;
self.selectedEntries = nil;
}

Expand Down
14 changes: 13 additions & 1 deletion MacPass/MPOutlineViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

@interface MPOutlineViewController () {
BOOL _bindingEstablished;
NSIndexSet *_storedSelectionIndexSet;
MPOutlineContextMenuDelegate *_menuDelegate;

}
Expand Down Expand Up @@ -100,7 +101,6 @@ - (void)viewDidLoad {
name:MPDidActivateViewNotification
object:self.outlineView];


NSView *clipView = self.outlineView.enclosingScrollView.contentView;
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(_outlineDidScroll:)
Expand Down Expand Up @@ -226,6 +226,8 @@ - (void)setDatabaseNameWrapper:(NSString *)databaseNameWrapper {
- (void)registerNotificationsForDocument:(MPDocument *)document {
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didExitSearch:) name:MPDocumentDidExitSearchNotification object:document];
}

- (void)clearSelection {
Expand Down Expand Up @@ -273,6 +275,16 @@ - (void)_didRevertDocument:(NSNotification *)notification {
[self clearSelection];
}

- (void)_didEnterSearch:(NSNotification *)notification {
// store seelection
_storedSelectionIndexSet = self.outlineView.selectedRowIndexes;
[self clearSelection];
}

- (void)_didExitSearch:(NSNotification *)notification {
[self.outlineView selectRowIndexes:_storedSelectionIndexSet byExtendingSelection:NO];
}

- (id)itemUnderMouse {
NSPoint mouseLocation = [self.outlineView.window mouseLocationOutsideOfEventStream];
NSPoint localPoint = [self.outlineView convertPoint:mouseLocation fromView:self.outlineView.window.contentView];
Expand Down

0 comments on commit 59f4fd0

Please sign in to comment.