Skip to content

Chat: code block after a list item has no padding above #324339

Description

@roblourens

Bug

In the chat view, when a fenced code block immediately follows or is nested in a list, the vertical spacing is asymmetric — there is no padding above the code block, but normal padding below it.

Repro markdown:

- list item
- another list item
```
code
```
- list

Cause

Chat code blocks (.rendered-markdown [data-code]) only carry a bottom margin (margin: 0 0 16px 0) and rely on the previous element's bottom margin for the space above them. Inside a list, list items collapse their inner paragraph margins to stay tight (.rendered-markdown li > p { margin: 0 }), so a code block that follows list content ends up with 0 space above it while keeping 16px below.

Two DOM shapes are affected, depending on whether the fence is indented under a list item or is a sibling between two lists.

Fix

Give code blocks that follow a list (or are nested in a list item) a matching 16px top margin. Margin collapsing keeps the other cases (after a paragraph, first child, tool calls / progress UI) unchanged.

(Written by Copilot)

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugchatinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions