Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Rules/Acronyms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension FormatRule {
for replaceCandidateRange in token.string.ranges(of: find) {
let acronymShouldBeCapitalized: Bool

if replaceCandidateRange.upperBound < token.string.indices.last! {
if replaceCandidateRange.upperBound <= token.string.indices.last! {
let indexAfterMatch = replaceCandidateRange.upperBound
let characterAfterMatch = token.string[indexAfterMatch]

Expand Down
16 changes: 16 additions & 0 deletions Tests/Rules/AcronymsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,20 @@ class AcronymsTests: XCTestCase {
let options = FormatOptions(preserveAcronyms: ["externallyProvidedUrl", "toUrl"])
testFormatting(for: input, output, rule: .acronyms, options: options)
}

func testAcronymMatchesPartOfOtherWordAtEndOfIdentifier() {
let input = """
struct MasKit {}
struct Mask {}
struct MaskView {}
"""

let output = """
struct MASKit {}
struct Mask {}
struct MaskView {}
"""

testFormatting(for: input, output, rule: .acronyms, options: FormatOptions(acronyms: ["MAS"]))
}
}
Loading