fix: batch note formatting to prevent typing flashes
This commit is contained in:
@@ -274,8 +274,6 @@ final class NotesController: NSViewController, NSTextViewDelegate {
|
||||
|
||||
func textDidChange(_ notification: Notification) {
|
||||
isDirty = true
|
||||
MarkdownHighlighting.apply(to: editor)
|
||||
editor.refreshTasks()
|
||||
_ = save()
|
||||
}
|
||||
|
||||
@@ -581,8 +579,6 @@ final class NotesController: NSViewController, NSTextViewDelegate {
|
||||
editor.undoManager?.removeAllActions()
|
||||
editor.isEditable = true
|
||||
editor.setSelectedRange(NSRange(location: editor.string.utf16.count, length: 0))
|
||||
MarkdownHighlighting.apply(to: editor)
|
||||
editor.refreshTasks()
|
||||
noteTitle.stringValue = note.title
|
||||
status.isHidden = true
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user