From a9d16194151c6688169a5bdc5cbd83efa51a059a Mon Sep 17 00:00:00 2001 From: kiritannplum <52336390+kiritannplum@users.noreply.github.com> Date: Mon, 21 Jul 2025 05:01:44 +0900 Subject: [PATCH] Fix extension.ts Fixed a bug where formatting for binary operators was also applied to +- signs used to indicate positive or negative numbers. --- src/extension.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index aefc242..f142396 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -154,6 +154,7 @@ function formatUnityComputeShader(text: string): string { if (!line.includes('<') || !line.includes('>')) { line = line .replace(/(?!&|^%])([=+\-*/<>!&|^%])(?![=+\-*/<>!&|^%])/g, ' $1 ') + .replace(/(\de|(?:^|[(+\-])[\t ]*)[\t ]*?([+\-])[\t ]*/g, '$1$2') .replace(/([=+\-*<>!&|^%]{2})/g, ' $1 ') .replace(/\s*([,;])\s*/g, '$1 ') .replace(/\s*:\s*/g, ' : ') @@ -242,6 +243,7 @@ function formatUnityShaderlabShader(text: string): string { if (!line.includes('<') || !line.includes('>')) { line = line .replace(/(?!&|^%])([=+\-*/<>!&|^%])(?![=+\-*/<>!&|^%])/g, ' $1 ') + .replace(/(\de|(?:^|[(+\-])[\t ]*)[\t ]*?([+\-])[\t ]*/g, '$1$2') .replace(/([=+\-*<>!&|^%]{2})/g, ' $1 ') .replace(/\s*([,;])\s*/g, '$1 ') .replace(/\s*:\s*/g, ' : ') @@ -288,4 +290,4 @@ function formatUnityShaderlabShader(text: string): string { return formattedLines.join('\n'); } -export function deactivate() { } \ No newline at end of file +export function deactivate() { }