Skip to content

Commit fbc2144

Browse files
committed
Recover line endings
1 parent bfc748a commit fbc2144

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Tool/Sources/XcodeInspector/SourceEditor.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ public extension SourceEditor {
129129
}
130130

131131
static func breakLines(_ string: String) -> [String] {
132-
let lines = string.split(whereSeparator: \.isNewline, omittingEmptySubsequences: false)
132+
let lineEnding = string.first(where: \.isNewline) ?? "\n"
133+
let lines = string.split(omittingEmptySubsequences: false, whereSeparator: \.isNewline)
133134
var all = [String]()
134135
for (index, line) in lines.enumerated() {
135136
if index == lines.endIndex - 1 {
136137
all.append(String(line))
137138
} else {
138-
all.append(String(line) + "\n")
139+
all.append(String(line) + String(lineEnding))
139140
}
140141
}
141142
return all

0 commit comments

Comments
 (0)