Quellcode durchsuchen

fix: delete at end concats wrong blocks

related to https://github.com/logseq/db-test/issues/347
Tienson Qin vor 6 Monaten
Ursprung
Commit
19513d3ecb

+ 1 - 0
clj-e2e/src/logseq/e2e/keyboard.clj

@@ -8,6 +8,7 @@
 (def enter #(press "Enter"))
 (def enter #(press "Enter"))
 (def esc #(press "Escape"))
 (def esc #(press "Escape"))
 (def backspace #(press "Backspace"))
 (def backspace #(press "Backspace"))
+(def delete #(press "Delete"))
 (def tab #(press "Tab"))
 (def tab #(press "Tab"))
 (def shift+tab #(press "Shift+Tab"))
 (def shift+tab #(press "Shift+Tab"))
 (def shift+enter #(press "Shift+Enter"))
 (def shift+enter #(press "Shift+Enter"))

+ 11 - 0
clj-e2e/test/logseq/e2e/outliner_basic_test.clj

@@ -65,6 +65,14 @@
     (is (= "b1" (util/get-edit-content)))
     (is (= "b1" (util/get-edit-content)))
     (is (= 1 (util/page-blocks-count)))))
     (is (= 1 (util/page-blocks-count)))))
 
 
+(defn delete-end []
+  (testing "Delete at end"
+    (b/new-blocks ["b1" "b2" "b3"])
+    (k/arrow-up)
+    (k/delete)
+    (is (= "b2b3" (util/get-edit-content)))
+    (is (= 2 (util/page-blocks-count)))))
+
 (defn delete-test-with-children []
 (defn delete-test-with-children []
   (testing "Delete block with its children"
   (testing "Delete block with its children"
     (b/new-blocks ["b1" "b2" "b3" "b4"])
     (b/new-blocks ["b1" "b2" "b3" "b4"])
@@ -88,5 +96,8 @@
 (deftest delete-test
 (deftest delete-test
   (delete))
   (delete))
 
 
+(deftest delete-end-test
+  (delete-end))
+
 (deftest delete-test-with-children-test
 (deftest delete-test-with-children-test
   (delete-test-with-children))
   (delete-test-with-children))

+ 4 - 1
src/main/frontend/handler/editor.cljs

@@ -2762,7 +2762,10 @@
       (let [repo (state/get-current-repo)
       (let [repo (state/get-current-repo)
             editor-state (assoc (get-state)
             editor-state (assoc (get-state)
                                 :block-id (:block/uuid next-block)
                                 :block-id (:block/uuid next-block)
-                                :value (:block/title next-block))]
+                                :value (:block/title next-block)
+                                :block-container (util/get-next-block-non-collapsed
+                                                  (util/rec-get-node (state/get-input) "ls-block")
+                                                  {:exclude-property? true}))]
         (delete-block-inner! repo editor-state)))))
         (delete-block-inner! repo editor-state)))))
 
 
 (defn keydown-delete-handler
 (defn keydown-delete-handler