-
Notifications
You must be signed in to change notification settings - Fork 20
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
Refactor the diagnostic renderer to avoid printing trailing whitespace #430
Conversation
experimental/parser/testdata/lexer/braces/interleaved.proto.stderr.txt
Outdated
Show resolved
Hide resolved
experimental/report/writer.go
Outdated
return len(data), nil | ||
} | ||
|
||
func (w *writer) WriteBytes(b byte, n int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think passing b = '\n'
breaks this thing. This is only ever called with a space. How about instead just name it WritePadding(n int)
and hardcode the space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think b = '\n'
breaks as the same WriteString("\n\n\n")
would append \n\n\n
to the buffer, just looping over and checking for right padding between each newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, Josh is right. Plus, having it only print spaces means we can make it more efficient.
This PR refactors the renderer so that all writes go through a shared state type, to ensure fine control over whitespace and line endings. This is also an opportunity to somewhat better organize how values are passed between functions in the renderer.