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,8 +151,14 @@
|
|||||||
|
|
||||||
+ (void)appendPasteCommandForContent:(NSString *)pasteContent toCommands:(NSMutableArray *)commands {
|
+ (void)appendPasteCommandForContent:(NSString *)pasteContent toCommands:(NSMutableArray *)commands {
|
||||||
if(pasteContent) {
|
if(pasteContent) {
|
||||||
MPAutotypePaste *pasteCommand = [[MPAutotypePaste alloc] initWithString:pasteContent];
|
/* Update an already inserted paste command with the new conents */
|
||||||
[commands addObject:pasteCommand];
|
if([[commands lastObject] isKindOfClass:[MPAutotypePaste class]]) {
|
||||||
|
[[commands lastObject] appendString:pasteContent];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MPAutotypePaste *pasteCommand = [[MPAutotypePaste alloc] initWithString:pasteContent];
|
||||||
|
[commands addObject:pasteCommand];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,6 @@
|
|||||||
@interface MPAutotypePaste : MPAutotypeCommand
|
@interface MPAutotypePaste : MPAutotypeCommand
|
||||||
|
|
||||||
- (instancetype)initWithString:(NSString *)aString;
|
- (instancetype)initWithString:(NSString *)aString;
|
||||||
|
- (void)appendString:(NSString *)aString;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -27,6 +27,11 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)appendString:(NSString *)aString {
|
||||||
|
self.pasteData = [self.pasteData stringByAppendingString:aString];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)execute {
|
- (void)execute {
|
||||||
if([self.pasteData length] > 0) {
|
if([self.pasteData length] > 0) {
|
||||||
MPPasteBoardController *controller = [MPPasteBoardController defaultController];
|
MPPasteBoardController *controller = [MPPasteBoardController defaultController];
|
||||||
@@ -40,4 +45,6 @@
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -50,14 +50,11 @@
|
|||||||
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"];
|
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"];
|
||||||
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|
||||||
XCTAssert([commands count] == 7);
|
XCTAssert([commands count] == 4);
|
||||||
XCTAssert([commands[0] isKindOfClass:[MPAutotypePaste class]]);
|
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[2] isKindOfClass:[MPAutotypePaste class]]);
|
||||||
XCTAssert([commands[3] isKindOfClass:[MPAutotypeKeyPress 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}"];
|
context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
||||||
commands = [MPAutotypeCommand commandsForContext:context];
|
commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|||||||
Reference in New Issue
Block a user