Skip to content

Commit

Permalink
🐛 过早优化万恶之源
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed Oct 1, 2022
1 parent bef90e5 commit f841292
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Mac/View/EditTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ class EditTextView: NSTextView, NSTextFinderClient {
override func drawInsertionPoint(in rect: NSRect, color: NSColor, turnedOn flag: Bool) {
var newRect = NSRect(origin: rect.origin, size: rect.size)
newRect.size.width = caretWidth
var diff = 4.0
if let range = getParagraphRange(), range.upperBound != textStorage?.length || (
range.upperBound == textStorage?.length
&& textStorage?.string.last == "\n"
&& selectedRange().location != textStorage?.length
) {
newRect.size.height = newRect.size.height - 6.0
newRect.origin.y = newRect.origin.y + 4.0
} else {
newRect.size.height = newRect.size.height - 4.0
newRect.origin.y = newRect.origin.y + 4.0
diff = 6.0
}

newRect.size.height = newRect.size.height - diff
newRect.origin.y = newRect.origin.y + 4.0

super.drawInsertionPoint(in: newRect, color: EditTextView.fontColor, turnedOn: flag)
}

Expand Down
25 changes: 13 additions & 12 deletions Mac/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ class ViewController:
editArea.isEditable = false

editArea.layoutManager?.defaultAttachmentScaling = .scaleProportionallyDown
editArea.layoutManager?.typesetterBehavior = .behavior_10_2_WithCompatibility

if UserDefaultsManagement.fontName != "LXGW WenKai Lite" {
editArea.layoutManager?.typesetterBehavior = .behavior_10_2_WithCompatibility
}
search.font = UserDefaultsManagement.searchFont
editArea.font = UserDefaultsManagement.noteFont
titleLabel.font = UserDefaultsManagement.titleFont.titleBold()
Expand Down Expand Up @@ -1799,17 +1800,17 @@ class ViewController:

return !note.name.isEmpty
&& (filter.isEmpty || isMatched(note: note, terms: terms!)
) && (
type == .All && note.project.showInCommon
|| (
type != .All && projects!.contains(note.project)
|| (note.project.parent != nil && projects!.contains(note.project.parent!))
) && (
type == .All && note.project.showInCommon
|| (
type != .All && projects!.contains(note.project)
|| (note.project.parent != nil && projects!.contains(note.project.parent!))
)
|| type == .Trash
) && (
type == .Trash && note.isTrash()
|| type != .Trash && !note.isTrash()
)
|| type == .Trash
) && (
type == .Trash && note.isTrash()
|| type != .Trash && !note.isTrash()
)
}

public func contains(tag name: String, in tags: [String]) -> Bool {
Expand Down

0 comments on commit f841292

Please sign in to comment.