-
-
Notifications
You must be signed in to change notification settings - Fork 350
Description
Describe the bug
In components/JsonEditor.tsx, the hasCodeblockAsDescendant function is using a falsy check on the value returned by indexOf(). Since indexOf() returns 0 when the match is found at the very beginning of the string, the check treats that valid result as if nothing was found. Because of that, the function exits early whenever the code block appears at the start of the markdown content.
Steps To Reproduce
1.Open a markdown file where a JSON code block appears right at the beginning (index 0).
2.The JsonEditor component starts processing the markdown content.
3.During that process, the hasCodeblockAsDescendant check runs.
4.Since indexOf() returns 0 when it finds the code block at the start, the condition
if (!positionOfCodeInFullMarkdown)
incorrectly evaluates to true.
As a result, the function exits early and skips handling code that should actually be processed.
Expected Behavior
The function should be able to detect and handle code blocks no matter where they appear in the markdown — even when a block starts right at index 0.
Screenshots
N/A — this is a logic-level bug, not a visual issue.
Device Information [optional]
- OS: Windows 10
- Browser: Chrome (latest)
- Version: Current codebaseAre you working on this issue?
Yes
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
No