-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Type: Bug
It appears any attempt at changes to the 'Visual Studio' pseudo style, via the GUI, .clang-format file or JSON settings option "C_Cpp.clang_format_fallbackStyle" (EX. "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Visual Studio }" will result in "Formatting failed".
Searching for workarounds, I found this post:
Internally, the Visual Studio style setting we use is similar to
"{ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, TabWidth: 4 }", so you could set the clang_format_style to something like that with modifications. In the pending 0.11.0 update, you can also use a custom clang_format_fallbackStyle. What formatting feature of Visual Studio are you not able to replicate with clang-format? Later clang-format versions have added more options.
Originally posted by @sean-mcmanus in #657 (comment)
That lead me to the conclusion that 'Visual Studio' is not a real style but instead is a macro that is being converted somewhere between your VSCode settings (JSON or GUI) and clang-format. The issue then, would be that it seems to only function as a Pseudo style while not being used as a base. When used as a base, whatever macro functionality exists to convert it into its true { BasedOnStyle: LLVM... form, fails to recognize it is being used in a base, resulting in a failed call to clang-format with a style option it is not familiar with.
To fix this, whatever mechanism converts 'Visual Studio' into { BasedOnStyle: LLVM... would need to also do so while it was used as a base (situations like "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Visual Studio, ColumnLimit: 80 }").
Alternatively, as this seems to be a rather niche issue, I suppose it could also just be documented as a quirk so that the UI more accurately represented the possibilities of configuration.
Workaround
Use the equivalent given in the UI Hint in your settings.json or clang formatting file.
Extension version: 1.17.5
VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 x 4200) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.96GB (6.74GB free) |
| Process Argv | --crash-reporter-id 00f1fbea-93e1-4a68-9e0a-faf5d8fb943d |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30792226
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
282f8724:30602487
f6dab269:30613381
showlangstatbar:30737416
962ge761:30823813
03d35959:30757346
7ij38806:30736111
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015cf:30823818