Skip to content

markdown table cells do not wrap and can overflow horizontally #2197

@suxiaoshao

Description

@suxiaoshao

Description

Markdown table cells can overflow horizontally instead of wrapping inside the cell.

I hit this in an app that renders markdown via TextView::markdown(...). Normal paragraph text wraps correctly, but once the content is inside a markdown table cell, long Chinese/English mixed text stays on a single line and pushes the row beyond the container width.

This looks like a bug in the markdown table renderer in crates/ui/src/text/node.rs, not in app-level usage.

Environment

  • GPUI: v0.2.2
  • GPUI Component: v0.5.1
  • Platform: macOS

Steps to Reproduce

  1. Render markdown with TextView::markdown(...).
  2. Include a table with one short first column and one long second column.
  3. Put long natural-language text in the second column.
  4. View the rendered table in a constrained-width container.

Example markdown:

| Framework | Detection Pattern |
| --- | --- |
| React | useEffect without cleanup return, addEventListener without removeEventListener, setInterval/setTimeout without cleanup, subscribe() without unsubscribe() |
| Vue | onMounted without matching onUnmounted cleanup, watch/watchEffect without stop handle, manual addEventListener inside setup without removal |

Screenshots

Image

Expected

Table cells should wrap text within the available cell width, similar to normal paragraph rendering.

Actual

The table renderer sets a width using relative(len as f32) where len is derived from text length, and also applies .truncate() on each cell. This makes cells behave like fixed/non-wrapping content and causes horizontal overflow for long cell text.

Relevant code:

  • crates/ui/src/text/node.rs
  • div().w(Length::Definite(relative(len as f32)))
  • .truncate()

From inspection:

  • .truncate() disables wrapping by applying whitespace_nowrap
  • relative(...) expects a fraction of parent width, but here it receives character-count-like values (len as f32), not a 0.0..=1.0 ratio

So the issue appears to be in gpui-component's markdown table layout logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions