Skip to content

Commit

Permalink
reduce calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
LEOYoon-Tsaw committed Jun 3, 2022
1 parent 8e0efb7 commit 5bc46eb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions SquirrelPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ - (NSRect)contentRect {
NSAttributedString *str = [self.text attributedSubstringFromRange:range];
NSRange nonWhiteRange = [str.string rangeOfCharacterFromSet:NSCharacterSet.whitespaceCharacterSet.invertedSet options:NSBackwardsSearch];
if (nonWhiteRange.location != NSNotFound) {
NSRange newRange = NSMakeRange(range.location, nonWhiteRange.location+1);
NSRange actualRange = NSMakeRange(NSNotFound, 0);
[self.text.layoutManagers[0] glyphRangeForCharacterRange:newRange actualCharacterRange:&actualRange];
CGFloat width = [self.text attributedSubstringFromRange:actualRange].size.width;
NSRange newRange = NSMakeRange(range.location, NSMaxRange(nonWhiteRange));
CGFloat width = [self.text attributedSubstringFromRange:newRange].size.width;
if (width > actualWidth) {
actualWidth = width;
}
Expand Down

0 comments on commit 5bc46eb

Please sign in to comment.