Here's my settings.json:
{
"C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}",
"workbench.sideBar.location": "right",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"terminal.integrated.shell.windows": "C:/msys64/usr/bin/bash.exe",
"terminal.integrated.shellArgs.windows": [ "-i" ],
"terminal.integrated.env.windows": {
"MSYSTEM": "MINGW64",
"PATH" : "/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/"
}
}
This is the code I have:
struct Test : Module
{
enum ParamIds {
TRIGGER_PARAM,
CYCLE_PARAM,
RATE_PARAM,
RATE_FINE_PARAM,
RISE_LENGTH_PARAM,
NUM_PARAMS
};
enum InputIds
{
TRIGGER_INPUT,
TAIL_LENGTH_CV_INPUT,
NUM_INPUTS
};
enum OutputIds {
EOR_OUTPUT,
EOF_OUTPUT,
EOC_OUTPUT,
RISING_OUTPUT,
FALLING_OUTPUT,
OUT_OUTPUT,
NUM_OUTPUTS
};
};
I want, when paste or type (formatOnType), that { is on the same line of function, and code is well formatted (due to Google specifics).
If now, within InputIds I paste a new value in that empty space, that's the result:
struct Test : Module
{
enum ParamIds {
TRIGGER_PARAM,
CYCLE_PARAM,
RATE_PARAM,
RATE_FINE_PARAM,
RISE_LENGTH_PARAM,
NUM_PARAMS
};
enum InputIds {
TRIGGER_INPUT,
ASD_PARAM,
TAIL_LENGTH_CV_INPUT,
NUM_INPUTS
};
enum OutputIds {
EOR_OUTPUT,
EOF_OUTPUT,
EOC_OUTPUT,
RISING_OUTPUT,
FALLING_OUTPUT,
OUT_OUTPUT,
NUM_OUTPUTS
};
};
As you can see, it adds a tab/indention and mess the whole code.
Also, the struct { keep on the new line, not on the same line.
It seems formatting fail.
I'm not able to repro the bug. Can you describe:
Is formatting not working at all for you? If so, can you check the error logs? https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/Enabling%20logging.md
Yes, formatting works.
Here's the code you can test: Test.zip
Do you see now?
Okay, thanks, I repro the issue now.
@sean-mcmanus news about this fix? Thanks
A fix is not currently scheduled because we're busy with other higher priority features.
This might be a bug with clang-format (not sure).
I tried the repro. The file itself does not start out with the correct formatting, so clang-format is applying partial formatting. If you format the whole file first, then paste in your code, the correct behavior happens. This appears to be an issue with clang-format.
Also, you probably meant to use C_Cpp.clang_format_style instead of C_Cpp.clang_format_fallbackStyle