fix: batch note formatting to prevent typing flashes

This commit is contained in:
Valdemar Lorenzen
2026-10-20 12:41:55 +02:00
parent f6d9d04b74
commit 3dfd9f58a4
5 changed files with 63 additions and 10 deletions
+4 -3
View File
@@ -299,7 +299,6 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
super.insertText(rendered.attributedSubstring(from: inserted), replacementRange: removed)
if semantic { breakUndoCoalescing() }
}
refreshTasks()
let caret = renderedRange(for: NSRange(location: range.location + replacement.length, length: 0))
setSelectedRange(NSRange(location: hiddenBoundary(from: caret.location, forward: true), length: 0))
}
@@ -538,16 +537,18 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
checkbox.setAccessibilityLabel(title.isEmpty ? "Task" : title)
checkbox.toolTip = title
}
applyListLayout()
applyFormatting()
positionCheckboxes()
}
private func applyListLayout() {
private func applyFormatting() {
guard let storage = textStorage, let layoutManager else { return }
let range = NSRange(location: 0, length: storage.length)
layoutManager.delegate = self
storage.beginEditing()
Self.restoreListLayout(in: storage)
// Publish Markdown and list styles together, never the unindented reset between them.
MarkdownHighlighting.apply(to: self)
let markerFont = NotesAppearance.font
let column = ceil(tasks.reduce(CGFloat(22)) { width, task in
guard !task.attachment.isTask else { return width }