Skip to content

Commit

Permalink
✨ 增强输入的性能移除格式变化
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Jul 12, 2023
1 parent 7807c51 commit 72b7064
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions Mac/View/EditTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class EditTextView: NSTextView, NSTextFinderClient {
override func becomeFirstResponder() -> Bool {
let shouldBecomeFirstResponder = super.becomeFirstResponder()
if shouldBecomeFirstResponder && string.isEmpty {
DispatchQueue.main.async {
self.applyParagraphStyle()
}
let paragraphStyle = NSTextStorage.getParagraphStyle()
typingAttributes[.paragraphStyle] = paragraphStyle
defaultParagraphStyle = paragraphStyle
}

return shouldBecomeFirstResponder
Expand All @@ -63,7 +63,6 @@ class EditTextView: NSTextView, NSTextFinderClient {
super.updateInsertionPointStateAndRestartTimer(true)
if let range = selectedRanges[0] as? NSRange, range.length > 0, range != initRange {
DispatchQueue.main.async {
self.textStorage?.updateParagraphStyle()
self.initRange = range
}
}
Expand Down Expand Up @@ -99,7 +98,6 @@ class EditTextView: NSTextView, NSTextFinderClient {

if initRange.length > 0 {
DispatchQueue.main.async {
self.textStorage?.updateParagraphStyle()
self.initRange = NSRange(location: 0, length: 0)
}
}
Expand Down Expand Up @@ -239,7 +237,6 @@ class EditTextView: NSTextView, NSTextFinderClient {
breakUndoCoalescing()
saveTextStorageContent(to: note)
fillHighlightLinks()
textStorage?.updateParagraphStyle()
return
}

Expand Down Expand Up @@ -397,8 +394,8 @@ class EditTextView: NSTextView, NSTextFinderClient {

undoManager?.removeAllActions(withTarget: self)

if let appd = NSApplication.shared.delegate as? AppDelegate,
let md = appd.mainWindowController {
if let appDelegate = NSApplication.shared.delegate as? AppDelegate,
let md = appDelegate.mainWindowController {
md.editorUndoManager = note.undoManager
}

Expand Down Expand Up @@ -800,7 +797,6 @@ class EditTextView: NSTextView, NSTextFinderClient {
NotesTextProcessor.highlightMarkdown(attributedString: storage, note: note)
saveTextStorageContent(to: note)
note.save()
textStorage?.updateParagraphStyle()
}
viewDelegate?.notesTableView.reloadRow(note: note)

Expand Down Expand Up @@ -992,13 +988,6 @@ class EditTextView: NSTextView, NSTextFinderClient {
NSWorkspace.shared.open(url)
}

public func applyParagraphStyle() {
let paragraphStyle = NSTextStorage.getParagraphStyle()
typingAttributes[.paragraphStyle] = paragraphStyle
defaultParagraphStyle = paragraphStyle
textStorage?.updateParagraphStyle()
}

override func viewDidChangeEffectiveAppearance() {
guard let note = EditTextView.note else { return }
guard let vc = ViewController.shared() else { return }
Expand Down

0 comments on commit 72b7064

Please sign in to comment.