Skip to content

Conversation

@efarrer
Copy link

@efarrer efarrer commented Aug 21, 2020

When outputing results the current behavior is to use the key in the
output if the identifier would be too long for example:
"$f != nil"

This instead truncates the value and adds elisis as follows:

"ThisIsAReallyLongIdentifierThatWillBeTruncatedInsteadOfReje... != nil"

This output is more friendly.

Addresses #70

When outputing results the current behavior is to use the key in the
output if the identifier would be too long for example:
"$f != nil"

This instead truncates the value and adds elisis as follows:

"ThisIsAReallyLongIdentifierThatWillBeTruncatedInsteadOfReje... != nil"

This output is more friendly.

Addresses quasilyte#70
@quasilyte
Copy link
Owner

@cristaloleg what's your opinion on this?

@quasilyte
Copy link
Owner

quasilyte commented Aug 23, 2020

I also believe some tools truncate statements in a smart way, so you get func (foo int) { ... } instead of something that is truncated in the middle of it.

var replacement string
if truncate && buf.Len() > 60 {
replacement = key
replacement = string([]rune(buf.String())[:60]) + "..."
Copy link
Owner

Choose a reason for hiding this comment

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

Since we're using the value of 60 here twice, maybe make it a local const? It would be easier to find the connection between these two later.

Copy link
Owner

@quasilyte quasilyte Aug 23, 2020

Choose a reason for hiding this comment

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

Another thing is that we're checking for 60 bytes length but then we truncate it to the 60 runes.
We either need to check for the "width" (or runes count) in the first condition or slice the string itself instead of doing string->[]rune->string.

This example demonstrates that the current solution might panic:
https://play.golang.org/p/8WCl054GxLP

Copy link
Owner

@quasilyte quasilyte left a comment

Choose a reason for hiding this comment

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

I'm not comfortable with string->[]rune->string that can panic. We should fix that prior to merging this.

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