Skip to content

Fix alignment with extra spaces after the * or &. - #1359

Merged
gmaurel merged 3 commits into
uncrustify:masterfrom
KVic:align-extra-spaces-fix
Sep 28, 2017
Merged

gmaurel merged 3 commits into
uncrustify:masterfrom
KVic:align-extra-spaces-fix

Conversation

@KVic

@KVic KVic commented Sep 27, 2017

Copy link
Copy Markdown
Contributor

Aligning does not work correctly in variable definitions with extra spaces between '*'/'&' and variable name:

void test()
{
float & c;
double &     d;
}

produce:

void test()
{
	float & c;
	double & d;
}

expected:

void test()
{
	float &  c;
	double & d;
}

Config:

align_var_def_span   = 1
align_var_def_thresh = 4

This PR is an option how to fix this issue.

Aligning variables does not work correctly
in the following case:
float & c;
double &     d;

This commit fix it.
In AlignStack::Add() the threshold check is moved
after reducing the space between 'ref' and 'start'.
@CDanU

CDanU commented Sep 27, 2017

Copy link
Copy Markdown
Collaborator

Neat, could you check if

# Controls the positioning of the '*' in typedefs. Just try it.
# 0: Align on typedef type, ignore '*'
# 1: The '*' is part of type name: typedef int  *pint;
# 2: The '*' is part of the type, but dangling: typedef int *pint;
align_typedef_star_style        = 1        # unsigned number

# Controls the positioning of the '&' in typedefs. Just try it.
# 0: Align on typedef type, ignore '&'
# 1: The '&' is part of type name: typedef int  &pint;
# 2: The '&' is part of the type, but dangling: typedef int &pint;
align_typedef_amp_style         = 1        # unsigned number

is working with this? I am not sure if there is already a test for that.

@KVic

KVic commented Sep 28, 2017

Copy link
Copy Markdown
Contributor Author

I added more tests for the option align_var_def_thresh.

This fix does not affect the align_typedef_xxx so much. Also, there is no align_typedef_thresh option. Therefore, it should be in another fix.

@gmaurel

gmaurel commented Sep 28, 2017

Copy link
Copy Markdown
Collaborator

Thanks for the fix.

@gmaurel
gmaurel merged commit cc6a061 into uncrustify:master Sep 28, 2017
@KVic
KVic deleted the align-extra-spaces-fix branch October 14, 2017 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants