Procházet zdrojové kódy

enhance: don't show diff if there's only blank changes

Tienson Qin před 4 roky
rodič
revize
b86a801514

+ 1 - 1
src/main/frontend/components/diff.cljs

@@ -247,7 +247,7 @@
     [:span.cp__diff-file-header-content.pl-1.font-medium {:style {:word-break "break-word"}}
      (str "File " path " has been modified on the disk.")]]
    [:div.p-4
-    (when (not= disk-content db-content)
+    (when (not= (string/trim disk-content) (string/trim db-content))
       (ui/foldable
        [:span.text-sm.font-medium.ml-1 "Check diff"]
        (fn []

+ 4 - 2
src/main/frontend/handler/events.cljs

@@ -22,7 +22,8 @@
             [datascript.core :as d]
             ["semver" :as semver]
             [clojure.set :as set]
-            [rum.core :as rum]))
+            [rum.core :as rum]
+            [clojure.string :as string]))
 
 ;; TODO: should we move all events here?
 
@@ -156,7 +157,8 @@
 (defmethod handle :file/not-matched-from-disk [[_ path disk-content db-content]]
   (state/clear-edit!)
   (when-let [repo (state/get-current-repo)]
-    (state/set-modal! #(diff/local-file repo path disk-content db-content))))
+    (when (not= (string/trim disk-content) (string/trim db-content))
+      (state/set-modal! #(diff/local-file repo path disk-content db-content)))))
 
 (defmethod handle :modal/display-file-version [[_ path content hash]]
   (state/set-modal! #(git-component/file-specific-version path hash content)))