Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions analysis/src/CompletionFrontEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ let offsetOfLine text line =
let positionToOffset text (line, character) =
match offsetOfLine text line with
| None -> None
| Some bol -> Some (bol + character)
| Some bol ->
if bol + character <= String.length text then Some (bol + character)
else None

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

let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
let offset =
match positionToOffset text posCursor with
| Some offset -> offset
| None -> assert false
in
let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
let offsetNoWhite = skipWhite text (offset - 1) in
let posNoWhite =
let line, col = posCursor in
Expand Down Expand Up @@ -789,3 +786,9 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
if !found = false then if debug then Printf.printf "XXX Not found!\n";
!result)
else None

let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
match positionToOffset text posCursor with
| Some offset ->
completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text
| None -> None