Skip to content

Commit 392bb3e

Browse files
committed
Fix macro parsing with no inputs or no outputs
1 parent add0c3d commit 392bb3e

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the "hex-casting" extension will be documented in this file.
44

5+
## [0.2.2] - 2025-05-19
6+
7+
### Fixes
8+
9+
- Fixed an issue in the `#define` regex which caused macros with no outputs to include the args in the macro name.
10+
511
## [0.2.1] - 2025-05-17
612

713
### Fixes

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ function makeCompletionList(
416416
}
417417

418418
const defineRe =
419-
/^(?<directionPrefix>(?<directive>#define[ \t]+)(?=[^ \t])(?<translation>[^(\n]+?))(?:(?<directionPrefix2>[ \t]*\([ \t]*)(?<direction>[a-zA-Z_\-]+)(?:[ \t]+(?<signature>[aqwedsAQWEDS]+))?[ \t]*\))?[ \t]*(?:\[ *(?:(?<modid>[0-9a-z_\-.]+):(?<idPath>[0-9a-z_\-./]+))? *,? *(?:(?<=\[ *|\, *)(?<perWorld>perWorld))? *\])?[ \t]*(?:=[ \t]*(?=[^ \t])(?<inputs>.+?)\s*->\s*(?<outputs>.+?)[ \t]*)?(?:\/\/|\/\*|$)/;
419+
/^(?<directionPrefix>(?<directive>#define[ \t]+)(?=[^ \t])(?<translation>[^(\n]+?))(?:(?<directionPrefix2>[ \t]*\([ \t]*)(?<direction>[a-zA-Z_\-]+)(?:[ \t]+(?<signature>[aqwedsAQWEDS]+))?[ \t]*\))?[ \t]*(?:\[ *(?:(?<modid>[0-9a-z_\-.]+):(?<idPath>[0-9a-z_\-./]+))? *,? *(?:(?<=\[ *|\, *)(?<perWorld>perWorld))? *\])?[ \t]*(?:=[ \t]*(?=[^ \t])(?<inputs>.+?)? *-> *(?<outputs>.+?)?[ \t]*)?(?:\/\/|\/\*|$)/;
420420

421421
const includeRe = /^#include[ \t]+"(?<path>.+?)"(?:\/\/|\/\*|$)/;
422422

test.hexpattern

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Imported
3131
/// description line 1
3232
/// description line 2
3333
#define Foo's Reflection13 = int -> int
34+
#define Foo's Reflection14 = -> int
35+
#define Foo's Reflection15 = int ->
3436
#define Foo =
3537
define Foo
3638
#define Counter's Queue (NORTH_EAST dadaddww)
@@ -51,6 +53,9 @@ Per World Macro
5153
Foo's Reflection
5254
Foo's Purification
5355
Foo's Reflection12
56+
Foo's Reflection13
57+
Foo's Reflection14
58+
Foo's Reflection15
5459
Consume Wisp
5560
Craft Debugger
5661
Consideration: Foo's Purification

0 commit comments

Comments
 (0)