Skip to content
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

cmt_convert_tab_to_spaces indents comments with spaces instead of configured tabs #4278

Open
schrolli opened this issue Apr 18, 2024 · 0 comments

Comments

@schrolli
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants