Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,10 @@ extension NativeTextViewCoordinator {
self.previousActiveTokenIndices = self.activeTokenIndices
self.previousCaretLocation = caretLoc

// Track code blocks for button overlay (reuse tokens)
updateCodeBlockSelection(textView: tv, tokens: tokens)
// Skip during a pending edit — viewRect is stale until textDidChange's restyle runs; otherwise the overlay flashes to the old Y before settling.
if !shouldSkipSelectionRestyle {
updateCodeBlockSelection(textView: tv, tokens: tokens)
}
}

public func textView(_ textView: NSTextView, shouldChangeTextIn affectedCharRange: NSRange, replacementString: String?) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class NativeTextView: NSTextView {
}
}

// AppKit doesn't fire textDidChange for setMarkedText mutations, so Apple's inline-prediction inserts the completion with base typingAttributes and heading lines flicker to body font; restyle the paragraph here to reapply heading font.
// AppKit skips textDidChange for setMarkedText, so markdown attrs (heading font, code-block bg) don't reach the marked range — restyle the affected paragraph to fix it.
override func setMarkedText(_ string: Any, selectedRange: NSRange, replacementRange: NSRange) {
super.setMarkedText(string, selectedRange: selectedRange, replacementRange: replacementRange)
guard hasMarkedText(),
Expand All @@ -67,8 +67,6 @@ final class NativeTextView: NSTextView {
guard marked.location != NSNotFound, marked.length > 0 else { return }
let nsText = self.string as NSString
let paragraph = nsText.paragraphRange(for: marked)
let line = nsText.substring(with: nsText.lineRange(for: NSRange(location: paragraph.location, length: 0)))
guard line.hasPrefix("#") else { return }
coord.restyleParagraphs([paragraph], in: self)
}

Expand Down
Loading