Skip to content

Commit 5fe3930

Browse files
committed
Merge pull request onevcat#186 from onevcat/fix/enum-crash
Enum crash at EOF
2 parents 0cd033e + 7c2b90b commit 5fe3930

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

VVDocumenter-Xcode/Commenter/VVEnumCommenter.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ - (NSString *)document {
4646
NSTextCheckingResult *enumDefineResult = [enumDefineExpression firstMatchInString:self.code options:0 range:NSMakeRange(0, self.code.length)];
4747

4848
finalString = [finalString stringByAppendingString:[self.code substringWithRange:[enumDefineResult rangeAtIndex:0]]];
49-
finalString = [finalString stringByAppendingString:@"\n"];
49+
finalString = [finalString substringToIndex:finalString.length - 1];
50+
finalString = [finalString stringByAppendingString:@" {\n"];
5051

5152
NSString *endPattern = @"\\}\\s*;";
5253
NSString *enumPartsString = [[self.code vv_stringByReplacingRegexPattern:enumDefinePattern withString:@""]

VVDocumenter-Xcode/OCCategory/NSString+VVTextGetter/NSString+VVTextGetter.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ -(VVTextResult *) vv_textResultUntilNextString:(NSString *)findString currentLoc
115115
NSString *line = nil;
116116
if (nextLineRange.location != NSNotFound && rangeToString.location != NSNotFound && nextLineRange.location <= rangeToString.location) {
117117
NSRange lineRange = NSMakeRange(nextLineRange.location + 1, rangeToString.location - nextLineRange.location);
118-
if (lineRange.location < [self length] && NSMaxRange(lineRange) < [self length]) {
118+
if (lineRange.location < [self length] && NSMaxRange(lineRange) <= [self length]) {
119119
line = [self substringWithRange:lineRange];
120120
return [[VVTextResult alloc] initWithRange:lineRange string:line];
121121
} else {

VVDocumenterTests/DocumenterTests/VVMethodTestsCode.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@
355355
<string>/**
356356
* &lt;#Description#&gt;
357357
*/
358-
typedef NS_ENUM(NSInteger, SIAlertViewBackgroundStyle){
358+
typedef NS_ENUM(NSInteger, SIAlertViewBackgroundStyle) {
359359
/**
360360
* &lt;#Description#&gt;
361361
*/

0 commit comments

Comments
 (0)