Skip to content

Commit c44ff8b

Browse files
committed
Use stronger type information.
1 parent 5810e07 commit c44ff8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/gyb-swift/Tokenization.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,17 @@ extension StringProtocol {
205205
} else if token.tokenKind == .rightBrace {
206206
nesting -= 1
207207
if nesting < 0 {
208-
return indexFromUTF8Offset(token.positionAfterSkippingLeadingTrivia.utf8Offset)
208+
return index(at: token.positionAfterSkippingLeadingTrivia)
209209
}
210210
}
211211
}
212212

213213
return endIndex
214214
}
215215

216-
/// Converts a UTF-8 byte offset to a `String.Index`.
217-
func indexFromUTF8Offset(_ utf8Offset: Int) -> String.Index {
218-
let utf8Index = utf8.index(utf8.startIndex, offsetBy: utf8Offset)
216+
/// The index at `position`.
217+
func index(at position: AbsolutePosition) -> String.Index {
218+
let utf8Index = utf8.index(utf8.startIndex, offsetBy: position.utf8Offset)
219219
return String.Index(utf8Index, within: self) ?? endIndex
220220
}
221221
}

0 commit comments

Comments
 (0)