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

Fix formatter indendation #1

Open
robocoder opened this issue Jun 5, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@robocoder
Copy link
Member

commented Jun 5, 2019

Copied from: leafo/scssphp#291

Clarification : this issue is about indentation differences (vs the reference ruby implementation) when using the Nested formatter.

Hint: see adjustAllChildren()

Nice-to-have: eliminate the separate adjustAllChildren() pass

Cerdic added a commit that referenced this issue Jun 11, 2019

@Cerdic

This comment has been minimized.

Copy link
Collaborator

commented Jun 11, 2019

@robocoder I just pushed a working branch with a refactoring of the Nested formatter that seems to solve a lot of cases in the ruby test cases.

https://github.com/scssphp/scssphp/commits/dev/formatter-nested

This a somme little impacts on outputs test, and a lot on outputs_numbered because having a blank line before each numbering comment line.
I let you have a look and tell me if you think it's close enough from the ruby implementation.

I got rid of the adjustAllChildren() and did all the work in the block() function but I don't know if it's really better understandable, because a little tricky at the end - at least it should be faster and less memory consuming.

Some cases are still not good like https://github.com/scssphp/scssphp/blob/master/tests/scss_test.rb#L802 but the Formatter alone can't do anything here as lines are coming all-in-one formatted from the Compiler. This case will need some improvement in the Compiler itself

@robocoder

This comment has been minimized.

Copy link
Member Author

commented Jun 11, 2019

Compatibility improved. Looks good to merge.

Cerdic added a commit that referenced this issue Jun 12, 2019

Refactoring nested formatter #1
code simplification: all the trick is in the block() function, no preprocessing of the output tree

Cerdic added a commit that referenced this issue Jun 12, 2019

#1 downgrade the depth when meeting an empty block with lower depth,…
… before compiling children (they will reincrease the depth due to their own depth), after closing a level>1 block with selectors and children (@media)

do not reincrease depth after a previous empty, except if depth 0 and skip a blank line only after coming back to a real zero depth

Cerdic added a commit that referenced this issue Jun 12, 2019

#1 after an empty line do not increase the depth but change the refe…
…rence to avoid the next line will increase the depth

Cerdic added a commit that referenced this issue Jun 12, 2019

#1 Update tests outputs due to Nested Formatter refactoring: the comp…
…atibility with the reference ruby implementation is better (see make compat)
@Cerdic

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2019

This is now in the master branch (with some commits rewriting/cleaning)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.