Here's the second attempt of building my live-preview #Markdown editor: I made some massive improvements! 🚀 In fact, I think the last bug to fix is caret navigation using arrow-right key. For example, if I navigate caret from left to right into a word with bold styling, it'll skip over the asterisks "**|word**" and move immediately to inside of range. It works fine when navigating caret from opposite direction (right to left)... It's a minor detail, but important for a good UX. #dev #macOS #AppKit #Swift #SwiftUI

Replies (2)

This bug has been fixed ✅ I’m surprised at how reliable the insertion and removal logic for syntax is. It seems to work perfectly! I do need to implement logic so that syntax shows when making a text selection. This is the same behavior in Obsidian and I think it’s the right way.
There’s a critical bug that I need to solve. If I type or remove a character in the editor, all the Markdown styling will be messed up and all line-breaks also seem to be removed. This could potentially be a re-rendering problem where the `AttributedString` is being reset.