diff --git a/MacDown/Code/Document/MPDocument.m b/MacDown/Code/Document/MPDocument.m index 0bf25db..30bed6e 100644 --- a/MacDown/Code/Document/MPDocument.m +++ b/MacDown/Code/Document/MPDocument.m @@ -514,7 +514,11 @@ static void (^MPGetPreviewLoadingCompletionHandler(MPDocument *doc))() NSString *text = self.editor.string; NSUInteger end = text.length; if (end && ![newline characterIsMember:[text characterAtIndex:end - 1]]) + { + NSRange selection = self.editor.selectedRange; [self.editor insertText:@"\n" replacementRange:NSMakeRange(end, 0)]; + self.editor.selectedRange = selection; + } } return [super writeToURL:url ofType:typeName error:outError]; }