浏览代码

Extract WordLimit into its own file to fix Xcode scope resolution.

Moving the enum out of the String extension file restores reliable indexing and clears the WordLimit compile errors across ViewModels.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 月之前
父节点
当前提交
6199d7d4ec
共有 2 个文件被更改,包括 22 次插入21 次删除
  1. 0 21
      gramora/Utilities/String+WordCount.swift
  2. 22 0
      gramora/Utilities/WordLimit.swift

+ 0 - 21
gramora/Utilities/String+WordCount.swift

@@ -1,26 +1,5 @@
 import Foundation
 
-enum WordLimit {
-    static func message(maxWords: Int) -> String {
-        "Maximum \(maxWords) words allowed."
-    }
-
-    static func apply(_ text: String, maxWords: Int) -> (text: String, exceeded: Bool) {
-        guard text.wordCount > maxWords else { return (text, false) }
-        return (text.truncated(toMaxWords: maxWords), true)
-    }
-
-    static func applyImported(
-        _ text: String,
-        maxWords: Int,
-        setError: (String?) -> Void
-    ) -> String {
-        let (limited, exceeded) = apply(text, maxWords: maxWords)
-        setError(exceeded ? message(maxWords: maxWords) : nil)
-        return limited
-    }
-}
-
 extension String {
     var wordCount: Int {
         let trimmed = trimmingCharacters(in: .whitespacesAndNewlines)

+ 22 - 0
gramora/Utilities/WordLimit.swift

@@ -0,0 +1,22 @@
+import Foundation
+
+enum WordLimit {
+    static func message(maxWords: Int) -> String {
+        "Maximum \(maxWords) words allowed."
+    }
+
+    static func apply(_ text: String, maxWords: Int) -> (text: String, exceeded: Bool) {
+        guard text.wordCount > maxWords else { return (text, false) }
+        return (text.truncated(toMaxWords: maxWords), true)
+    }
+
+    static func applyImported(
+        _ text: String,
+        maxWords: Int,
+        setError: (String?) -> Void
+    ) -> String {
+        let (limited, exceeded) = apply(text, maxWords: maxWords)
+        setError(exceeded ? message(maxWords: maxWords) : nil)
+        return limited
+    }
+}