mirror of
https://github.com/zhigang1992/macdown.git
synced 2026-04-30 13:02:40 +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;
|
NSString *text = self.editor.string;
|
||||||
NSUInteger end = text.length;
|
NSUInteger end = text.length;
|
||||||
if (end && ![newline characterIsMember:[text characterAtIndex:end - 1]])
|
if (end && ![newline characterIsMember:[text characterAtIndex:end - 1]])
|
||||||
|
{
|
||||||
|
NSRange selection = self.editor.selectedRange;
|
||||||
[self.editor insertText:@"\n" replacementRange:NSMakeRange(end, 0)];
|
[self.editor insertText:@"\n" replacementRange:NSMakeRange(end, 0)];
|
||||||
|
self.editor.selectedRange = selection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return [super writeToURL:url ofType:typeName error:outError];
|
return [super writeToURL:url ofType:typeName error:outError];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user