vscode-shader
vscode-shader copied to clipboard
Extension's code formatting ignores CLANG format options file
Tl;Dr
When formatting HLSL code the resulting format ignores the .clang-format
file that's present in the Workspace, if present. I didn't test other languages, but it seems like the extension still doesn't support formatting for shader languages that are not HLSL
Steps to reproduce
- Create a
.clang-format
file that changes the behaviour of the default C++ formatter options set in VSCode - Launch formatting on an HLSL file
- The file doesn't follow the non-default options
Potential cause
I tried to look around the code and I think I understood that to format an HLSL file the code creates a temporary copy of the file in the system's temp folder, appends .cpp
to it and then calls the standard VSCode format call on it. When using clang-formatter as a formatter provider and with file
as a default format style VSCode looks for a .clang-format
file by traversing the parent folders of the file (or so I understood from the documentation). Since we go in another root altogether the .clang-format
file is not found.