openscad-support-vscode icon indicating copy to clipboard operation
openscad-support-vscode copied to clipboard

Formatting can get thrown off by * modifier

Open anguslocke opened this issue 1 year ago • 4 comments

Minor formatting bug:

Take example (Google-style formatting)

union() {
  difference() {
    circle();
    square();
  }
}

circle();

Suppose you want to hide the last circle, like:

union() {
  difference() {
    circle();
    square();
  }
}

*circle();

Formatting the file results in

union(){difference(){circle();
square();
}
}

*circle();

(workaround: make a dummy module hide(), and use that instead of * )

anguslocke avatar Mar 22 '23 02:03 anguslocke

In fact there is no dedicated OpenSCAD formatting tool, the formatting function simply calls clang-format. So if the format is too different from the c language, it will not be formatted correctly. There is no good resolution for now, it is a big project.

Leathong avatar Mar 22 '23 03:03 Leathong

I'll try a workaround, replacing the * modifier by a mark before formatting and restoring it after it was done.

Leathong avatar Mar 22 '23 03:03 Leathong

ah, ok, I thought there was already some openSCAD special formatting sauce already. That sounds like a good workaround; same with the ! and # modifiers too?

anguslocke avatar Mar 23 '23 01:03 anguslocke

All modifier characters are not handled for now, they can be processed by the same way.

Leathong avatar Mar 23 '23 03:03 Leathong