|
@@ -97,9 +97,24 @@ let filter_somehow ctx items kind subj =
|
|
|
) acc_types;
|
|
|
DynArray.to_list ret,DynArray.length ret
|
|
|
|
|
|
+let patch_completion_subject subj =
|
|
|
+ let p = Parser.cut_pos_at_display subj.s_insert_pos in
|
|
|
+ match subj.s_name with
|
|
|
+ | Some name ->
|
|
|
+ let delta = p.pmax - p.pmin in
|
|
|
+ let name = if delta > 0 && delta < String.length name then
|
|
|
+ String.sub name 0 delta
|
|
|
+ else
|
|
|
+ name
|
|
|
+ in
|
|
|
+ {subj with s_name = Some name;s_insert_pos = p}
|
|
|
+ | None ->
|
|
|
+ {subj with s_insert_pos = p}
|
|
|
+
|
|
|
let fields_to_json ctx fields kind subj =
|
|
|
last_completion_result := Array.of_list fields;
|
|
|
let needs_filtering = !max_completion_items > 0 && Array.length !last_completion_result > !max_completion_items in
|
|
|
+ let subj = patch_completion_subject subj in
|
|
|
let ja,num_items = if needs_filtering then
|
|
|
filter_somehow ctx fields kind subj
|
|
|
else
|
|
@@ -108,7 +123,6 @@ let fields_to_json ctx fields kind subj =
|
|
|
let did_filter = num_items = !max_completion_items in
|
|
|
if did_filter then last_completion_pos := Some subj.s_start_pos;
|
|
|
let filter_string = (match subj.s_name with None -> "" | Some name -> name) in
|
|
|
- let p = Parser.cut_pos_at_display subj.s_insert_pos in
|
|
|
(* print_endline (Printf.sprintf "FIELDS OUTPUT:\n\tfilter_string: %s\n\t num items: %i\n\t position: %s\n\t before cut: %s"
|
|
|
filter_string
|
|
|
num_items
|
|
@@ -120,7 +134,7 @@ let fields_to_json ctx fields kind subj =
|
|
|
("isIncomplete",jbool did_filter) ::
|
|
|
("mode",CompletionResultKind.to_json ctx kind) ::
|
|
|
("filterString",jstring filter_string) ::
|
|
|
- ("replaceRange",generate_pos_as_range p) ::
|
|
|
+ ("replaceRange",generate_pos_as_range subj.s_insert_pos) ::
|
|
|
[]
|
|
|
in
|
|
|
jobject fl
|