Skip to content

Commit f3687eb

Browse files
committed
Merge branch 'master' into feat-publish-diagnostics
2 parents 7519dce + a7f5fed commit f3687eb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

analysis/src/CompletionFrontEnd.ml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ let offsetOfLine text line =
2323
let positionToOffset text (line, character) =
2424
match offsetOfLine text line with
2525
| None -> None
26-
| Some bol -> Some (bol + character)
26+
| Some bol ->
27+
if bol + character <= String.length text then Some (bol + character)
28+
else None
2729

2830
type prop = {
2931
name: string;
@@ -216,12 +218,7 @@ let rec exprToContextPath (e : Parsetree.expression) =
216218
| Some contexPath -> Some (CPApply (contexPath, args |> List.map fst)))
217219
| _ -> None
218220

219-
let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
220-
let offset =
221-
match positionToOffset text posCursor with
222-
| Some offset -> offset
223-
| None -> assert false
224-
in
221+
let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
225222
let offsetNoWhite = skipWhite text (offset - 1) in
226223
let posNoWhite =
227224
let line, col = posCursor in
@@ -789,3 +786,9 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
789786
if !found = false then if debug then Printf.printf "XXX Not found!\n";
790787
!result)
791788
else None
789+
790+
let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
791+
match positionToOffset text posCursor with
792+
| Some offset ->
793+
completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text
794+
| None -> None

0 commit comments

Comments
 (0)