(void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler
{
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure.
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure.
//要实现光标选择的几行删除
if (invocation.buffer.selections.count!=0) {
//开始删除的位置
NSInteger loc = invocation.buffer.selections.firstObject.start.line;
//删除行的数量
NSInteger len = invocation.buffer.selections.firstObject.end.line-loc+1;
//指定范围
NSRange range = NSMakeRange(loc, len);
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:range];
[invocation.buffer.lines removeObjectsAtIndexes:set];
}
// completionHandler(nil);
completionHandler(nil);
}
{
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure.
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure.
//要实现光标选择的几行删除
if (invocation.buffer.selections.count!=0) {
//开始删除的位置
NSInteger loc = invocation.buffer.selections.firstObject.start.line;
//删除行的数量
NSInteger len = invocation.buffer.selections.firstObject.end.line-loc+1;
//指定范围
NSRange range = NSMakeRange(loc, len);
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:range];
[invocation.buffer.lines removeObjectsAtIndexes:set];
}
// completionHandler(nil);
completionHandler(nil);
}