Skip to content

Commit

Permalink
[ASTextNode] Fix locking, add test for issue #trivial (#825)
Browse files Browse the repository at this point in the history
* A few small fixes plus a failing test for ASTextNode

* Change the approach

* Update changelog

* Eh screw null_resettable

* No need for changelog now
  • Loading branch information
Adlai-Holler authored Mar 9, 2018
1 parent f99dd68 commit 6f1d2d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ @implementation ASTextNode {
NSArray *_exclusionPaths;

NSAttributedString *_attributedText;
NSAttributedString *_truncationAttributedText;
NSAttributedString *_composedTruncationText;

NSString *_highlightedLinkAttributeName;
Expand Down Expand Up @@ -1189,6 +1190,12 @@ - (UIEdgeInsets)shadowPadding
return defaultTruncationAttributedString;
}

- (NSAttributedString *)truncationAttributedText
{
ASDN::MutexLocker l(__instanceLock__);
return _truncationAttributedText;
}

- (void)setTruncationAttributedText:(NSAttributedString *)truncationAttributedText
{
{
Expand Down
17 changes: 17 additions & 0 deletions Tests/ASTextNodeSnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,21 @@ - (void)testShadowing
ASSnapshotVerifyNode(textNode, nil);
}

/**
* https://github.com/TextureGroup/Texture/issues/822
*/
- (void)DISABLED_testThatTruncationTokenAttributesPrecedeThoseInheritedFromTextWhenTruncateTailMode
{
ASTextNode *textNode = [[ASTextNode alloc] init];
textNode.style.maxSize = CGSizeMake(20, 80);
NSMutableAttributedString *mas = [[NSMutableAttributedString alloc] initWithString:@"Quality is an important "];
[mas appendAttributedString:[[NSAttributedString alloc] initWithString:@"thing" attributes:@{ NSBackgroundColorAttributeName : UIColor.yellowColor}]];
textNode.attributedText = mas;
textNode.truncationMode = NSLineBreakByTruncatingTail;

textNode.truncationAttributedText = [[NSAttributedString alloc] initWithString:@"\u2026" attributes:@{ NSBackgroundColorAttributeName: UIColor.greenColor }];
ASDisplayNodeSizeToFitSizeRange(textNode, ASSizeRangeMake(CGSizeZero, CGSizeMake(INFINITY, INFINITY)));
ASSnapshotVerifyNode(textNode, nil);
}

@end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6f1d2d1

Please sign in to comment.