chat: wrap markdown tables with horizontal scrollbar#298604
Merged
roblourens merged 3 commits intomainfrom Mar 1, 2026
Merged
Conversation
- Wrap each rendered markdown table in a DomScrollableElement so it scrolls horizontally with the VS Code custom scrollbar instead of the native one. - Apply per-column min-width (in ch units, capped at 3ch) based on max text-content length, so short values like "001" aren't squeezed to a single character wide. - Allow table headers to wrap at word boundaries (white-space: normal) rather than staying on a single line. - Extract the wrapping logic into chatMarkdownTableScrolling.ts with unit tests in chatMarkdownTableScrolling.test.ts. Fixes #265062 (Written by Copilot)
Contributor
There was a problem hiding this comment.
Pull request overview
Adds horizontal scrolling support for rendered markdown tables in the chat widget (using VS Code’s custom scrollbar) and improves table readability by preventing overly-squeezed short columns and allowing header text to wrap.
Changes:
- Wrap rendered
<table>elements in aDomScrollableElementscroll container and re-measure on resize via layout participants. - Apply per-column
min-width(inch, capped) derived from max cell text length to reduce aggressive column squishing. - Update chat CSS for the new wrapper and allow
<th>wrapping; add unit tests for DOM wrapping + sizing behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/widget/chatMarkdownTableScrolling.test.ts | Adds unit tests covering wrapper DOM structure, resize participants, and min-width behavior across tables. |
| src/vs/workbench/contrib/chat/browser/widget/media/chat.css | Styles the new scroll wrapper and adjusts table header wrapping behavior. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownTableScrolling.ts | Introduces table wrapping + min-width computation logic for rendered markdown tables. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts | Integrates the new table-wrapping helper into markdown rendering. |
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownTableScrolling.ts
Outdated
Show resolved
Hide resolved
Instead of setting style.minWidth on every cell in the table (all rows × columns), only apply it to the first row. Column constraints propagate naturally via CSS table layout, so this avoids unnecessary style mutations for large tables. (Written by Copilot)
chrmarti
approved these changes
Mar 1, 2026
DonJayamanne
pushed a commit
that referenced
this pull request
Mar 2, 2026
- Wrap each rendered markdown table in a DomScrollableElement so it scrolls horizontally with the VS Code custom scrollbar instead of the native one. - Apply per-column min-width (in ch units, capped at 3ch) based on max text-content length, so short values like "001" aren't squeezed to a single character wide. - Allow table headers to wrap at word boundaries (white-space: normal) rather than staying on a single line. - Extract the wrapping logic into chatMarkdownTableScrolling.ts with unit tests in chatMarkdownTableScrolling.test.ts. Fixes #265062 (Written by Copilot)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #265062
Summary
Markdown tables in the chat panel can have many columns with wide content. Previously the table would overflow its container with no way to scroll, and short cell values like
001would be aggressively squished to a single character wide.Changes
Horizontal scrolling
<table>is now wrapped in aDomScrollableElementso it scrolls horizontally using the VS Code custom scrollbar.<div>first — passing a<table>directly toDomScrollableElementdoesn't work because a table always expands to its content width, soclientWidth === scrollWidthand the scrollbar never appears.scanDomNodecallback is registered as a layout participant so the scrollbar re-measures on resize.Column min-widths
min-widthis set (inchunits) based on the maximumtextContent.lengthof any cell in that column, capped at3ch. This prevents columns like001from being squeezed to one character wide while keeping the layout flexible for wide content.min-widthapplied).textContentlengths are read, causing no forced reflows.Header wrapping
<th>cells now usewhite-space: normal+overflow-wrap: break-wordinstead ofwhite-space: nowrap, so headers wrap at word boundaries rather than overflowing.Refactoring
chatMarkdownTableScrolling.tsmodule.chatMarkdownTableScrolling.test.tscovering DOM structure, scroll wrapper class, layout participants, min-width capping, and multiple-table handling.(Written by Copilot)