fix(editor): incorrect behavior of the delete key for deleting the last char

This commit is contained in:
charlie
2024-04-02 12:56:00 +08:00
committed by Andelf
parent 3fc1560cf5
commit 369b5ece15
2 changed files with 15 additions and 9 deletions

View File

@@ -14,13 +14,17 @@
(is (= 3 (util/safe-dec-current-pos-from-end "abc😀" 5)))
(is (= 0 (util/safe-dec-current-pos-from-end "😀" 2)))
(is (= 4 (util/safe-dec-current-pos-from-end "abcde" 5)))
(is (= 1 (util/safe-dec-current-pos-from-end "中文" 2))))
(is (= 1 (util/safe-dec-current-pos-from-end "中文" 2)))
(is (= 0 (util/safe-dec-current-pos-from-end "中" 1)))
(is (= 0 (util/safe-dec-current-pos-from-end "a" 1))))
(testing "safe current position from start for emoji"
(is (= 5 (util/safe-inc-current-pos-from-start "abc😀d" 3)))
(is (= 2 (util/safe-inc-current-pos-from-start "😀" 0)))
(is (= 2 (util/safe-inc-current-pos-from-start "abcde" 1)))
(is (= 1 (util/safe-inc-current-pos-from-start "中文" 0)))))
(is (= 1 (util/safe-inc-current-pos-from-start "中文" 0)))
(is (= 2 (util/safe-inc-current-pos-from-start "😀" 0)))
(is (= 1 (util/safe-inc-current-pos-from-start "中" 0)))
(is (= 1 (util/safe-inc-current-pos-from-start "a" 0)))))
(deftest test-memoize-last
(testing "memoize-last add test"