@@ -21,6 +21,18 @@ let rec findBackSkippingCommentsAndStrings text char pair i level =
21
21
loop (findOpenComment text (i - 2 )) level
22
22
| _ -> loop (i - 1 ) level
23
23
24
+ let rec findLineComment text offset =
25
+ if offset < = 0 || text.[offset] = '\n' then None
26
+ else if offset > 0 && text.[offset] = '/' && text.[offset - 1 ] = '/' then
27
+ Some (offset - 1 )
28
+ else findLineComment text (offset - 1 )
29
+
30
+ (* Check if the position is inside a `//` comment *)
31
+ let insideLineComment text offset = findLineComment text offset <> None
32
+
33
+ let skipLineComment text offset =
34
+ match findLineComment text offset with None -> offset | Some n -> n - 1
35
+
24
36
let rec skipWhite text i =
25
37
if i < 0 then 0
26
38
else
@@ -38,6 +50,7 @@ let rec startOfLident text i =
38
50
let findCallFromArgument text offset =
39
51
let none = ([] , [] ) in
40
52
let rec loop identsSeen i =
53
+ let i = skipLineComment text i in
41
54
let i = skipWhite text i in
42
55
if i > 0 then
43
56
match text.[i] with
@@ -244,12 +257,6 @@ let findCompletable text offset =
244
257
in
245
258
if offset > String. length text || offset = 0 then None else loop (offset - 1 )
246
259
247
- (* Check if the position is inside a `//` comment *)
248
- let rec insideLineComment text offset =
249
- if offset < = 0 || text.[offset] = '\n' then false
250
- else if offset > 0 && text.[offset] = '/' && text.[offset - 1 ] = '/' then true
251
- else insideLineComment text (offset - 1 )
252
-
253
260
let findOpens text offset =
254
261
let opens = ref [] in
255
262
let pathOfModuleOpen o =
0 commit comments