fix(editor): wrong file editing save condition

This commit is contained in:
Andelf
2023-03-16 13:33:13 +08:00
parent 7737053ce1
commit 3338263088

View File

@@ -44,10 +44,13 @@
rpath (path/trim-dir-prefix repo-dir path)]
(if rpath
;; in-db file
(let [old-content (or (db/get-file rpath) "")]
(when (and
(not (string/blank? value))
(not= (string/trim value) (string/trim old-content)))
(let [db-content (db/get-file rpath)
not-in-db? (nil? db-content)
old-content (or db-content "")
contents-matched? (= (string/trim value) (string/trim old-content))]
(when (or
(and not-in-db? (not-empty value))
(not contents-matched?))
(file-handler/alter-file (state/get-current-repo)
rpath
(str (string/trim value) "\n")