From e297a53eb2f35aff00e4cde1010580e10be47abb Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 6 Nov 2020 17:03:20 -0800 Subject: [PATCH] Fix out-of-index crash by guarding against a 0-length string. --- Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift b/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift index de75fc46e..82f49370a 100644 --- a/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift +++ b/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift @@ -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