Skip to content

Fix #2063: Print tabs in message padding #2486

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

Merged
merged 1 commit into from
May 23, 2017

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki requested a review from smarter May 20, 2017 15:51
@@ -101,9 +100,12 @@ trait MessageRendering {

math.min(currPad, minPad)
}
val padding =
if (leastWhitespace - offset == pos.startColumn) pos.startColumnPadding
else " " * (leastWhitespace - offset)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this is correct. Why not use startColumnPadding in currPad above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we do not know the size of one tab.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But indeed I need to modify the logic a bit

/** The padding of the column corresponding to `offset`, includes tabs */
def startColumnPadding(offset: Int): String = {
var idx = startOfLine(offset)
val pad = new StringBuffer("")
Copy link
Member

Choose a reason for hiding this comment

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

Use StringBuilder instead to avoid the synchronization overhead of StringBuffer, also you can use the empty constructor: new StringBuilder

@smarter smarter merged commit 83745f3 into scala:master May 23, 2017
@allanrenucci allanrenucci deleted the fix-#2063 branch December 14, 2017 19:18
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.

2 participants