Skip to content

Commit 5b4d29c

Browse files
committed
Replace separator: "\n" with whereSeparator: \.isNewline
1 parent 81c3ba9 commit 5b4d29c

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

Core/Sources/PromptToCodeService/OpenAIPromptToCodeService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ extension OpenAIPromptToCodeService {
266266
}
267267

268268
func getCommonLeadingSpaceCount(_ code: String) -> Int {
269-
let lines = code.split(separator: "\n")
269+
let lines = code.split(whereSeparator: \.isNewline)
270270
guard !lines.isEmpty else { return 0 }
271271
var commonCount = Int.max
272272
for line in lines {

Pro

Submodule Pro updated from 09b4e63 to 2022283

Tool/Sources/CodeiumService/CodeiumService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func getXcodeVersion() async throws -> String {
359359
if let data = try outpipe.fileHandleForReading.readToEnd(),
360360
let content = String(data: data, encoding: .utf8)
361361
{
362-
let firstLine = content.split(separator: "\n").first ?? ""
362+
let firstLine = content.split(whereSeparator: \.isNewline).first ?? ""
363363
var version = firstLine.replacingOccurrences(of: "Xcode ", with: "")
364364
if version.isEmpty {
365365
version = "14.0"

Tool/Sources/FocusedCodeFinder/ObjectiveC/ObjectiveCCodeFinder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public class ObjectiveCFocusedCodeFinder: KnownLanguageFocusedCodeFinder<
130130
}
131131
}
132132

133-
prefix = prefix.split(separator: "\n")
133+
prefix = prefix.split(whereSeparator: \.isNewline)
134134
.joined(separator: " ")
135135
.trimmingCharacters(in: .whitespacesAndNewlines)
136136

137-
extra = extra.split(separator: "\n")
137+
extra = extra.split(whereSeparator: \.isNewline)
138138
.joined(separator: " ")
139139
.trimmingCharacters(in: .whitespacesAndNewlines)
140140

Tool/Sources/FocusedCodeFinder/Swift/SwiftFocusedCodeFinder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public class SwiftFocusedCodeFinder: KnownLanguageFocusedCodeFinder<
156156
let type = node.funcKeyword.text
157157
let name = node.identifier.text
158158
let signature = node.signature.trimmedDescription
159-
.split(separator: "\n")
159+
.split(whereSeparator: \.isNewline)
160160
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
161161
.joined(separator: " ")
162162

Tool/Sources/GitIgnoreCheck/GitIgnoreCheck.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public struct DefaultGitIgnoredChecker: GitIgnoredChecker {
8181
environment: [:]
8282
)
8383
return result
84-
.split(separator: "\n")
84+
.split(whereSeparator: \.isNewline)
8585
.map(String.init)
8686
.compactMap(URL.init(fileURLWithPath:))
8787
} catch {

Tool/Sources/WorkspaceSuggestionService/Filespace+SuggestionService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public extension Filespace {
5757
}
5858

5959
let editingLine = lines[cursorPosition.line].dropLast(1) // dropping \n
60-
let suggestionLines = presentingSuggestion.text.split(separator: "\n")
60+
let suggestionLines = presentingSuggestion.text.split(whereSeparator: \.isNewline)
6161
let suggestionFirstLine = suggestionLines.first ?? ""
6262

6363
/// For example:

Tool/Sources/XcodeInspector/SourceEditor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public extension SourceEditor {
129129
}
130130

131131
static func breakLines(_ string: String) -> [String] {
132-
let lines = string.split(separator: "\n", omittingEmptySubsequences: false)
132+
let lines = string.split(whereSeparator: \.isNewline, omittingEmptySubsequences: false)
133133
var all = [String]()
134134
for (index, line) in lines.enumerated() {
135135
if index == lines.endIndex - 1 {

0 commit comments

Comments
 (0)