Skip to content

Fixes issue #1260 #1268 #1277 - #31

Merged
hschlichter merged 2 commits into
masterfrom
fixes/extra-indentation-after-line-with-multiple-assignments
Oct 25, 2017
Merged

hschlichter merged 2 commits into
masterfrom
fixes/extra-indentation-after-line-with-multiple-assignments

Conversation

@spuppala-rythmos

Copy link
Copy Markdown

Setting CT_ASSIGN_NL only for pc type is CT_ASSIGN & chunk next is new line

For multiple consecutive assignments in single line , the indent of all these
assignments should be same and one more than this line's indent.
so popping the previous assign and pushing the new one

As discussed with mihai changed the test case as it contradicts uncrustify#1260 & uncrustify#1268

Setting CT_ASSIGN_NL only for pc type is CT_ASSIGN & chunk next is new line

As discussed with mihai changed the test case as it contradicts uncrustify#1260 & uncrustify#1268
Comment thread src/indent.cpp
*/
if ((frm.pse[frm.pse_tos].type == CT_ASSIGN || frm.pse[frm.pse_tos].type == CT_ASSIGN_NL) && pc->type == CT_ASSIGN)
{
indent_pse_pop(frm, pc);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the same as avoiding doing the indent_pse_push from below?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Mihai,
It will work if we avoid doing the indent_pse_push as well but,
the chunk that is responsible for indentation, which must be the last assignment operator in the series of consecutive assignments, should be in the stack.
Hence we are popping the unnecessary chunks and pushing the right one.

y);
x = o.Func2(a, b,
y);
variablex = o.Func(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to the variable name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was suggested by Mihai

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, for purely visual purposes as I understood. Which is fine. Was just worried that the tokeniser actually behaved differently and that was the reason for the change.

@hschlichter
hschlichter merged commit a9036c7 into master Oct 25, 2017
@mihaipopescu

Copy link
Copy Markdown

@satishp87 we have found a regression on unity codebase after merging this PR. We will come back shortly with details.

@mihaipopescu

Copy link
Copy Markdown

For instance, we have found this regression:

diff --git a/output/staging/60036-UNI-99999.cs b/results/staging/60036-UNI-99999.cs
index eda66433..572a6f64 100644
--- a/output/staging/60036-UNI-99999.cs
+++ b/results/staging/60036-UNI-99999.cs
@@ -5,12 +5,12 @@ namespace Unity
         public Resource Bar(File foo)
         {
             Resource resource = null;
             switch (foo.GetExension())
             {
                 case ".boo":
                     resource = new BooResource(type,
-                        paramA,
-                        paramB);
+                    paramA,
+                    paramB);
             }
             return resource;
         }

The indentation of parameters is reduced to first column relative to the variable assignment. I don't think it is what we want. One level of indentation would be ok instead.

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.

4 participants