Skip to content

Conversation

shulaoda
Copy link

@shulaoda shulaoda commented Oct 8, 2025

closes #6660

Previously, when formatting comments containing blockquotes followed by comparison operators like > >= >> >>= >>> >>>=, the code would panic with byte index out of bounds error.

The issue was in itemized_block_quote_start function, which counted all > characters in non-alphanumeric prefix, treating operators like >= as nested blockquote markers. This caused the calculated indent to exceed the line length, leading to out-of-bounds indexing.

Fixed by only recognizing valid Markdown blockquote syntax where each > must be followed by a space (e.g., > > text), which was the original intended behavior. Note that only the standard format with spaces is supported, alternative formats like >> text, > > text (multiple spaces), or >text (no space) are not recognized as blockquote markers.


while chars.peek() == Some(&'>') {
chars.next();
if chars.peek() == Some(&' ') {
Copy link
Member

Choose a reason for hiding this comment

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

it can be multiple spaces, yes?

Copy link
Member

Choose a reason for hiding this comment

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

we should have tests for the nested blockquote code that include quotes with multiple spaces (if that does indeed work in rust's markdown)

Copy link
Member

Choose a reason for hiding this comment

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

and if it's multiple spaces then we can't just do line[indent..] above, we actually need to count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE with wrap_comments = true
3 participants