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

Emit remainder spaces #82

Closed
wants to merge 1 commit into from
Closed

Emit remainder spaces #82

wants to merge 1 commit into from

Conversation

sormuras
Copy link
Contributor

@sormuras sormuras commented Mar 8, 2017

Fixes #81 by emitting remainding spaces, that were not replaced by tabs.

Copy link
Member

@jbduncan jbduncan left a comment

Choose a reason for hiding this comment

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

LGTM, but I imagine this would change the behaviour of indentWithTabs for some Spotless users. What do you think @nedtwigg ?

@sormuras
Copy link
Contributor Author

sormuras commented Mar 8, 2017

Perhaps, guard the new behaviour with a switch and call it like indentWithTabsAndEmitRemaindingSpaces(2) -- but removing the single space in front of each Javadoc comment line feels not right.

@jbduncan
Copy link
Member

jbduncan commented Mar 8, 2017

Sounds reasonable to me. However, I don't think "remainding" is a proper word in English. How about "remaining" (without the 'd') or "remainder" instead?

@sormuras sormuras changed the title Emit remainding spaces Emit remainder spaces Mar 8, 2017
@sormuras
Copy link
Contributor Author

sormuras commented Mar 8, 2017

Hm, I don't have an shell here atm to edit the commit message. Can you please squash and edit on-the-fly?

Fixes #81 by emitting remainder spaces, that were not replaced by tabs.
@nedtwigg
Copy link
Member

nedtwigg commented Mar 8, 2017

I'm hesitant to change IndentStep. It is a possibly-breaking change in one of the oldest rules we've got. The current implementation can catch bugs of the following sort:

\t    \t    Good
\t    \t    Good
\t    \t    _Oops (where _ = a space)
\t    \t    Good

The suggested change would break this case. This mistake is easy to see, but the following is harder:

\t    \t    Good

\t    \t    Good

\t    \t    _Oops (where _ = a space)

\t    \t    Good

Advantage of existing implementation: Guarantees that all leading indentation will match exactly a multiple of the specified conditions.
Disadvantage of existing implementation: Doesn't handle indentation exceptions for comments very well.
Workaround: A fairly simple regex specific to these exceptions.

Advantage of new implementation: Swaps tabs and spaces without changing actual position of anything.
Disadvantage of new implementation: Doesn't enforce total amount of leading whitespace, just swaps the characters.
Workaround: ?

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.

None yet

3 participants