-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
- VSCode Version: Code 1.4.0 (6276dcb0ae497766056b4c09ea75be1d76a8b679, 2016-08-04T16:49:32.489Z)
- C/C++ for Visual Studio Code extension version: 0.9.0
- OS Version: Linux x64 3.13.0-92-generic
The extension doesn't seem to apply C_Cpp.clang_format_style=file correctly. My settings.json contents:
{
"C_Cpp.clang_format_style": "file",
"C_Cpp.clang_format_fallbackStyle": "Visual Studio"
}
But files seem to be formatted using the "Visual Studio" style.
Steps to Reproduce:
-
Install vscode and the C/C++ extension.
-
In terminal:
$ mkdir /tmp/vscode-clang-format $ echo "BasedOnStyle: LLVM" > /tmp/vscode-clang-format/.clang-format $ echo "void f() { int a; int b; }" > /tmp/vscode-clang-format/file.cpp $ clang-format -style=file /tmp/vscode-clang-format/file.cpp void f() { int a; int b; } $ code /tmp/vscode-clang-format/
-
Open /tmp/vscode-clang-format/file.cpp
-
Change workspace settings (settings.json) to:
{ "C_Cpp.clang_format_style": "file", "C_Cpp.clang_format_fallbackStyle": "Visual Studio" }
-
Press Ctrl-Shift-I. Observe that an incorrect style is applied to the file.
-
Save the file
-
The resulting formatting is:
$ cat /tmp/vscode-clang-format/file.cpp void f() { int a; int b; }
Looks like the arguments supplied to clang-format in my case are:
-style={ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0 } -fallback-style=LLVM -sort-includes=0
Instead, -style=file
along with the proper -assume-filename=...
should be used.