Skip to content

Commit

Permalink
Fix out-of-index crash by guarding against a 0-length string.
Browse files Browse the repository at this point in the history
  • Loading branch information
brentsimmons committed Nov 7, 2020
1 parent 69911bd commit e297a53
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e297a53

Please sign in to comment.