mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 09:22:33 +00:00
Removed duplicate paste commands for autotype
This commit is contained in:
@@ -151,9 +151,15 @@
|
||||
|
||||
+ (void)appendPasteCommandForContent:(NSString *)pasteContent toCommands:(NSMutableArray *)commands {
|
||||
if(pasteContent) {
|
||||
/* Update an already inserted paste command with the new conents */
|
||||
if([[commands lastObject] isKindOfClass:[MPAutotypePaste class]]) {
|
||||
[[commands lastObject] appendString:pasteContent];
|
||||
}
|
||||
else {
|
||||
MPAutotypePaste *pasteCommand = [[MPAutotypePaste alloc] initWithString:pasteContent];
|
||||
[commands addObject:pasteCommand];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)appendCommandForString:(NSString *)commandString toCommands:(NSMutableArray *)commands activeModifer:(CGEventFlags)flags {
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
@interface MPAutotypePaste : MPAutotypeCommand
|
||||
|
||||
- (instancetype)initWithString:(NSString *)aString;
|
||||
- (void)appendString:(NSString *)aString;
|
||||
|
||||
@end
|
||||
@@ -27,6 +27,11 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appendString:(NSString *)aString {
|
||||
self.pasteData = [self.pasteData stringByAppendingString:aString];
|
||||
}
|
||||
|
||||
|
||||
- (void)execute {
|
||||
if([self.pasteData length] > 0) {
|
||||
MPPasteBoardController *controller = [MPPasteBoardController defaultController];
|
||||
@@ -40,4 +45,6 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -50,14 +50,11 @@
|
||||
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"];
|
||||
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
||||
|
||||
XCTAssert([commands count] == 7);
|
||||
XCTAssert([commands count] == 4);
|
||||
XCTAssert([commands[0] isKindOfClass:[MPAutotypePaste class]]);
|
||||
XCTAssert([commands[1] isKindOfClass:[MPAutotypePaste class]]);
|
||||
XCTAssert([commands[1] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||
XCTAssert([commands[2] isKindOfClass:[MPAutotypePaste class]]);
|
||||
XCTAssert([commands[3] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||
XCTAssert([commands[4] isKindOfClass:[MPAutotypePaste class]]);
|
||||
XCTAssert([commands[5] isKindOfClass:[MPAutotypePaste class]]);
|
||||
XCTAssert([commands[6] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||
|
||||
context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
||||
commands = [MPAutotypeCommand commandsForContext:context];
|
||||
|
||||
Reference in New Issue
Block a user