mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 12:06:58 +01:00
Fix out-of-index crash by guarding against a 0-length string.
This commit is contained in:
parent
69911bd914
commit
e297a53eb2
@ -53,7 +53,10 @@ final class MultilineTextFieldSizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func size(for attributedString: NSAttributedString, numberOfLines: Int, width: Int) -> TextFieldSizeInfo {
|
static func size(for attributedString: NSAttributedString, numberOfLines: Int, width: Int) -> TextFieldSizeInfo {
|
||||||
|
guard attributedString.length > 0 else {
|
||||||
|
return TextFieldSizeInfo(size: NSSize.zero, numberOfLinesUsed: 0)
|
||||||
|
}
|
||||||
|
|
||||||
// Assumes the same font family/size for the whole string
|
// Assumes the same font family/size for the whole string
|
||||||
let font = attributedString.attribute(.font, at: 0, effectiveRange: nil) as! NSFont
|
let font = attributedString.attribute(.font, at: 0, effectiveRange: nil) as! NSFont
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user