zed-industries/zed · error
Unexpected indented codeblock
Error message
Unexpected indented codeblock
What it means
While parsing an edit-prediction example spec, a code block that is indented rather than fenced has no info string, so the parser cannot know which section field the block belongs to and bails immediately (example_spec.rs:363). Only fenced code blocks with an info tag carry meaning in these specs.
Source
Thrown at crates/edit_prediction/src/example_spec.rs:363
Event::End(TagEnd::Heading(HeadingLevel::H4)) => {
mem::take(&mut text);
}
Event::End(TagEnd::Heading(level)) => {
anyhow::bail!("Unexpected heading level: {level}");
}
Event::Start(Tag::CodeBlock(kind)) => {
if current_section == Section::EditHistory
&& text.trim() == ACCEPTED_PREDICTION_MARKER
{
next_edit_predicted = true;
}
text.clear();
match kind {
CodeBlockKind::Fenced(info) => {
block_info = info;
}
CodeBlockKind::Indented => {
anyhow::bail!("Unexpected indented codeblock");
}
};
}
Event::Start(_) => {
text.clear();
block_info = "".into();
}
Event::End(TagEnd::CodeBlock) => {
let block_info = block_info.trim();
match current_section {
Section::UncommittedDiff => {
spec.uncommitted_diff = mem::take(&mut text);
}
Section::RecentlyOpenedFiles => {
spec.recently_opened_files = parse_path_list(&text);
text.clear();
}
Section::RecentlyViewedFiles => {View on GitHub (pinned to f4178619ac)
Solutions
- Convert the indented block into a fenced block with the correct info string for its section.
- Re-run the parser to verify no other indented blocks remain.
- Configure your editor/markdown formatter to always emit fenced code blocks in these files.
Example fix
def handle(self): // before — indented block, bails
return None
```python
def handle(self): // after — fenced block with info string
return None
``` Defensive patterns
Strategy: validation
Validate before calling
# flag indented code blocks before the parser does
awk '/^( |\t)/ && !/^```/ { print FILENAME ":" FNR ": indented code"; exit 1 }' examples/*.md Type guard
fn is_fenced(kind: &CodeBlockKind) -> bool {
matches!(kind, CodeBlockKind::Fenced(_))
} Prevention
- Always author spec code blocks as fenced blocks with an explicit info string.
- Configure markdown formatters to never emit indented code blocks.
- Add a CI grep/lint for leading-tab/4-space code blocks in spec dirs.
When it happens
Trigger: A spec markdown containing a tab/4-space indented code block (pulldown-cmark's CodeBlockKind::Indented) anywhere the parser walks — typically from content pasted from an editor that auto-indents code.
Common situations: Pasting snippets from terminals or editors that convert to indented blocks; reformatting specs with prettier-style tools that may produce indented blocks; hand-writing specs without fences.
Related errors
- Unexpected heading level: {level}
- cursor position marker line must contain '^' or '<' before [
- Failed to parse example on {}:{} {error}
- Missing cursor position codeblock
- No eval-cli binary provided. Either pass binary_path=/path/t
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ad3c3dc8ccd13c52.
Report an issue: GitHub.