Bump date of find/replace pasteboard history items when they are used

Currently this bumping is limited to the Find dialog and happens when executing a search. Selecting from the Show Find History or subsequently using ⌘G, does not bump the date of the selected item (but probably should).
This commit is contained in:
Allan Odgaard
2016-10-08 11:04:13 +02:00
parent 2feb4a497a
commit 03d912e7c4
3 changed files with 14 additions and 7 deletions

View File

@@ -540,17 +540,24 @@ static NSButton* OakCreateStopSearchButton ()
if(OakNotEmptyString(_findString))
{
OakPasteboardEntry* oldEntry = [[OakPasteboard pasteboardWithName:NSFindPboard] current];
if(!oldEntry || ![oldEntry.string isEqualToString:_findString])
if(oldEntry && [oldEntry.string isEqualToString:_findString])
{
if(![oldEntry.options isEqualToDictionary:newOptions])
oldEntry.options = newOptions;
oldEntry.date = [NSDate date];
}
else
{
[[OakPasteboard pasteboardWithName:NSFindPboard] addEntryWithString:_findString andOptions:newOptions];
else if(![oldEntry.options isEqualToDictionary:newOptions])
oldEntry.options = newOptions;
}
}
if(_replaceString)
{
NSString* oldReplacement = [[[OakPasteboard pasteboardWithName:OakReplacePboard] current] string];
if(!oldReplacement || ![oldReplacement isEqualToString:_replaceString])
[[OakPasteboard pasteboardWithName:OakReplacePboard] addEntryWithString:_replaceString];
OakPasteboardEntry* oldEntry = [[OakPasteboard pasteboardWithName:OakReplacePboard] current];
if(oldEntry && [oldEntry.string isEqualToString:_replaceString])
oldEntry.date = [NSDate date];
else [[OakPasteboard pasteboardWithName:OakReplacePboard] addEntryWithString:_replaceString];
}
return res;

View File

@@ -14,6 +14,7 @@ extern PUBLIC NSString* const OakFindRegularExpressionOption;
PUBLIC @interface OakPasteboardEntry : NSManagedObject
@property (nonatomic) NSString* string;
@property (nonatomic) NSDictionary* options;
@property (nonatomic) NSDate* date;
@property (nonatomic) BOOL fullWordMatch;
@property (nonatomic) BOOL ignoreWhitespace;

View File

@@ -21,7 +21,6 @@ NSString* const OakFindRegularExpressionOption = @"regularExpression";
NSString* const kUserDefaultsDisablePersistentClipboardHistory = @"disablePersistentClipboardHistory";
@interface OakPasteboardEntry ()
@property (nonatomic) NSDate* date;
@property (nonatomic) OakPasteboard* pasteboard;
@property (nonatomic) NSDictionary* primitiveOptions;
@end