Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions MacDown/Code/Extension/NSTextView+Autocomplete.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
};

static NSString * const kMPListLineHeadPattern =
@"^(\\s*)((?:(?:\\*|\\+|-|)\\s+)?)((?:\\d+\\.\\s+)?)(\\S)?";
@"^(\\s*)((?:(?:\\*|\\+|-|)\\s+)?)((?:\\d+\\.\\s+)?)((?:\\[[ xX]\\]\\s+)?)(\\S)?";
static NSString * const kMPBlockquoteLinePattern = @"^((?:\\> ?)+).*$";


Expand Down Expand Up @@ -537,7 +537,8 @@ - (BOOL)completeNextListItem:(BOOL)autoIncrement
NSString *t = nil;
BOOL isUl = ([result rangeAtIndex:2].length != 0);
BOOL isOl = ([result rangeAtIndex:3].length != 0);
BOOL previousLineEmpty = ([result rangeAtIndex:4].length == 0);
BOOL hasCheckbox = ([result rangeAtIndex:4].length != 0);
BOOL previousLineEmpty = ([result rangeAtIndex:5].length == 0);
if (previousLineEmpty)
{
NSRange replaceRange = NSMakeRange(NSNotFound, 0);
Expand All @@ -558,6 +559,8 @@ - (BOOL)completeNextListItem:(BOOL)autoIncrement
NSRange range = [result rangeAtIndex:2];
range.length -= 1; // Exclude trailing whitespace.
t = [line substringWithRange:range];
if (hasCheckbox)
t = [t stringByAppendingString:@" [ ]"];
}
else if (isOl)
{
Expand All @@ -568,6 +571,8 @@ - (BOOL)completeNextListItem:(BOOL)autoIncrement
if (autoIncrement)
i += 1;
t = [NSString stringWithFormat:@"%ld.", i];
if (hasCheckbox)
t = [t stringByAppendingString:@" [ ]"];
}
if (!t)
return NO;
Expand Down