Prevent cursor move on trailing newline insertion

This commit is contained in:
Tzu-ping Chung
2014-12-13 15:10:29 +08:00
parent ee548df4cd
commit 189298619b

View File

@@ -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];
}