print bounded depth partial strings correctly
@@ -1188,15 +1188,19 @@ fn print_list_like(&mut self, mut max_depth: usize) {
self.state_stack.push(TokenOrRedirect::HeadTailSeparator);
}
- for (char_count, c) in pstr.chars().rev().enumerate() {
+ let state_stack_len = self.state_stack.len();
+
+ for (char_count, c) in pstr.chars().enumerate() {
if max_depth > 0 && char_count + 1 >= max_depth {
break;
}
- self.state_stack.push(TokenOrRedirect::Char(c));
self.state_stack.push(TokenOrRedirect::Comma);
+ self.state_stack.push(TokenOrRedirect::Char(c));
}
+ self.state_stack[state_stack_len ..].reverse();
+
if let Some(TokenOrRedirect::Comma) = self.state_stack.last() {
self.state_stack.pop();
}
