Compare commits
No commits in common. "cd01d2f8c330c7ce850e6d52a9e8bc8601a20c96" and "93c859a3c4076709fc94cc19c91c87d796a555e2" have entirely different histories.
cd01d2f8c3
...
93c859a3c4
|
@ -2451,7 +2451,6 @@
|
|||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
INFOPLIST_FILE = TuskerUITests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
@ -2805,7 +2804,6 @@
|
|||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
INFOPLIST_FILE = TuskerUITests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
@ -2825,7 +2823,6 @@
|
|||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
INFOPLIST_FILE = TuskerUITests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
@ -2959,8 +2956,8 @@
|
|||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://git.shadowfacts.net/shadowfacts/HTMLStreamer.git";
|
||||
requirement = {
|
||||
kind = upToNextMinorVersion;
|
||||
minimumVersion = 0.1.0;
|
||||
branch = main;
|
||||
kind = branch;
|
||||
};
|
||||
};
|
||||
D63CC700290EC0B8000E19DE /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
|
||||
|
|
|
@ -30,31 +30,20 @@ extension NSAttributedString {
|
|||
extension NSMutableAttributedString {
|
||||
|
||||
func trimLeadingCharactersInSet(_ charSet: CharacterSet) {
|
||||
var end = string.startIndex
|
||||
while end < string.endIndex && charSet.contains(string.unicodeScalars[end]) {
|
||||
end = string.unicodeScalars.index(after: end)
|
||||
}
|
||||
if end > string.startIndex {
|
||||
let length = string.utf16.distance(from: string.startIndex, to: end)
|
||||
replaceCharacters(in: NSRange(location: 0, length: length), with: "")
|
||||
var range = (string as NSString).rangeOfCharacter(from: charSet)
|
||||
|
||||
while range.length != 0 && range.location == 0 {
|
||||
replaceCharacters(in: range, with: "")
|
||||
range = (string as NSString).rangeOfCharacter(from: charSet)
|
||||
}
|
||||
}
|
||||
|
||||
func trimTrailingCharactersInSet(_ charSet: CharacterSet) {
|
||||
if string.isEmpty {
|
||||
return
|
||||
}
|
||||
var start = string.index(before: string.endIndex)
|
||||
while start > string.startIndex && charSet.contains(string.unicodeScalars[start]) {
|
||||
start = string.unicodeScalars.index(before: start)
|
||||
}
|
||||
if start < string.endIndex {
|
||||
if start != string.startIndex || !charSet.contains(string.unicodeScalars[start]) {
|
||||
start = string.unicodeScalars.index(after: start)
|
||||
}
|
||||
let location = string.utf16.distance(from: string.startIndex, to: start)
|
||||
let length = string.utf16.distance(from: start, to: string.endIndex)
|
||||
replaceCharacters(in: NSRange(location: location, length: length), with: "")
|
||||
var range = (string as NSString).rangeOfCharacter(from: charSet, options: .backwards)
|
||||
|
||||
while range.length != 0 && range.length + range.location == length {
|
||||
replaceCharacters(in: range, with: "")
|
||||
range = (string as NSString).rangeOfCharacter(from: charSet, options: .backwards)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ extension HTMLConverter {
|
|||
if clazz == "invisible" {
|
||||
return .skip
|
||||
} else if clazz == "ellipsis" {
|
||||
return .append("…")
|
||||
return .replace("…")
|
||||
} else {
|
||||
return .default
|
||||
}
|
||||
|
|
|
@ -388,11 +388,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
|
||||
let html = translation?.content ?? status.content
|
||||
let attributedContent = ConversationMainStatusCollectionViewCell.htmlConverter.convert(html)
|
||||
let collapsedContent = NSMutableAttributedString(attributedString: attributedContent)
|
||||
collapsedContent.collapseWhitespace()
|
||||
collapsedContent.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
||||
collapsedContent.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
||||
doUpdateUI(status: status, content: collapsedContent)
|
||||
doUpdateUI(status: status, content: attributedContent)
|
||||
|
||||
if !status.spoilerText.isEmpty,
|
||||
let translated = translation?.spoilerText {
|
||||
|
|
|
@ -616,11 +616,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
}
|
||||
|
||||
let content = precomputedContent ?? TimelineStatusCollectionViewCell.htmlConverter.convert(status.content)
|
||||
let collapsedContent = NSMutableAttributedString(attributedString: content)
|
||||
collapsedContent.collapseWhitespace()
|
||||
collapsedContent.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
||||
collapsedContent.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
||||
doUpdateUI(status: status, content: collapsedContent)
|
||||
doUpdateUI(status: status, content: content)
|
||||
|
||||
doUpdateTimestamp(status: status)
|
||||
timestampLabel.isHidden = showPinned
|
||||
|
|
|
@ -16,36 +16,6 @@ class AttributedStringHelperTests: XCTestCase {
|
|||
|
||||
override func tearDown() {
|
||||
}
|
||||
|
||||
func testTrimLeading() {
|
||||
let a = NSMutableAttributedString(string: " a ")
|
||||
a.trimLeadingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(a, NSAttributedString(string: "a "))
|
||||
let b = NSMutableAttributedString(string: " ")
|
||||
b.trimLeadingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(b, NSAttributedString(string: ""))
|
||||
let c = NSMutableAttributedString(string: "")
|
||||
c.trimLeadingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(c, NSAttributedString(string: ""))
|
||||
let d = NSMutableAttributedString(string: "abc")
|
||||
d.trimLeadingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(d, NSAttributedString(string: "abc"))
|
||||
}
|
||||
|
||||
func testTrimTrailing() {
|
||||
let a = NSMutableAttributedString(string: " a ")
|
||||
a.trimTrailingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(a, NSAttributedString(string: " a"))
|
||||
let b = NSMutableAttributedString(string: " ")
|
||||
b.trimTrailingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(b, NSAttributedString(string: ""))
|
||||
let c = NSMutableAttributedString(string: "")
|
||||
c.trimTrailingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(c, NSAttributedString(string: ""))
|
||||
let d = NSMutableAttributedString(string: "abc")
|
||||
d.trimTrailingCharactersInSet(.whitespaces)
|
||||
XCTAssertEqual(d, NSAttributedString(string: "abc"))
|
||||
}
|
||||
|
||||
func testCollapsingWhitespace() {
|
||||
var str = NSAttributedString(string: "test 1\n")
|
||||
|
|
Loading…
Reference in New Issue