修复 TextFormatter actor 隔离警告
This commit is contained in:
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
enum TextFormatter {
|
||||
|
||||
static func formatLog(_ text: String) -> String {
|
||||
static nonisolated func formatLog(_ text: String) -> String {
|
||||
var content = text
|
||||
|
||||
content = content.replacingOccurrences(of: "# ", with: "")
|
||||
@@ -31,7 +31,7 @@ enum TextFormatter {
|
||||
return content
|
||||
}
|
||||
|
||||
static func formatForCloud(_ text: String) -> String {
|
||||
static nonisolated func formatForCloud(_ text: String) -> String {
|
||||
var content = formatForShortcut(text)
|
||||
content = "# " + content
|
||||
content = insertEmptyLineAfterFirstLine(content)
|
||||
@@ -81,7 +81,7 @@ enum TextFormatter {
|
||||
return content
|
||||
}
|
||||
|
||||
static func formatForNote(_ text: String) -> String {
|
||||
static nonisolated func formatForNote(_ text: String) -> String {
|
||||
var content = text
|
||||
content = content.replacingOccurrences(of: "# ", with: "")
|
||||
content = content.replacingOccurrences(of: "#", with: "")
|
||||
@@ -116,13 +116,13 @@ enum TextFormatter {
|
||||
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 nonEmptyLines = lines.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
|
||||
return nonEmptyLines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
static func insertEmptyLineAfterFirstLine(_ text: String) -> String {
|
||||
static nonisolated func insertEmptyLineAfterFirstLine(_ text: String) -> String {
|
||||
var lines = text.components(separatedBy: .newlines)
|
||||
if !lines.isEmpty {
|
||||
lines.insert("", at: 1)
|
||||
|
||||
Reference in New Issue
Block a user