Skip to content

fix: correct index bug in extractCodeBlocks and extractInlineCodes#130

Merged
mengzhuo merged 1 commit intosipeed:mainfrom
MHCP000:fix/codeblock-index-bug
Feb 13, 2026
Merged

fix: correct index bug in extractCodeBlocks and extractInlineCodes#130
mengzhuo merged 1 commit intosipeed:mainfrom
MHCP000:fix/codeblock-index-bug

Conversation

@MHCP000
Copy link

@MHCP000 MHCP000 commented Feb 13, 2026

The previous implementation used len(codes)-1 in ReplaceAllStringFunc, which caused all placeholders to point to the same (last) index. This resulted in only the last code block being displayed correctly when multiple code blocks were present in a message.

Now using a proper counter variable that increments for each match, ensuring each code block gets a unique placeholder index.

The previous implementation used len(codes)-1 in ReplaceAllStringFunc,
which caused all placeholders to point to the same (last) index.
This resulted in only the last code block being displayed correctly
when multiple code blocks were present in a message.

Now using a proper counter variable that increments for each match,
ensuring each code block gets a unique placeholder index.
@mengzhuo mengzhuo merged commit 82a9a80 into sipeed:main Feb 13, 2026
3 checks passed
emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
fix: correct index bug in extractCodeBlocks and extractInlineCodes
StarWindv referenced this pull request in StarWindv/PicoClaw-shou Feb 19, 2026
fix: correct index bug in extractCodeBlocks and extractInlineCodes
@Orgmar
Copy link
Contributor

Orgmar commented Feb 19, 2026

@MHCP000 That index bug was a sneaky one, all placeholders pointing to the last code block must have been confusing for users. Good find and clean fix with the counter variable!

By the way, we have the PicoClaw Dev Group on Discord for contributors. Want to join? Just email support@sipeed.com with the subject [Join PicoClaw Dev Group] + Your GitHub account and we'll send the invite your way.

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.

4 participants