Skip to content

Commit 5552a0f

Browse files
author
ndr
committed
Refactor form-checker
Uses the new token and form detection to return useful information from a wider range of relative cursor positions.
1 parent a1c3dea commit 5552a0f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lt/plugins/typedclojure.cljs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,12 @@
210210
(let [e (pool/last-active)
211211
c (ed/->cursor e)
212212
token (if (ed/selection? e)
213-
(ed/selection e)
214-
(:string (ed/->token e c)))]
215-
(object/raise e
216-
:eval.custom
217-
(check-form token)
218-
{:result-type :inline :verbatim true})))})
213+
{:string (ed/selection e) :selection true}
214+
(->token* e c))]
215+
(cond
216+
(or (:boundary token)
217+
(:whitespace token)) (let [[start end] (par/form-boundary e (:at token) nil)
218+
form (ed/range e start (ed/adjust-loc end 1))]
219+
(raise* e (check-form form) :res :inline))
220+
(:orphan token) (notifos/set-msg! "core.typed can only check vars or forms")
221+
:else (raise* e (check-form (:string token)) :res :inline))))})

0 commit comments

Comments
 (0)