From f550fdda1808dc783760b55fab05d4b34382ae05 Mon Sep 17 00:00:00 2001 From: Dominic Yu Date: Thu, 14 Dec 2023 00:11:39 -0800 Subject: [PATCH] avoid reloading directory when undoing move/trash --- CreeveyMainWindowController.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CreeveyMainWindowController.m b/CreeveyMainWindowController.m index 0a3c6b9..a4d44ab 100644 --- a/CreeveyMainWindowController.m +++ b/CreeveyMainWindowController.m @@ -484,13 +484,17 @@ - (void)fileWasDeleted:(NSString *)s atIndex:(NSUInteger)i { - (void)filesWereUndeleted:(NSArray *)a { NSString *currentPath = self.path; - BOOL needsRefresh = NO; + BOOL subfolders = self.wantsSubfolders; for (NSString *s in a) { - if ([s hasPrefix:currentPath]) - needsRefresh = YES; + if (subfolders ? [s hasPrefix:currentPath] : [s.stringByDeletingLastPathComponent isEqualToString:currentPath]) + dispatch_async(dispatch_get_main_queue(), ^{ + if (!filenamesDone) return; + NSUInteger count = filenames.count; + NSUInteger idx = [filenames indexOfObject:s inSortedRange:NSMakeRange(0, count) options:NSBinarySearchingInsertionIndex usingComparator:self.comparator]; + if (idx == count || ![filenames[idx] isEqualToString:s]) + [self addFile:s atIndex:idx]; + }); } - if (needsRefresh) - [self setPath:currentPath]; } - (void)updateStatusFld {