From 2b1d6b966987e9036ff74f5ffc50be82482ed958 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 29 Aug 2025 11:44:02 -0700 Subject: [PATCH] fix(haxe) Restore highlighting of type after new keyword PR #3993 fixed incorrect highlighting of variable names starting with new (like newValue), but at the same time, it removed highlighting of type names that follow the new keyword. This commit restores the lost highlighting for type names after the new keyword, while still ensuring that new at the start of a variable name is not highlighted as a keyword. --- CHANGES.md | 2 ++ src/languages/haxe.js | 2 +- test/markup/haxe/default.expect.txt | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b1413c29a5..cd0797b0fd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ Core Grammars: - enh(json) add json5 support [Kerry Shetline][] - fix(css) `unicode-range` parsing, issue #4253 [Kerry Shetline][] - fix(csharp) Support digit separators [te-ing][] +- fix(haxe) Restore highlighting of type after new keyword [Josh Tynjala][] Documentation: @@ -55,6 +56,7 @@ CONTRIBUTORS [te-ing]: https://github.com/te-ing [Anthony Martin]: https://github.com/anthony-c-martin [NriotHrreion]: https://github.com/NriotHrreion +[Josh Tynjala]: https://github.com/joshtynjala ## Version 11.11.1 diff --git a/src/languages/haxe.js b/src/languages/haxe.js index 084b80263b..f1cefe1bd1 100644 --- a/src/languages/haxe.js +++ b/src/languages/haxe.js @@ -89,7 +89,7 @@ export default function(hljs) { }, { className: 'type', // instantiation - beginKeywords: 'new', + begin: /new[ \t]+/, end: /\W/, excludeBegin: true, excludeEnd: true diff --git a/test/markup/haxe/default.expect.txt b/test/markup/haxe/default.expect.txt index 72d1b25922..cd4d0869ff 100644 --- a/test/markup/haxe/default.expect.txt +++ b/test/markup/haxe/default.expect.txt @@ -84,7 +84,7 @@ class Main extends BaseClass implements SomeFunctionality { var callback:Void->Void = null; - var myArray:Array<Float> = new Array<Float>(); + var myArray:Array<Float> = new Array<Float>(); var arr = [4,8,0,3,9,1,5,2,6,7]; public function new(x) { @@ -120,8 +120,8 @@ done = true; } - var H:Int = cast new MyAbstract(42); - var h:Int = cast(new MyAbstract(31), Int); + var H:Int = cast new MyAbstract(42); + var h:Int = cast(new MyAbstract(31), Int); try { throw "error"; @@ -130,7 +130,7 @@ trace(err); } - var map = new haxe.ds.IntMap<String>(); + var map = new haxe.ds.IntMap<String>(); var f = map.set.bind(_, "12"); } @@ -178,7 +178,7 @@ function generateNewArray(newArray:Array):Void { var i = newArray; - var array = new Array(); + var array = new Array(); } } \ No newline at end of file