Show truncation indicator in array display#7072
Show truncation indicator in array display#7072dimitarvdimitrov wants to merge 3 commits intodevelopfrom
Conversation
6378a6d to
1c79cc4
Compare
There was a problem hiding this comment.
Pull request overview
Updates array value display so that when the displayed values are truncated (default limit 16), the output visibly indicates truncation by appending an ellipsis.
Changes:
- Update scalar array display formatting to append
...when output is truncated. - Update
DisplayOptionsdocs to mention the default truncation behavior. - Add a unit test asserting the new truncation indicator behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Dimitar Dimitrov <dimitar@spiraldb.com>
1c79cc4 to
0e2ed56
Compare
joseph-isaacs
left a comment
There was a problem hiding this comment.
we need to add custom trunc len. but this can be a follow up
joseph-isaacs
left a comment
There was a problem hiding this comment.
would be nice to include the last few values too?
|
I have added the logic to print trailer as well. We now print LIMIT - 3, ..., LAST 3 items when display is truncated |
Merging this PR will degrade performance by 15.51%
Performance Changes
Comparing Footnotes
|
| let limit = self.len().min(f.precision().unwrap_or(DISPLAY_LIMIT)); | ||
| let is_truncated = self.len() > limit; | ||
| write!( | ||
| f, | ||
| "{}", | ||
| (0..limit) | ||
| (0..(limit - if is_truncated { 3 } else { 0 })) | ||
| .map(|i| self | ||
| .scalar_at(i) | ||
| .map_or_else(|e| format!("<error: {e}>"), |s| s.to_string())) | ||
| .format(sep) | ||
| )?; | ||
| write!(f, "{}", if f.alternate() { "\n]" } else { "]" }) | ||
| if is_truncated { | ||
| write!(f, "{sep}...{sep}")?; | ||
| write!( | ||
| f, | ||
| "{}", | ||
| (self.len() - 3..self.len()) | ||
| .map(|i| self | ||
| .scalar_at(i) | ||
| .map_or_else(|e| format!("<error: {e}>"), |s| s.to_string())) | ||
| .format(sep) | ||
| )?; | ||
| } | ||
| let closing_brace = if f.alternate() { "\n]" } else { "]" }; | ||
| write!(f, "{closing_brace}") |
There was a problem hiding this comment.
can we simplify this
When displaying array values that exceed the display limit (16), we now show
...at the end instead of silently truncating. Makes it obvious the output is incomplete.