glsl-language-toolkit icon indicating copy to clipboard operation
glsl-language-toolkit copied to clipboard

Don't wrap `#define` values in parenthesis unnecessarily

Open Lutymane opened this issue 7 months ago • 0 comments

This breaks code e.g.

// #define noise snoise
#define noise cnoise
//...
noise(position)

Formatter would replace the define with #define noise (cnoise), which would break the code (cnoise)(position).

My edit is doing this instead to preserve existing parenthesis but not adding any extra:

// print() -> case "ppDefine"
paren(p("node"), n.tokens.at(0).tokenType.name === 'LEFT_PAREN' && n.tokens.at(-1).tokenType.name === 'RIGHT_PAREN')

Lemme know your thoughts

Lutymane avatar Apr 28 '25 08:04 Lutymane