-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last indent level converted to spaces (.clang-format set to UseTab: Always
)
#3172
Comments
I think this might be a convenience feature of vscode and not an actual case of space-indentation. |
Could you elaborate on how is this a convenience feature? I have VSCode and clang-format both set to use tabs, and yet every time I paste, the last level of surrounding code gets indented by spaces. It would be convenient if clang-format followed VSCode indent setting without even requiring separate |
@Tronic I'm not able to repro this issue, although I used
If someone can provide a specific code example that might help. |
@sean-mcmanus Missing TabWidth seemed to be causing this. It would make sense for UseTab, IndentWidth and TabWidth all to follow the indentation choice made in VS Code, but at least manually configuring avoids the paste misformat issue. Thanks! |
@Tronic When the default "Visual Studio" style is used, we do inherit the VS Code tab/indent-related settings, but when a .clang-format file is used, we don't do anything to change that, because clang-format itself reads the .clang-format directly. Theoretically we could read/parse/modify the .clang-format ourselves and stop sending "file" to clang-format. This issue #657 is related (although it morphed into a different issue). |
@Tronic Sorry I missed your question. I don't remember tbh since this was a while back. But I think at least at that time I had come to the conclusion that the editor was showing the last indent level as spaces but it was only for ease of navigation and not actual tab characters. |
Type: LanguageService
I am using "C_Cpp.Clang_format_style": "file" to specify my custom formatting. Here is my
.clang-format
file content:However, when formatting, vs-code converts the last indentation level to spaces. For example if I have 4 indentation levels the fourth one is converted to spaces. I have set detectIndentation and insertSpaces to false.
Describe the bug
UseTab: Always
)To Reproduce
1- Set "C_Cpp.Clang_format_style" to "file"
2- Create a .clang-format file in project root:
3- Attempt to format a file
Expected behavior
All indentation levels must be tabs.
Additional context
Please note that when I select Tab Size > Convert Indentation to Tabs all levels are converted to tabs as expected. But after reformatting the file the last level is turned back to spaces.
Resources
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
The text was updated successfully, but these errors were encountered: