修复 TextFormatter actor 隔离警告

This commit is contained in:
2026-07-15 23:47:47 +08:00
parent 7d49f7d5a4
commit 01ad237af3
+5 -5
View File
@@ -9,7 +9,7 @@ import Foundation
enum TextFormatter { enum TextFormatter {
static func formatLog(_ text: String) -> String { static nonisolated func formatLog(_ text: String) -> String {
var content = text var content = text
content = content.replacingOccurrences(of: "# ", with: "") content = content.replacingOccurrences(of: "# ", with: "")
@@ -31,7 +31,7 @@ enum TextFormatter {
return content return content
} }
static func formatForCloud(_ text: String) -> String { static nonisolated func formatForCloud(_ text: String) -> String {
var content = formatForShortcut(text) var content = formatForShortcut(text)
content = "# " + content content = "# " + content
content = insertEmptyLineAfterFirstLine(content) content = insertEmptyLineAfterFirstLine(content)
@@ -81,7 +81,7 @@ enum TextFormatter {
return content return content
} }
static func formatForNote(_ text: String) -> String { static nonisolated func formatForNote(_ text: String) -> String {
var content = text var content = text
content = content.replacingOccurrences(of: "# ", with: "") content = content.replacingOccurrences(of: "# ", with: "")
content = content.replacingOccurrences(of: "#", with: "") content = content.replacingOccurrences(of: "#", with: "")
@@ -116,13 +116,13 @@ enum TextFormatter {
return result.trimmingCharacters(in: .whitespacesAndNewlines) return result.trimmingCharacters(in: .whitespacesAndNewlines)
} }
static func removeEmptyLines(_ text: String) -> String { static nonisolated func removeEmptyLines(_ text: String) -> String {
let lines = text.components(separatedBy: .newlines) let lines = text.components(separatedBy: .newlines)
let nonEmptyLines = lines.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty } let nonEmptyLines = lines.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
return nonEmptyLines.joined(separator: "\n") return nonEmptyLines.joined(separator: "\n")
} }
static func insertEmptyLineAfterFirstLine(_ text: String) -> String { static nonisolated func insertEmptyLineAfterFirstLine(_ text: String) -> String {
var lines = text.components(separatedBy: .newlines) var lines = text.components(separatedBy: .newlines)
if !lines.isEmpty { if !lines.isEmpty {
lines.insert("", at: 1) lines.insert("", at: 1)