Fix command completion firing too often

Only fire at the beginning of a line or when starting a new word
This commit is contained in:
Gabriel Horner
2023-02-07 17:03:04 -05:00
committed by Andelf
parent 9d2055f8b9
commit 475d4ce7d9
2 changed files with 27 additions and 3 deletions

View File

@@ -98,6 +98,24 @@
(is (= nil (state/get-editor-action))
"Don't autocomplete properties if typing in a block where properties already exist"))
(testing "Command autocompletion"
(handle-last-input-handler {:value "/"})
(is (= :commands (state/get-editor-action))
"Command search if only / has been typed")
(handle-last-input-handler {:value "some words /"})
(is (= :commands (state/get-editor-action))
"Command search on start of new word")
(handle-last-input-handler {:value "https://"})
(is (= nil (state/get-editor-action))
"No command search in middle of a word")
(handle-last-input-handler {:value "#blah/"})
(is (= nil (state/get-editor-action))
"No command search after a tag search to allow for namespace completion")
)
(testing "Tag autocompletion"
(handle-last-input-handler {:value "#"
:cursor-pos 1})