Преглед изворни кода

[display] fix typedef = | ranges

see #8669
Simon Krajewski пре 6 година
родитељ
комит
1bf35f1314
3 измењених фајлова са 14 додато и 2 уклоњено
  1. 1 1
      src/context/display/displayException.ml
  2. 1 1
      src/syntax/grammar.mly
  3. 12 0
      tests/server/src/DisplayTests.hx

+ 1 - 1
src/context/display/displayException.ml

@@ -110,7 +110,7 @@ let fields_to_json ctx fields kind subj =
 		("items",jarray ja) ::
 		("isIncomplete",jbool did_filter) ::
 		("mode",CompletionResultKind.to_json ctx kind) ::
-		("filterString",(match subj.s_name with None -> jnull | Some name -> jstring name)) ::
+		("filterString",(match subj.s_name with None -> jstring "" | Some name -> jstring name)) ::
 		("replaceRange",generate_pos_as_range (Parser.cut_pos_at_display subj.s_insert_pos)) ::
 		[]
 	in

+ 1 - 1
src/syntax/grammar.mly

@@ -224,7 +224,7 @@ and parse_type_decl mode s =
 				d_flags = List.map decl_flag_to_class_flag c @ n @ hl;
 				d_data = fl;
 			}, punion p1 p2)
-		| [< '(Kwd Typedef,p1); name = type_name; tl = parse_constraint_params; '(Binop OpAssign,p2); t = parse_complex_type; s >] ->
+		| [< '(Kwd Typedef,p1); name = type_name; tl = parse_constraint_params; '(Binop OpAssign,p2); t = parse_complex_type_at p2; s >] ->
 			(match s with parser
 			| [< '(Semicolon,_) >] -> ()
 			| [< >] -> ());

+ 12 - 0
tests/server/src/DisplayTests.hx

@@ -384,4 +384,16 @@ typedef Foo = {
 		checkReplaceRange(markers, 1, 2, response);
 		equals("get", response.filterString);
 	}
+
+	function testIssue8669_typedef() {
+		complete("typedef Foo = {-1-}
+		", 1);
+		checkReplaceRange(markers, 1, 1, response);
+		equals("", response.filterString);
+
+		complete("typedef Foo = {-1-}Cl{-2-}
+		", 2);
+		checkReplaceRange(markers, 1, 2, response);
+		equals("Cl", response.filterString);
+	}
 }