kyle-n / HighlightedTextEditor

A SwiftUI view for dynamically highlighting user input
MIT License
719 stars 68 forks source link

[Markdown] Entering text will jitter after pressing enter in the title #76

Open iamiota opened 8 months ago

iamiota commented 8 months ago

DO NOT DELETE THIS TEMPLATE

If you do not fill out this template, your issue will be automatically closed.

Describe the bug In markdown mode, text input will jitter after pressing enter in the title.

To Reproduce

  1. Input "# aaaaaa"
  2. Press "Enter" and input "aaaaa"
  3. After returning the cursor to "# aaaaaa", press enter, and then enter text

Expected behavior Normally output text in default font

Screenshots If applicable, add screenshots to help explain your problem.

https://github.com/kyle-n/HighlightedTextEditor/assets/7531576/52015b48-5278-4586-9a6b-d052ca3c1652

Environment Please include:

Additional context Add any other context about the problem here.

iamiota commented 8 months ago

It is worth mentioning that I also have a similar font size bug when using another markdown editor (SwiftDown). I don’t know if it is because of the system version. I am preparing to upgrade to the latest macos system. After that, I will give feedback.

iamiota commented 8 months ago

The bug still exists in macOS 14.2.1

kyle-n commented 8 months ago

Confirmed the bug is happening on macOS 14.2.1.

Code to reproduce:

struct MarkdownEditorA: View {
    @State var text: String = ""

    var body: some View {
        HighlightedTextEditor(text: $text, highlightRules: .markdown)
    }
}

Steps:

  1. Type "a" (without quotes) and press return twice
  2. Type "# b" and press return twice
  3. Type "c"
  4. Use the mouse to move the insertion point to the end of "# b"
  5. Press return once and type "d"
  6. Observe each letter typed starts as big, then resizes to regular size

Not sure what the problem is. Going to see if anyone else is having trouble with NSTextView() on Sonoma.

envomer commented 7 months ago

I am experiencing the same issue on macOS 14.2.1 Sonoma.

garrettmurray commented 7 months ago

Reproducible on macOS 14.3.1 as well.