simonbs / Runestone

📝 Performant plain text editor for iOS with syntax highlighting, line numbers, invisible characters and much more.
MIT License
2.68k stars 150 forks source link

Caret position not updating when setting selectedRange #335

Closed jbromberg closed 6 months ago

jbromberg commented 8 months ago

What happened?

When manually setting selectedRange after inserting new text the visual position of the caret is wrong. Once I start typing, the text goes to the position specified by selectedRange and the caret updates. It seems like there may be caret position updating logic in the replace() function that is conflicting with the selectedRange setter.

What are the steps to reproduce?

replace(NSMakeRange(0, 0), withText: "Hello, world!")
selectedRange = NSMakeRange(5, 0)

What is the expected behavior?

Caret position is display based on the selectedRange property.

simonbs commented 6 months ago

Thanks for opening the issue. I believe it's addressed in #364.