File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Sources/SwiftFormat/Rules
Tests/SwiftFormatTests/Rules Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,14 @@ public final class BeginDocumentationCommentWithOneLineSummary: SyntaxLintRule {
130130 in: text. startIndex..< text. endIndex,
131131 scheme: NSLinguisticTagScheme . lexicalClass. rawValue,
132132 tokenRanges: & tokenRanges)
133+ var isInsideQuotes = false
133134 let sentenceTerminatorIndices = tags. enumerated ( ) . filter {
134- $0. element == " SentenceTerminator "
135+ if $0. element == " OpenQuote " {
136+ isInsideQuotes = true
137+ } else if $0. element == " CloseQuote " {
138+ isInsideQuotes = false
139+ }
140+ return !isInsideQuotes && $0. element == " SentenceTerminator "
135141 } . map {
136142 tokenRanges [ $0. offset] . lowerBound
137143 }
Original file line number Diff line number Diff line change @@ -139,4 +139,24 @@ final class BeginDocumentationCommentWithOneLineSummaryTests: LintOrFormatRuleTe
139139 )
140140 #endif
141141 }
142+
143+ func testSentenceTerminationInsideQuotes( ) {
144+ assertLint (
145+ BeginDocumentationCommentWithOneLineSummary . self,
146+ """
147+ /// Creates an instance with the same raw value as `x` failing iff `x.kind != Subject.kind`.
148+ struct TestBackTick {}
149+
150+ /// A set of `Diagnostic` that can answer the question 'was there an error?' in O(1).
151+ struct TestSingleQuotes {}
152+
153+ /// A set of `Diagnostic` that can answer the question “was there an error?” in O(1).
154+ struct TestDoubleQuotes {}
155+
156+ /// A set of `Diagnostic` that can answer the question “was there
157+ /// an error?” in O(1).
158+ struct TestTwoLinesDoubleQuotes {}
159+ """
160+ )
161+ }
142162}
You can’t perform that action at this time.
0 commit comments