Browse Source

[display] fix type-hint ranges

see #8669
Simon Krajewski 6 years ago
parent
commit
d1538af902
2 changed files with 11 additions and 1 deletions
  1. 1 1
      src/syntax/grammar.mly
  2. 10 0
      tests/server/src/DisplayTests.hx

+ 1 - 1
src/syntax/grammar.mly

@@ -508,7 +508,7 @@ and parse_type_hint = parser
 			(fun p2 ->
 				let ct = CTPath magic_type_path in
 				pignore(f);
-				ct,null_pos
+				ct,display_position#with_pos p1
 			)
 			f
 

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

@@ -396,4 +396,14 @@ typedef Foo = {
 		checkReplaceRange(markers, 1, 2, response);
 		equals("Cl", response.filterString);
 	}
+
+	function testIssue8669_typehint() {
+		complete("class Main { static function main() { var t:{-1-} }}", 1);
+		checkReplaceRange(markers, 1, 1, response);
+		equals("", response.filterString);
+
+		complete("class Main { static function main() { var t:{-1-}Cl{-2-} }}", 2);
+		checkReplaceRange(markers, 1, 2, response);
+		equals("Cl", response.filterString);
+	}
 }