File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Sources/_StringProcessing/Unicode Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,10 @@ extension String {
87
87
var j = maxIndex ?? range. lowerBound
88
88
89
89
while j < range. upperBound, j <= i {
90
- cache!. insert ( j)
90
+ // Workaround for underlying issue in https://github.com/swiftlang/swift-experimental-string-processing/issues/818
91
+ let ( inserted, _) = cache!. insert ( j)
92
+ guard inserted else { return true }
93
+
91
94
j = _wordIndex ( after: j)
92
95
}
93
96
Original file line number Diff line number Diff line change @@ -1946,6 +1946,22 @@ extension RegexDSLTests {
1946
1946
XCTAssertEqual ( anyOutput [ 15 ] . value as? Int , 123 )
1947
1947
XCTAssertEqual ( anyOutput [ 16 ] . substring, " 456 " )
1948
1948
}
1949
+
1950
+ func testIssue818( ) throws {
1951
+ // Original report from https://github.com/swiftlang/swift-experimental-string-processing/issues/818
1952
+ let clip = " ‘example.com’ "
1953
+ let clip2 = " \u{2060} \u{2018} \u{2060} \u{2060} example.com \u{2060} \u{2060} \u{2019} "
1954
+ assert ( clip. unicodeScalars. elementsEqual ( clip2. unicodeScalars) )
1955
+
1956
+ let pattern = Regex {
1957
+ Anchor . wordBoundary // line A
1958
+ " example "
1959
+ Anchor . wordBoundary // line B
1960
+ }
1961
+
1962
+ XCTAssertNotNil ( clip. contains ( pattern) )
1963
+ XCTAssertNotNil ( clip2. contains ( pattern) )
1964
+ }
1949
1965
}
1950
1966
1951
1967
extension Unicode . Scalar {
You can’t perform that action at this time.
0 commit comments