Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

Nested block statements in TGSL functions were missing indentation prefix for the opening brace when generating WGSL output.

Before:

fn f() -> i32 {
  var res = 0;
{ 
    const f2 = 2;
    res += f2;
  }
  return res;
}

After:

fn f() -> i32 {
  var res = 0;
  {
    const f2 = 2;
    res += f2;
  }
  return res;
}

Changes

  • Added this.ctx.pre prefix to standalone block statements in wgslGenerator.ts
  • Added test case for nested block indentation
  • Updated oklab.test.ts snapshot with corrected indentation
Original prompt

This section details on the original issue you should resolve

<issue_title>fix: incorrect indentation of nested code blocks</issue_title>
<issue_description>When resolving the following function

const f = () => {
  'use gpu';
  let res = 0;
  {
    const f = 2;
    res += f;
  }
  return res;
}

We get this output

fn f() -> i32 {
  var res = 0;
{ 
    const f2 = 2;
    res += f2;
  }
  return res;
}

The second opening brace is not indented correctly. It has too few leading spaces.</issue_description>

<agent_instructions>The root cause is likely located in wgslGenerator.ts within the logic responsible for handling NODE.Block. The indentation level is not being correctly propagated or incremented when entering a nested block.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix incorrect indentation of nested code blocks fix: correct indentation of nested code blocks in wgslGenerator Jan 9, 2026
Copilot AI requested a review from cieplypolar January 9, 2026 12:33
Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Copilot 🤖

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@ef68aafd0c10684b795fde59a299c42dc0d0e380
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@ef68aafd0c10684b795fde59a299c42dc0d0e380
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@ef68aafd0c10684b795fde59a299c42dc0d0e380

benchmark
view benchmark

commit
view commit

@iwoplaza iwoplaza marked this pull request as ready for review January 9, 2026 13:06
@iwoplaza iwoplaza merged commit 32a55d7 into main Jan 9, 2026
3 checks passed
@iwoplaza iwoplaza deleted the copilot/fix-nested-code-indentations branch January 9, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: incorrect indentation of nested code blocks

3 participants