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 {
|
||||
|
||||
guard attributedString.length > 0 else {
|
||||
return TextFieldSizeInfo(size: NSSize.zero, numberOfLinesUsed: 0)
|
||||
}
|
||||
|
||||
// Assumes the same font family/size for the whole string
|
||||
let font = attributedString.attribute(.font, at: 0, effectiveRange: nil) as! NSFont
|
||||
|
||||
|
|
Loading…
Reference in New Issue