uncrustify
uncrustify copied to clipboard
cmt_convert_tab_to_spaces indents comments with spaces instead of configured tabs
Sourcefile
void test(){
nop();
// this is a comment
nop();
}
Config
with comments from --update-config-with-doc
# The original size of tabs in the input.
#
# Default: 8
input_tab_size = 4 # unsigned number
# The size of tabs in the output (only used if align_with_tabs=true).
#
# Default: 8
output_tab_size = 4 # unsigned number
# The number of columns to indent per level. Usually 2, 3, 4, or 8.
#
# Default: 8
indent_columns = 4 # unsigned number
# How to use tabs when indenting code.
#
# 0: Spaces only
# 1: Indent with tabs to brace level, align with spaces (default)
# 2: Indent and align with tabs, using spaces when not on a tabstop
#
# Default: 1
indent_with_tabs = 1 # unsigned number
# Whether to indent comments that are not at a brace level with tabs on a
# tabstop. Requires indent_with_tabs=2. If false, will use spaces.
indent_cmt_with_tabs = true # true/false
# Whether to convert all tabs to spaces in comments. If false, tabs in
# comments are left alone, unless used for indenting.
cmt_convert_tab_to_spaces = true # true/false
Version
Uncrustify-0.78.1_f on Windows, downloaded from the github-Releases
Observed
the comment is indented by four spaces, the codelines are indented using hardtabs
Expected
the one-line comment should be indented by one hardtab, matching the code lines.
"Fix"
setting the cmt_convert_tab_to_spaces to false will indent the comment with a hardtab as expected.
Description ambiguity
as i interprete the description of the option cmt_convert_tab_to_spaces, tabs are replaced with spaces after the start of a comment (characters //). This option should not affect the external indentation before the start of the comment...
is this expected behaviour? if yes, this should be made clear in the description of the option.