Browse Source

[display] fix type parameter ranges

see #8669
Simon Krajewski 6 years ago
parent
commit
8974eebc30
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

@@ -658,7 +658,7 @@ and parse_type_path_or_const plt = parser
 		if !in_display_file then begin
 			if would_skip_display_position plt s then begin
 				let ct = CTPath magic_type_path in
-				TPType (ct,plt)
+				TPType (ct,display_position#with_pos plt)
 			end else
 				raise Stream.Failure
 		end else

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

@@ -406,4 +406,14 @@ typedef Foo = {
 		checkReplaceRange(markers, 1, 2, response);
 		equals("Cl", response.filterString);
 	}
+
+	function testIssue8669_typeParameter() {
+		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);
+	}
 }