File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,29 @@ extension Megrez.Compositor {
6262 return results
6363 }
6464
65+ /// 清除此游標位置所涉及節點的覆寫狀態,可選擇保留使用者明確覆寫過的節點。
66+ /// - Parameters:
67+ /// - location: 要處理的游標位置(會自動夾限於有效鍵長範圍內)。
68+ /// - preservingExplicit: 若為 true,則保留使用者明確覆寫的節點。
69+ public func clearOverrideStatus( at location: Int , preservingExplicit: Bool = true ) {
70+ guard !keys. isEmpty else { return }
71+ let clampedLocation = max ( 0 , min ( location, keys. count - 1 ) )
72+ let overlappingNodes = fetchOverlappingNodes ( at: clampedLocation)
73+ guard !overlappingNodes. isEmpty else { return }
74+ overlappingNodes. forEach { anchor in
75+ guard anchor. node. isOverridden else { return }
76+ if preservingExplicit, anchor. node. isExplicitlyOverridden {
77+ return
78+ }
79+ anchor. node. overrideStatus = . init(
80+ overridingScore: anchor. node. overridingScore,
81+ currentOverrideType: nil ,
82+ isExplicitlyOverridden: false ,
83+ currentUnigramIndex: anchor. node. currentUnigramIndex
84+ )
85+ }
86+ }
87+
6588 /// 要在 fetchOverlappingNodes() 內使用的一個工具函式。
6689 private static func insertAnchor(
6790 segmentIndex location: Int , node: Megrez . Node ,
You can’t perform that action at this time.
0 commit comments