diff --git a/MacDown/Code/Document/MPDocument.m b/MacDown/Code/Document/MPDocument.m
index c8e8c17..c40f0e7 100644
--- a/MacDown/Code/Document/MPDocument.m
+++ b/MacDown/Code/Document/MPDocument.m
@@ -679,7 +679,7 @@ static void (^MPGetPreviewLoadingCompletionHandler(id obj))()
{
if ([textView insertMappedContent])
return NO;
- if ([textView completeNextListItem])
+ if ([textView completeNextListItem:self.preferences.editorAutoIncrementNumberedLists])
return NO;
if ([textView completeNextBlockquoteLine])
return NO;
diff --git a/MacDown/Code/Extension/NSTextView+Autocomplete.h b/MacDown/Code/Extension/NSTextView+Autocomplete.h
index f453035..c3e9079 100644
--- a/MacDown/Code/Extension/NSTextView+Autocomplete.h
+++ b/MacDown/Code/Extension/NSTextView+Autocomplete.h
@@ -30,7 +30,7 @@
- (void)indentSelectedLinesWithPadding:(NSString *)padding;
- (void)unindentSelectedLines;
- (BOOL)insertMappedContent;
-- (BOOL)completeNextListItem;
+- (BOOL)completeNextListItem:(BOOL)autoIncrement;
- (BOOL)completeNextBlockquoteLine;
- (BOOL)completeNextIndentedLine;
- (void)makeHeaderForSelectedLinesWithLevel:(NSUInteger)level;
diff --git a/MacDown/Code/Extension/NSTextView+Autocomplete.m b/MacDown/Code/Extension/NSTextView+Autocomplete.m
index 1a5647e..15fb427 100644
--- a/MacDown/Code/Extension/NSTextView+Autocomplete.m
+++ b/MacDown/Code/Extension/NSTextView+Autocomplete.m
@@ -451,7 +451,7 @@ static NSString * const kMPBlockquoteLinePattern = @"^((?:\\> ?)+).*$";
return YES;
}
-- (BOOL)completeNextListItem
+- (BOOL)completeNextListItem:(BOOL)autoIncrement
{
NSRange selectedRange = self.selectedRange;
NSUInteger location = selectedRange.location;
@@ -511,7 +511,9 @@ static NSString * const kMPBlockquoteLinePattern = @"^((?:\\> ?)+).*$";
NSRange range = [result rangeAtIndex:3];
range.length -= 1; // Exclude trailing space.
NSString *captured = [line substringWithRange:range];
- NSInteger i = captured.integerValue + 1;
+ NSInteger i = captured.integerValue;
+ if (autoIncrement)
+ i += 1;
t = [NSString stringWithFormat:@"%ld.", i];
}
if (!t)
diff --git a/MacDown/Code/Preferences/MPPreferences.h b/MacDown/Code/Preferences/MPPreferences.h
index 80d25bd..70da20f 100644
--- a/MacDown/Code/Preferences/MPPreferences.h
+++ b/MacDown/Code/Preferences/MPPreferences.h
@@ -33,6 +33,7 @@ extern NSString * const MPDidDetectFreshInstallationNotification;
@property (assign) BOOL markdownManualRender;
@property (assign) NSDictionary *editorBaseFontInfo;
+@property (assign) BOOL editorAutoIncrementNumberedLists;
@property (assign) BOOL editorConvertTabs;
@property (assign) BOOL editorCompleteMatchingCharacters;
@property (assign) BOOL editorSyncScrolling;
diff --git a/MacDown/Code/Preferences/MPPreferences.m b/MacDown/Code/Preferences/MPPreferences.m
index 654d6c2..cbf88e4 100644
--- a/MacDown/Code/Preferences/MPPreferences.m
+++ b/MacDown/Code/Preferences/MPPreferences.m
@@ -75,6 +75,7 @@ static NSString * const kMPDefaultHtmlStyleName = @"GitHub2";
@dynamic markdownManualRender;
+@dynamic editorAutoIncrementNumberedLists;
@dynamic editorConvertTabs;
@dynamic editorCompleteMatchingCharacters;
@dynamic editorSyncScrolling;
@@ -148,6 +149,8 @@ static NSString * const kMPDefaultHtmlStyleName = @"GitHub2";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"editorMaximumWidth"])
self.editorMaximumWidth = 1000.0;
+ if (![defaults objectForKey:@"editorAutoIncrementNumberedLists"])
+ self.editorAutoIncrementNumberedLists = YES;
}
@end
diff --git a/MacDown/Localization/Base.lproj/MPEditorPreferencesViewController.xib b/MacDown/Localization/Base.lproj/MPEditorPreferencesViewController.xib
index 5e60b0b..d9a8b55 100644
--- a/MacDown/Localization/Base.lproj/MPEditorPreferencesViewController.xib
+++ b/MacDown/Localization/Base.lproj/MPEditorPreferencesViewController.xib
@@ -16,11 +16,11 @@
-
+
-
+
@@ -29,7 +29,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
@@ -56,7 +56,7 @@
-
+
-
+
+
@@ -115,6 +126,9 @@
+
+
+
@@ -123,7 +137,7 @@
-
+
@@ -141,7 +155,7 @@
-
+
@@ -155,7 +169,7 @@
-
+
@@ -164,7 +178,7 @@
-
+
@@ -186,7 +200,7 @@
-
+
@@ -208,7 +222,7 @@
-
+
@@ -216,7 +230,7 @@
-
+
@@ -224,7 +238,7 @@
-
+
@@ -233,7 +247,7 @@
-
+
@@ -249,7 +263,7 @@
-
+
@@ -257,7 +271,7 @@
-
+
@@ -285,7 +299,7 @@
-
+