Repository: CodeEditApp/CodeEdit
File: CodeEdit/Features/Search/Views/QuickSearchResultLabel.swift (Swift)

Code before:
/// Highlights currently entered text query
struct QuickSearchResultLabel: NSViewRepresentable {
    let labelName: String
    let charactersToHighlight: [NSRange]
    var nsLabelName: NSAttributedString?

    public func makeNSView(context: Context) -> some NSTextField {
        let label = NSTextField(wrappingLabelWithString: labelName)
        label.translatesAutoresizingMaskIntoConstraints = false
        label.drawsBackground = false
        label.textColor = .labelColor
        label.isEditable = false
        label.isSelectable = false
        label.font = .labelFont(ofSize: 13)
        label.allowsDefaultTighteningForTruncation = false
        label.cell?.truncatesLastVisibleLine = true
        label.cell?.wraps = true
        label.maximumNumberOfLines = 1
        label.attributedStringValue = nsLabelName ?? highlight()
        return label
    }

    func highlight() -> NSAttributedString {
        let attribText = NSMutableAttributedString(string: self.labelName)
        for range in charactersToHighlight {
            attribText.addAttribute(.foregroundColor, value: NSColor(Color(.labelColor)), range: range)
            attribText.addAttribute(.font, value: NSFont.boldSystemFont(ofSize: NSFont.systemFontSize), range: range)
        }
        return attribText
    }

    func updateNSView(_ nsView: NSViewType, context: Context) {
        nsView.textColor = nsLabelName == nil && charactersToHighlight.isEmpty ? .labelColor : .secondaryLabelColor
        nsView.attributedStringValue = nsLabelName ?? highlight()
    }
}


Review comment (suggestion):
```suggestion
            attribText.addAttribute(.foregroundColor, value: NSColor.controlTextColor, range: range)
```

Code after:
/// Highlights currently entered text query
struct QuickSearchResultLabel: NSViewRepresentable {
    let labelName: String
    let charactersToHighlight: [NSRange]
    var nsLabelName: NSAttributedString?

    public func makeNSView(context: Context) -> some NSTextField {
        let label = NSTextField(wrappingLabelWithString: labelName)
        label.translatesAutoresizingMaskIntoConstraints = false
        label.drawsBackground = false
        label.textColor = .labelColor
        label.isEditable = false
        label.isSelectable = false
        label.font = .labelFont(ofSize: 13)
        label.allowsDefaultTighteningForTruncation = false
        label.cell?.truncatesLastVisibleLine = true
        label.cell?.wraps = true
        label.maximumNumberOfLines = 1
        label.attributedStringValue = nsLabelName ?? highlight()
        return label
    }

    func highlight() -> NSAttributedString {
        let attribText = NSMutableAttributedString(string: self.labelName)
        for range in charactersToHighlight {
            attribText.addAttribute(.foregroundColor, value: NSColor.controlTextColor, range: range)
            attribText.addAttribute(.font, value: NSFont.boldSystemFont(ofSize: NSFont.systemFontSize), range: range)
        }
        return attribText
    }

    func updateNSView(_ nsView: NSViewType, context: Context) {
        nsView.textColor = if nsLabelName == nil && charactersToHighlight.isEmpty {
            .controlTextColor
        } else {
            .secondaryLabelColor
        }
        nsView.attributedStringValue = nsLabelName ?? highlight()
    }
}