Преглед на файлове

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
+    }
+}