We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f917276 commit 1048a98Copy full SHA for 1048a98
1 file changed
module/ohMyRime/lang_model.go
@@ -151,13 +151,21 @@ func RemoveLangModel() error {
151
return nil
152
}
153
154
- // 更新 config 中的 patch
155
- config[patchIndex].Value = newPatchSlice
+ if len(newPatchSlice) == 0 {
+ // 如果 patch 为空,则从 config 中移除 patch 字段
156
+ config = append(config[:patchIndex], config[patchIndex+1:]...)
157
+ } else {
158
+ // 更新 config 中的 patch
159
+ config[patchIndex].Value = newPatchSlice
160
+ }
161
162
// 写入文件
- data, err := yaml.Marshal(config)
- if err != nil {
- return err
163
+ var data []byte
164
+ if len(config) > 0 {
165
+ data, err = yaml.Marshal(config)
166
+ if err != nil {
167
+ return err
168
169
170
171
err = os.WriteFile(rimeMintCustomYamlPath, data, 0644)
0 commit comments