Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 3848d8d

Browse files
committed
cleanup
1 parent a22b38a commit 3848d8d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/PartialParser.ml

+6-5
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,25 @@ let findCompletable text offset =
149149
Cjsx (Str.split (Str.regexp_string ".") componentName, id) )
150150
| _ -> Cpath parts
151151
in
152+
let suffix i = String.sub text (i + 1) (offset - (i + 1)) in
152153
let rec loop i =
153154
match i < 0 with
154-
| true -> Some (mkPath (String.sub text (i + 1) (offset - (i + 1))))
155+
| true -> Some (mkPath (suffix i))
155156
| false -> (
156157
match text.[i] with
157158
| '>' when i > 0 && text.[i - 1] = '-' ->
158-
let rest = String.sub text (i + 1) (offset - (i + 1)) in
159+
let rest = suffix i in
159160
if isLowercaseIdent rest then loop (i - 2) else Some (mkPath rest)
160161
| '~' ->
161-
let labelPrefix = String.sub text (i + 1) (offset - (i + 1)) in
162+
let labelPrefix = suffix i in
162163
let funPath = findCallFromArgument text (i - 1) in
163164
Some (Clabel (funPath, labelPrefix))
164-
| '@' -> Some (Cdecorator (String.sub text (i + 1) (offset - (i + 1))))
165+
| '@' -> Some (Cdecorator (suffix i))
165166
| 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '.' | '_' -> loop (i - 1)
166167
| _ -> (
167168
match i = offset - 1 with
168169
| true -> None
169-
| false -> Some (mkPath (String.sub text (i + 1) (offset - (i + 1)))) )
170+
| false -> Some (mkPath (suffix i)) )
170171
)
171172
in
172173
if offset > String.length text || offset = 0 then None else loop (offset - 1)

0 commit comments

Comments
 (0)