Truncate too long output instead of using key#71
Truncate too long output instead of using key#71efarrer wants to merge 1 commit intoquasilyte:masterfrom
Conversation
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
|
@cristaloleg what's your opinion on this? |
|
I also believe some tools truncate statements in a smart way, so you get |
| var replacement string | ||
| if truncate && buf.Len() > 60 { | ||
| replacement = key | ||
| replacement = string([]rune(buf.String())[:60]) + "..." |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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