Don't drop multisym delimiters at the end of a symbol
added a test for completions
This commit is contained in:
parent
2b79a0955f
commit
1061db98d0
@ -165,9 +165,13 @@ These functions are all pure functions, which makes me happy."
|
||||
(let [offset (or ?offset (length symbol))
|
||||
next-separator (or (symbol:find ".[.:]" offset)
|
||||
(length symbol))
|
||||
symbol (symbol:sub 1 next-separator)]
|
||||
(icollect [word (: (.. symbol ".") :gmatch "(.-)[.:]")]
|
||||
word))))
|
||||
symbol (symbol:sub 1 next-separator)
|
||||
parts (icollect [word (symbol:gmatch "[^.:]+")]
|
||||
word)]
|
||||
(if (symbol:match "[.:]+$")
|
||||
(tset parts (length parts)
|
||||
(.. (. parts (length parts)) (symbol:match "[.:]+$"))))
|
||||
parts)))
|
||||
|
||||
(fn multi-sym-base [symbol]
|
||||
(local symbol (tostring symbol))
|
||||
|
||||
@ -282,6 +282,15 @@
|
||||
; [:os])
|
||||
nil)
|
||||
|
||||
;; ensure that we get completions for both the symbol and the table fields
|
||||
(fn test-sym-ending-in-delimiter []
|
||||
(check "(local a {:b 1 :c 2})
|
||||
(local a. 3)
|
||||
(set a.|"
|
||||
["a." "a.b" "a.c"]
|
||||
[])
|
||||
nil)
|
||||
|
||||
;; ;; Future tests / features
|
||||
;; ;; Scope Ordering Rules
|
||||
;; (it "does not suggest locals past the suggestion location when a symbol is partially typed")
|
||||
@ -308,4 +317,5 @@
|
||||
: test-module
|
||||
: test-destructure
|
||||
: test-no-completion
|
||||
: test-compiler-env}
|
||||
: test-compiler-env
|
||||
: test-sym-ending-in-delimiter}
|
||||
|
||||
@ -14,6 +14,11 @@
|
||||
(faith.= ["is" "equal"] (utils.multi-sym-split "is.equal" 5))
|
||||
(faith.= ["a" "b" "c" "d" "e" "f"] (utils.multi-sym-split "a.b.c.d.e.f"))
|
||||
(faith.= ["obj" "bar"] (utils.multi-sym-split (fennel.sym "obj.bar")))
|
||||
(faith.= ["a."] (utils.multi-sym-split (fennel.sym "a.")))
|
||||
(faith.= [".."] (utils.multi-sym-split (fennel.sym "..")))
|
||||
(faith.= ["?."] (utils.multi-sym-split (fennel.sym "?.")))
|
||||
(faith.= ["b:"] (utils.multi-sym-split (fennel.sym "b:")))
|
||||
(faith.= ["b" "a."] (utils.multi-sym-split (fennel.sym "b:a.")))
|
||||
nil)
|
||||
|
||||
(fn test-find-symbol []
|
||||
@ -34,6 +39,11 @@
|
||||
"[[1 2 sym-one] (match [1 2 4] [1 2 sym-one] sym-one) [(match [1 2 4] [1 2 sym-one] sym-one)]]"
|
||||
(fennel.view parents {:one-line? true})
|
||||
"bad parents"))
|
||||
|
||||
(let [{: server : uri} (create-client "(local a. 1) (print a.)")
|
||||
file (. server.files uri)
|
||||
[symbol _parents] [(analyzer.find-symbol server file 21)]]
|
||||
(faith.= symbol (fennel.sym "a.")))
|
||||
nil)
|
||||
|
||||
(fn test-failure []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user