mirror of
https://github.com/zhigang1992/macdown.git
synced 2026-01-12 22:48:37 +08:00
Prevent cursor move on trailing newline insertion
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user