Turn on strict memory safety for the macOS app
This commit is contained in:
@@ -112,7 +112,7 @@ struct InlineRenderer {
|
||||
private func run(_ s: String, _ style: Style) -> AttributedString {
|
||||
var a = AttributedString(s)
|
||||
a.font = Fonts.font(style.small ? 11 : size, weight: style.bold ? 700 : 400, italic: style.italic)
|
||||
a.appKit.font = Fonts.ns(style.small ? 11 : size, weight: style.bold ? 700 : 400, italic: style.italic)
|
||||
a.mergeAttributes(try! AttributeContainer([.font: Fonts.ns(style.small ? 11 : size, weight: style.bold ? 700 : 400, italic: style.italic)], including: \.appKit))
|
||||
if let link = style.link {
|
||||
a.link = link
|
||||
}
|
||||
@@ -364,7 +364,7 @@ private struct FlowBuilder {
|
||||
s.append(NSAttributedString(string: "\n", attributes: [.font: Fonts.ns(ctx.size)]))
|
||||
let all = NSRange(location: 0, length: s.length)
|
||||
let color = NSColor(ctx.color)
|
||||
s.enumerateAttribute(.foregroundColor, in: all) { value, range, _ in
|
||||
unsafe s.enumerateAttribute(.foregroundColor, in: all) { value, range, _ in
|
||||
if value == nil {
|
||||
s.addAttribute(.foregroundColor, value: color, range: range)
|
||||
}
|
||||
@@ -405,8 +405,8 @@ private struct FlowText: NSViewRepresentable {
|
||||
v.isVerticallyResizable = false
|
||||
v.isHorizontallyResizable = false
|
||||
v.textContainerInset = .zero
|
||||
v.textContainer!.lineFragmentPadding = 0
|
||||
v.textContainer!.widthTracksTextView = true
|
||||
unsafe v.textContainer!.lineFragmentPadding = 0
|
||||
unsafe v.textContainer!.widthTracksTextView = true
|
||||
v.linkTextAttributes = [.cursor: NSCursor.pointingHand]
|
||||
v.delegate = context.coordinator
|
||||
return v
|
||||
@@ -414,11 +414,11 @@ private struct FlowText: NSViewRepresentable {
|
||||
|
||||
func updateNSView(_ v: FlowTextView, context: Context) {
|
||||
context.coordinator.openURL = context.environment.openURL
|
||||
if v.textStorage!.isEqual(to: text) {
|
||||
if unsafe v.textStorage!.isEqual(to: text) {
|
||||
return
|
||||
}
|
||||
let selected = v.selectedRanges
|
||||
v.textStorage!.setAttributedString(text)
|
||||
unsafe v.textStorage!.setAttributedString(text)
|
||||
if selected.allSatisfy({ NSMaxRange($0.rangeValue) <= text.length }) {
|
||||
v.selectedRanges = selected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user