Commit graph

185 commits

Author SHA1 Message Date
alkinun
c0596fade7
markdown: Fix escaping non-ASCII chars (#55782)
Fixes #55704

The `escape` function in `crates/markdown/src/markdown.rs` was calling
`c as u8` on the `char`s before passing to `MarkdownEscaper::next()`.
This strips non ASCII Unicode codepoints down to just their low 8 bits
which might be in the ASCII punctuation range and thus cause an extra
backslash to be added in front of these non ASCII chars.
 
Release Notes:

- Fixed a bug where non-ASCII chars in diagnostic messages were
incorrectly rendered with spurious `\` characters
2026-05-19 17:20:24 +00:00
Lee Nussbaum
003e821177
markdown_preview: Independent code font family (#56744)
Adds a `markdown_preview_code_font_family` setting that overrides the
font used in the markdown preview for code — inline `code` spans and
fenced code blocks.
This is the counterpart to `markdown_preview_font_family` (#54003),
which already does this for body text. Together they let you choose a
typographically matched body + code font pair for the preview without
forcing the code font onto editor buffers, where it may not be a good
coding font:

```json
{
  "markdown_preview_font_family": "Noto Serif",
  "markdown_preview_code_font_family": "Noto Sans Mono"
}
```

Behavior mirrors `markdown_preview_font_family`:
- Scoped to the markdown preview only (`MarkdownFont::Preview`). The
agent panel, notifications, hover popovers, and REPL output are
unaffected — they keep using the buffer font for code.
- Falls back to the buffer font family when unset, so existing previews
are unchanged.
- Overrides the font family only; fallbacks and features still come from
the buffer font.

Before (uses buffer font, here Iosevka):

<img width="509" height="368" alt="Screenshot 2026-05-14 at 1 39 51 PM"
src="https://github.com/user-attachments/assets/6b7e49b2-fc6e-4db1-9679-392b3447f411"
/>

After (uses specified font, here Noto Sans Mono):

<img width="508" height="368" alt="Screenshot 2026-05-14 at 1 40 51 PM"
src="https://github.com/user-attachments/assets/f911c99b-08f8-4336-83eb-54b555f11c54"
/>

Release Notes:

- Added `markdown_preview_code_font_family` to override the code font in
the markdown preview
2026-05-14 20:03:29 +00:00
Danilo Leal
29db565437
markdown: Fix default UI font rendering in Mermaid diagrams (#56695)
Release Notes:

- Fixed Mermaid diagrams not rendering with the default UI typeface.
2026-05-14 11:15:08 +00:00
Cameron Mcloughlin
2301e61d2a
agent_ui: Mermaid diagrams (#56430)
Adds mermaid diagrams to the agent UI

Defaults to rendering the diagram, toggle to switch back to code.

<img width="605" height="837" alt="image"
src="https://github.com/user-attachments/assets/ed87f4e3-77f3-4602-b783-65eda909ad01"
/>
<img width="615" height="334" alt="image"
src="https://github.com/user-attachments/assets/1a422c83-fed4-4099-b895-b5a16e9d2222"
/>


Also makes markdown preview markdown rendering use theme colors:

Before:
<img width="593" height="781" alt="image"
src="https://github.com/user-attachments/assets/8598ca42-d44a-426b-ac4a-fb3cd1288780"
/>

<img width="593" height="781" alt="image"
src="https://github.com/user-attachments/assets/737fdd62-0a37-48dd-a13a-4e11bf80f038"
/>


Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-05-13 09:57:17 +00:00
Cameron Mcloughlin
4074eabb3d
agent_ui: Images (#56427)
Adds images to the agent panel

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2026-05-12 21:03:27 +00:00
Smit Barmase
6151889ddf
markdown: Fix table header alignment and apply alignment to cell content (#56179)
Follow up: https://github.com/zed-industries/zed/pull/53465

For Markdown tables, headers are now always centered (ignoring column
alignment), matching standard Markdown rendering behavior. For HTML
tables, headers default to center but respect explicit `align`
attributes.

This also propagates alignment to paragraphs and headings inside table
cells, not just the cell container itself.

Release Notes:

- N/A
2026-05-08 15:24:45 +00:00
David Alecrim
e6b8b30e22
markdown: Improve table cell alignment (#53465)
## Summary

Markdown preview tables kept text pinned to the top of a row when a
neighboring cell contained a taller image. This made mixed
text-and-image tables look unbalanced and inconsistent with common
editor behavior. This change makes table text stay visually centered
within taller rows so Markdown tables are easier to scan and match
expected rendering more closely.

## Before / After

| Before | After |
| --- | --- |
| <img width="849" height="869" alt="Screenshot 2026-04-08 at 19 55 50"
src="https://github.com/user-attachments/assets/b3751bff-3750-4ca1-8997-6f5265e4d291"
/> | <img width="898" height="734" alt="Screenshot 2026-04-08 at 21 47
31"
src="https://github.com/user-attachments/assets/d853c0a1-800c-4a2a-aec9-e0ef08453fa7"
/> |

## References
Inspired by comparing this with VS Code preview
<img width="1286" height="878" alt="Screenshot 2026-04-08 at 21 54 06"
src="https://github.com/user-attachments/assets/8dbbfe28-9980-4012-94f1-1b5b3503065b"
/>

Release Notes:

- Improved Markdown preview table cells to vertically center content in
tall rows and respect column alignment from the table header.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-05-07 12:26:13 +00:00
Kunall Banerjee
280f8b1048
agent_ui: Allow selection of commands from tool calls (#50545)
Closes #50427.

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

The changes respect your current theme + mimic the existing UI when it
comes to font size+weight.

<img width="437" height="131" alt="image"
src="https://github.com/user-attachments/assets/89f6c5d0-d1a3-478a-88e9-7d203240416d"
/>


https://github.com/user-attachments/assets/a5fb6c82-fffd-494f-a374-9296d1690736

Release Notes:

- Allow selection of commands from tool calls
2026-04-24 13:54:28 +00:00
iam-liam
1b37531a2e
markdown: Make table cell checkboxes clickable (#54747)
Closes #53587

Follow-up to #50595.

[#50595](https://github.com/zed-industries/zed/pull/50595) added
display-only checkboxes when `[x]` / `[X]` / `[ ]` appears as the sole
content of a markdown table cell. That PR called out interactivity as a
later step — this PR delivers it.


https://github.com/user-attachments/assets/c666ee4c-7e31-4450-ab33-c07c82949818

## What this does

When a consumer of `MarkdownElement` supplies an `on_checkbox_toggle`
callback, table-cell checkboxes now invoke it on click with the source
range of the `[x]` / `[ ]` marker and the new checked state. This
mirrors the existing list-item checkbox path.

For markdown preview (`markdown_preview_view.rs`) the callback is
already wired to edit the source buffer, so clicking a checkbox in a
previewed `.md` file now flips `[x]` to `[ ]` and back in the file, the
same as it already did for list checkboxes.

## How it works

`replace_pending_checkbox` previously took the cell's outer source range
and always built a visualization-only checkbox. It now takes the
optional toggle callback instead, and reconstructs the marker's exact
source range from `pending_line.source_mappings` — pulldown-cmark emits
`[x]` in a table cell as three separate `Text` events, so the per-chunk
mappings are needed to recover the 3-character range to rewrite. If a
callback was supplied, the checkbox attaches an `on_click` that invokes
it with that range and `!checked`; otherwise it falls back to the prior
visualization-only rendering.

Two free helpers (`source_range_for_rendered` /
`source_index_for_rendered`) were extracted so the mapping logic is
unit-testable.

## Scope

One file: `crates/markdown/src/markdown.rs`. No changes to
`markdown_preview` — since #52008 it renders through the shared
`MarkdownElement`, so its existing `on_checkbox_toggle` wiring picks up
table checkboxes for free.

## Relation to #53587

[#53587](https://github.com/zed-industries/zed/issues/53587) reports
that markdown checkboxes in the **agent panel** can't be clicked. This
PR is a necessary piece of that fix — without it, even if the agent
panel wired `on_checkbox_toggle`, its table checkboxes would stay inert.
It does not fully close #53587 on its own: the agent panel's
`MarkdownElement` instances in `conversation_view.rs` / `thread_view.rs`
don't currently wire `on_checkbox_toggle`, and wiring it there requires
deciding how clicks should mutate the in-memory agent response (no
source file to edit into). That's a follow-up.

## Test plan

**Unit tests** (2 new, both in `crates/markdown/src/markdown.rs`):
- `test_table_checkbox_marker_source_range` — walks parser events for a
table with checkboxes, replays what the builder accumulates, and asserts
the reconstructed source range slices to exactly `[x]` / `[ ]` in the
original markdown (including a padded-whitespace case).
- `test_source_range_for_rendered_handles_split_chunks` — pins the
mapping helper against the three-chunk layout pulldown-cmark produces.

**Automated**:
- [x] `cargo test -p markdown` — 46 tests pass (44 existing + 2 new)
- [x] `cargo test -p markdown_preview` — 3 tests pass
- [x] `./script/clippy -p markdown` — clean

**Manual** (against a preview of a markdown file with checkbox tables):
- [x] Click a checked `[x]` table cell — it becomes `[ ]` in the source
and rerenders as unchecked
- [x] Click an unchecked `[ ]` — becomes `[x]`
- [x] Uppercase `[X]` toggles on click (replacement writes `[x]` / `[
]`, matching the list-item behaviour)
- [x] Padded-whitespace cells still target just the three marker
characters
- [x] Multiple checkbox columns in one table all independently clickable
- [x] Alignment variants (left/center/right) behave the same
- [x] Non-checkbox table text unaffected
- [x] List-item checkboxes continue to work (regression)

Release Notes:

- Made table-cell markdown checkboxes clickable in markdown preview,
matching list-item checkbox behavior

Co-authored-by: Lukas Wirth <lukas@zed.dev>
2026-04-24 13:02:06 +00:00
Tim Vermeulen
2595391217
markdown: Make highlighting of rendered markdown more accurate (#54744)
Paints selections and search highlights of rendered markdown more
accurately, to properly match what's actually being selected.

Particularly noticeable when the selection spans multiple rows in a
table cell or when it starts right after a soft wrap.

|Before|After|
| --- | --- |
|<img width="831" height="677" alt="before"
src="https://github.com/user-attachments/assets/3b2c33be-e4cb-400f-9ba6-4163eb438f99"
/> | <img width="831" height="677" alt="after"
src="https://github.com/user-attachments/assets/04161dd8-7f4a-46c5-8c63-3497d3533f6d"
/> |


Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed selection and search highlights in rendered markdown not always
being displayed accurately.
2026-04-24 12:51:52 +00:00
Danilo Leal
442790c9bb
agent_ui: Fix markdown heading sizes (#54766)
Follow up to https://github.com/zed-industries/zed/pull/54374 as that
removed the custom heading styles that were mostly tailored to the agent
panel. It makes sense for those values not to be the ones used for
general markdown rendering, but I think it's just too big for the agent
panel. So I'm sort of hijacking the `MarkdownFont::Agent` enum here so
that we can set it conditionally to just the agent context.

Release Notes:

- N/A
2026-04-24 12:47:29 +00:00
shiwyang
9fe32ac141
Support GFM callouts in Markdown (formerly GitHub admonitions) (#54661)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #10022 

Release Notes:

- Added support for GFM alert callouts (`> [!NOTE]`, `> [!TIP]`, `>
[!IMPORTANT]`, `> [!WARNING]`, `> [!CAUTION]`) in markdown preview,
rendering each type with a colored left border, icon, and bold label.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2026-04-24 02:52:54 +00:00
robinojw
a1cb3706f4
markdown_preview: Independent font family and theme (#54003)
## Summary

Adds two user-facing settings that let the markdown preview render with
a font family and theme independent from the editor. Both are optional
and fall back to the editor defaults when unset.

```json
{
  "markdown_preview_font_family": "Georgia",
  "markdown_preview_theme": "Solarized Light"
}
```

## Details

- New `MarkdownFont::Preview` variant, used only by the preview surface.
- New `MarkdownStyle::themed_with_overrides()` that accepts explicit
`ThemeColors` and `SyntaxTheme` so the preview can render with a theme
other than the active editor theme. Existing `themed()` callers are
unchanged.
- The preview pane background adopts the chosen theme's
`editor_background`.
- Follows the pattern already used by `agent_ui_font_size` /
`agent_buffer_font_size`.

## Scope

Sizing-related changes (`markdown_preview_font_size`,
`markdown_preview_line_height`, typography tweaks, responsive max-width
container) were in an earlier revision of this PR and have been removed
per review feedback — they interact with the Cmd+/- zoom behavior in
ways that still need design work, and will land in a follow-up.

## Files Changed

- `crates/settings_content/src/theme.rs` — schema
- `crates/theme_settings/src/settings.rs` — runtime + accessor
- `crates/markdown/src/markdown.rs` — `MarkdownFont::Preview` +
`themed_with_overrides()`
- `crates/markdown_preview/src/markdown_preview_view.rs` — theme
resolution, style selection, background
- `crates/markdown_preview/Cargo.toml` — `theme` dependency
- `crates/settings/src/vscode_import.rs` — new fields in struct literal

Release Notes:

- Added `markdown_preview_font_family` and `markdown_preview_theme`
settings to customize the markdown preview independently from the
editor.

Co-authored-by: Chris Biscardi <chris@christopherbiscardi.com>
2026-04-23 23:41:07 +00:00
Bennet Bo Fenner
254c27d511
Revert "markdown: Apply theme syntax color to inline code in rendered markdown" (#54504)
Reverts zed-industries/zed#54475

This causes inline code blocks to look strange in some themes
2026-04-22 13:38:18 +00:00
Kento Yamamoto
14f0a254eb
markdown: Apply theme syntax color to inline code in rendered markdown (#54475)
## Summary

Inline code in rendered markdown previously used only the default
foreground color with a subtle background tint, which made it visually
indistinguishable from surrounding prose in some themes.

This change looks up the `text.literal` syntax style from the active
theme and applies its color to inline code, matching the treatment used
for inline code elsewhere in the editor (e.g. syntax highlighting in
source buffers). When the theme does not define `text.literal`, the
color falls back to the previous default.


Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved inline code in rendered markdown to use the theme's
`text.literal` syntax color
2026-04-21 22:38:47 -07:00
saberoueslati
d2ddb4b2d9
markdown: Fix heading sizes and spacing in preview (#54374)
## Context

Heading sizes in the markdown preview were nearly identical to body
text, making `# H1`, `## H2`, and `### H3` visually indistinguishable.
The root cause was in `MarkdownStyle::themed()`: it set a
`heading_level_styles` override with font sizes of `rems(1.05–1.15)`,
which silently replaced the correct sizes applied by
`apply_heading_style` (via GPUI's `text_3xl`/`text_2xl`/`text_xl`
utilities `rems(1.875/1.5/1.25)`). Removing that override restores the
intended hierarchy. A `mt_4()` top margin was also added so consecutive
headings have visual breathing room.

Closes #54358

Video of manual test below :

[Screencast from 2026-04-21
02-22-12.webm](https://github.com/user-attachments/assets/8dd815f9-6f9b-4e88-bebb-28c79f019427)

## How to Review

`crates/markdown/src/markdown.rs` Three changes:
- (1) removed the `heading_level_styles` block from
`MarkdownStyle::themed()` that was overriding heading font sizes with
nearly-body-text values;
- (2) added `mt_4()` to the heading div in `push_markdown_heading` for
better vertical spacing;
- (3) added `test_heading_font_sizes_are_distinct` which renders H1–H3
and a paragraph then asserts that line heights strictly decrease from H1
down to body text.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed heading sizes in the markdown preview to correctly reflect the
H1–H6 size hierarchy, matching standard markdown renderers
2026-04-21 19:03:40 -07:00
saberoueslati
481407479d
markdown: Add "Copy Link" to right-click context menu (#53758)
## Context

Closes #53741

Right-clicking on a link in any Markdown view showed no way to copy the
URL. The right-click handler already detected links for left-click
navigation, but the context menu was never extended to surface a
link-specific action.

Video of the manual test below :

[Screencast from 2026-04-13
00-29-49.webm](https://github.com/user-attachments/assets/fbde09ab-78da-4366-b1e0-e15e0d43442b)

## How to Review

- **`crates/markdown/src/markdown.rs`** — Added a `context_menu_link:
Option<SharedString>` field to `Markdown`. Added
`capture_for_context_menu(link)` (replaces the old
`capture_selection_for_context_menu`) which saves both selected text and
the hovered link together. Added a `context_menu_link()` accessor.
Updated the capture-phase right-click handler to detect the link under
the cursor via `rendered_text.link_for_source_index`. Added a
`event.button != MouseButton::Right` guard to the bubble-phase
`MouseDownEvent` handler to prevent selection logic from running on
right-click.

- **`crates/agent_ui/src/conversation_view/thread_view.rs`** — In
`render_message_context_menu`, after computing `has_selection`, also
reads `context_menu_link` from the same markdown chunks. Adds a "Copy
Link" entry with a separator at the top of the menu when a link URL is
present.

- **`crates/markdown_preview/src/markdown_preview_view.rs`** — Wraps the
markdown element in a `right_click_menu` with a "Copy Link" entry (when
a link is present).

Edit: There was a mention of a "Copy" and "Copy as Markdown" buttons.
After discussion, it was decided that I would re-add them fully fleshed
out in a separate PR

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the UI/UX checklist
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added "Copy Link" to the right-click context menu when clicking on a
  link in Markdown views (agent panel and Markdown preview)
2026-04-21 18:26:45 -07:00
David Alecrim
0ddc7d0666
Fix crash and enable GIF animation in markdown preview (#53459)
Closes #53426

Fixes a crash when previewing markdown with GIFs, and enables GIF
animation in the preview panel.

Two issues: a partially-decoded GIF could crash the preview, and GIFs in
markdown previews never animated.

The fix for GIFs with empty comment extensions (`21 fe 00`) was
implemented upstream in the `image-gif` crate (image-rs/image-gif#228)
and released as `gif 0.14.2`. This PR bumps the dependency so those GIFs
now render correctly in the markdown preview without any further changes
to Zed itself.

## Screenshot
Left=VS Code
Right=Zed


https://github.com/user-attachments/assets/7950abbc-1a79-4f01-a425-9595aa688325

Release Notes:

- Fixed a crash in certain scenarios when opening Markdown Preview with
GIFs.
- Added GIF animation support for Markdown Preview.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-16 10:44:00 +03:00
Dong
a151def86f
markdown_preview: Add footnotes support (#53086)
## What does this PR changed

Adds footnote rendering and navigation to Zed's markdown preview.

- **Footnote references**: (`[^1]`) render inline as `[1]` with link
styling (color + underline)
- **Footnote definitions**: (`[^1]: ...`) render at the bottom with a
horizontal separator, smaller text (85% size), and a label prefix
- **Click-to-navigate**: clicking a footnote reference scrolls to its
definition


https://github.com/user-attachments/assets/a79a0136-f22d-40ac-8b53-cfefa8573d21

## OOS/ Need discussion

- **Display style**: Since currently the gpui crate does not provide a
superscript style, in this PR we publish the feature with using
[`[1]`]() instead of aligning to the GFM styled[^1]
- **Footnote definition placement**: GFM renders the footnote at the
bottom of the content no matter where the user place the footnote
definition, but the `pulldown_cmark` renders the footnote just at where
user place it, for this PR I'll keep the footnote where `pulldown_cmark`
renders it, and we may have some more discuss on if we need to move them
to the bottom of the markdown preview

[^1]: GitHub-flavoured markdown

## What to test

- [ ] Open a markdown file with footnotes (e.g. `Text[^1]\n\n[^1]:
Definition`)
- [ ] Verify reference renders as `[1]` with link color
- [ ] Verify definition renders below a separator with smaller text
- [ ] Verify pointer cursor appears on hover over `[1]`
- [ ] Verify clicking `[1]` scrolls to the definition
- [ ] Verify normal links still work as before
- [ ] `cargo test -p markdown` passes (46 tests)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #13603

Release Notes:

- Added support for footnotes in Markdown Preview.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-10 19:11:27 +05:30
Dong
b150663d45
markdown_preview: Support anchor link for headings (#53184)
## What does this PR did

- Generate [GitHub-flavored heading
slugs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links)
for markdown headings
- Handle `[label](#heading)` same-document anchor links that scroll the
preview and editor to the target heading
- Handle `[label](./file.md#heading)` cross-file anchor links that open
the file, scroll the preview, and move the editor cursor to the heading


https://github.com/user-attachments/assets/ecc468bf-bed0-4543-a988-703025a61bf8

## What to test

- [ ] Create a markdown file with `[Go to section](#section-name)`
links, verify clicking scrolls preview and editor
- [ ] Create two markdown files with cross-file links like `[See
other](./other.md#heading)`, verify file opens and preview scrolls to
heading
- [ ] Verify duplicate headings produce correct slugs (`heading`,
`heading-1`)
- [ ] Verify external URLs (`https://...`) are unaffected

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #18699

Release Notes:

- Added support for anchor links for headings in Markdown Preview.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-09 21:43:51 +05:30
Angel P.
614f67ed2a
markdown_preview: Fix HTML alignment styles not being applied (#53196)
## What This PR Does
This PR adds support for HTML alignment styles to be applied to
Paragraph and Heading elements and their children. Here is what this
looks like before vs after this PR (both images use the same markdown
below):

```markdown
<p style="text-align: center;">
  <a target="_blank" href="https://github.com/"><img width="150" height="150" src="https://upload.wikimedia.org/wikipedia/commons/c/c2/GitHub_Invertocat_Logo.svg"></a>
</p>
```

**BEFORE:**

<img width="742" height="242" alt="image"
src="https://github.com/user-attachments/assets/4ca8b8d9-0606-45f5-8a0e-cafaaac47d97"
/>

**AFTER:**

<img width="1274" height="267" alt="image"
src="https://github.com/user-attachments/assets/2c347ce7-75b9-4ef6-9598-b1eda7272ef5"
/>

## Notes
I used `style="text-align: center|left|right;"` instead of
`align="center|right|left"` since `align` has been [deprecated in
HTML5](https://www.w3.org/TR/2011/WD-html5-author-20110809/obsolete.html)
for block-level elements. The issue this PR solves mentioned that github
supports the `align="center|right|left"` attribute, so I'm unsure if the
Zed team would want to have parity there. Feel free to let me know if
that would be something that should be added, however for now I've
decided to follow the HTML5 standard.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes https://github.com/zed-industries/zed/issues/51062

Release Notes:

- Fixed HTML alignment styles not being applied in markdown previews

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-07 14:30:22 +05:30
Ahmet Kaan Gümüş
fd4d8444cf
markdown_preview: Add search support to markdown preview (#52502)
Context

The markdown preview had no search functionality — pressing Ctrl+F did
nothing. This PR implements the SearchableItem trait for
MarkdownPreviewView, enabling in-pane text search with match
highlighting and navigation.

  Changes span four crates:

- project: Added SearchQuery::search_str() — a synchronous method to
search plain &str text, since the existing search() only works on
BufferSnapshot.
- markdown: Added search highlight storage to the Markdown entity and
paint_search_highlights to MarkdownElement. Extracted the existing
selection painting into a reusable paint_highlight_range helper to avoid
duplicating quad-painting logic.
- markdown_preview: Implemented SearchableItem with full match
navigation, active match tracking, and proper SearchEvent emission
matching Editor behavior.
- Keymaps: Added buffer_search::Deploy bindings to the MarkdownPreview
context on all three platforms.
  
The PR hopefully Closes
https://github.com/zed-industries/zed/issues/27154

  How to Review

1. crates/project/src/search.rs — search_str method at the end of impl
SearchQuery. Handles both Text (AhoCorasick) and Regex variants with
whole-word and multiline support.
  2. crates/markdown/src/markdown.rs — Three areas:
    - New fields and methods on Markdown struct (~line 264, 512-548)
- paint_highlight_range extraction and paint_search_highlights (~line
1059-1170)
    - The single-line addition in Element::paint (~line 2003)
3. crates/markdown_preview/src/markdown_preview_view.rs — The main
change. Focus on:
- SearchEvent::MatchesInvalidated emission in schedule_markdown_update
(line 384)
    - EventEmitter<SearchEvent> and as_searchable (lines 723, 748-754)
- The SearchableItem impl (lines 779-927), especially active_match_index
which computes position from old highlights to handle query changes
correctly
  4. Keymap files — Two lines each for Linux/Windows, one for macOS.

  Self-Review Checklist

- [ x ] I've reviewed my own diff for quality, security, and reliability
- [ x ] Unsafe blocks (if any) have justifying comments (no unsafe)
- [ x ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
(should be 😄 )
- [ - ] Tests cover the new/changed behavior (not sure)
- [ - ] Performance impact has been considered and is acceptable (I'm
not sure about it and it would be nice to see experienced people to
test)


Release Notes:
- Added search support (Ctrl+F / Cmd+F) to the markdown preview

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2026-04-06 16:42:20 +00:00
Smit Barmase
a48bab76e8
markdown: Fix horizontal rules and blockquotes not visible (#53223)
Closes #53167

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed horizontal rules and blockquotes not being visible in the
Markdown preview.
2026-04-06 08:17:51 +00:00
João Soares
843615c35e
markdown: Fix visible escape characters in LSP diagnostics (#51766)
Closes #51622

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Fixed markdown escape characters being visible in LSP diagnostic
messages when leading whitespace caused indented code blocks

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-04-03 08:26:08 +00:00
Xiaobo Liu
c5446117c1
markdown: Refactor code block copy button visibility to use enum (#52817)
Release Notes:

- N/A

---------

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Co-authored-by: Finn Evers <finn.evers@outlook.de>
Co-authored-by: MrSubidubi <finn@zed.dev>
2026-04-01 09:05:03 +00:00
João Soares
878aba817c
markdown: Show copy button on hover to prevent overlapping code block… (#52837)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [X] Performance impact has been considered and is acceptable

Closes #52064

Release Notes:

- Fixed copy button overlapping code block content in the Agent panel
(#52064)

## Demo

Before:
<img width="496" height="139" alt="image"
src="https://github.com/user-attachments/assets/6c49ad7f-ae36-4a6b-be72-783ff6e98537"
/>
<img width="411" height="182" alt="image"
src="https://github.com/user-attachments/assets/a4b89407-2ae0-4629-875b-706592e81b34"
/>

After:


https://github.com/user-attachments/assets/a139db06-3909-4a22-881a-836262ed3c36
2026-04-01 03:22:56 +00:00
Mikayla Maki
20b140664d
Fix markdown table rendering in the agent panel (#52864)
This PR reverts part of
https://github.com/zed-industries/zed/pull/50839, as it was causing bad
clipping in the agent panel

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A
2026-04-01 00:10:29 +00:00
Smit Barmase
3e0a0e1dd5
markdown: Skip linkify inside code blocks (#52762)
Profiling streamed agent responses showed `parse_markdown_with_options`
consuming ~50% of CPU cycles. The hot path is `LinkFinder` scanning
every `Text` event, including code block content, where detected URLs
are never rendered as links.

In the profiled case, the markdown had 235k+ URLs inside code blocks,
making linkify extremely costly per-parse. This PR short-circuits the
text-merging + linkify path for code block content.

Release Notes:

- N/A
2026-03-31 11:24:25 +05:30
hnakashima
dbb8afe676
gpui: Fix BGRA conversion for SVG rendering (#52641)
### Description
Fixes swapped red/blue channels when rendering SVG images.

#### Describe the bug

When rendering a full-color SVG into an Image object using
Image::from_bytes(ImageFormat::Svg, ...) on macOS, the resulting bitmap
has its Red and Blue channels swapped. For example, a color specified as
#38BDF8 (Light Blue) in the SVG source appears as yellowish in the
rendered GPUI view.

#### Steps to reproduce
1. Create a GPUI application. 
1. Generate or load an SVG string containing a specific color, for
example:
```xml
   <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
     <rect width="100" height="100" fill="#38BDF8"/>
   </svg>
```
3. Load this SVG into an Image object:
```rust
   let image = Arc::new(Image::from_bytes(
       ImageFormat::Svg,
       svg_string.into_bytes(),
   ));
```
4. Display this image in a view using an img() element. 

#### Expected behavior
The rectangle should be rendered in **Light Blue (#38BDF8)**. 

#### Actual behavior
The rectangle is rendered in **Yellowish Color (#F8BD38)**.

### Self-Review Checklist:

- [X] I've reviewed my own diff for quality, security, and reliability
- [X] Unsafe blocks (if any) have justifying comments
- [X] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [X] Tests cover the new/changed behavior
- [X] Performance impact has been considered and is acceptable

### Closes #ISSUE

### Release Notes:

- Fixed swapped color channels when pasting SVG images from the
clipboard.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
2026-03-29 14:43:05 +00:00
Piotr Osiewicz
93e641166d
theme: Split out theme_settings crate (#52569)
Self-Review Checklist:

- [ ] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A
2026-03-27 14:41:25 +01:00
Smit Barmase
9efe3c5a21
markdown_preview: Refactor to use shared markdown crate (#52008)
We now use the parser and renderer from the `markdown` crate for
Markdown Preview, instead of maintaining two separate code paths.

How it works:

`markdown_preview_view.rs` is now a consumer of `MarkdownElement`. It
acts as a thin wrapper, handling things like resolving URL clicks and
image URLs, which can vary between consumers. It also handles syncing
the editor selection with the active block in the preview. The APIs for
this are provided by `MarkdownElement`.

All the heavy lifting like parsing HTML, rendering block markers on
hover, handling the active block, etc. is done by `MarkdownElement`.
Everything is opt-in. For example, markdown in the Agent Panel can
choose not to enable block marker rendering or HTML parsing, while
Markdown Preview opts into those features.

Final outcome:

For Markdown Preview View:

- Added:
  - Selection support in the preview

- Stays:
  - Syncing between editor and preview
  - Autoscroll
  - Hover and active block markers
  - Checkbox toggling
  - Image rendering
  - Mermaid rendering

For the `markdown` crate:

- No changes for existing consumers like the Agent Panel
- Consumers can now opt into:
  - HTML rendering
  - Block marker rendering
  - Click event handling
  - Custom image resolvers
  - Mermaid rendering

Release Notes:

- N/A
2026-03-26 12:27:39 +05:30
Nathan Sobo
3ce0cd11ec
Extract language_core and grammars crates from language (#52238)
This extracts a `language_core` crate from the existing `language`
crate, and creates a `grammars` data crate. The goal is to separate
tree-sitter grammar infrastructure, language configuration, and LSP
adapter types from the heavier buffer/editor integration layer in
`language`.

## Motivation

The `language` crate pulls in `text`, `theme`, `settings`, `rpc`,
`task`, `fs`, `clock`, `sum_tree`, and `fuzzy` — all of which are needed
for buffer integration (`Buffer`, `SyntaxMap`, `Outline`,
`DiagnosticSet`) but not for grammar parsing or language configuration.
Extracting the core types lets downstream consumers depend on
`language_core` without pulling in the full integration stack.

## Dependency graph after extraction

```
language_core   ← gpui, lsp, tree-sitter, util, collections
grammars        ← language_core, rust_embed, tree-sitter-{rust,python,...}
language        ← language_core, text, theme, settings, rpc, task, fs, ...
languages       ← language, grammars
```

## What moved to `language_core`

- `Grammar`, `GrammarId`, and all query config/builder types
- `LanguageConfig`, `LanguageMatcher`, bracket/comment/indent config
types
- `HighlightMap`, `HighlightId` (theme-dependent free functions
`highlight_style` and `highlight_name` stay in `language`)
- `LanguageName`, `LanguageId`
- `LanguageQueries`, `QUERY_FILENAME_PREFIXES`
- `CodeLabel`, `CodeLabelBuilder`, `Symbol`
- `Diagnostic`, `DiagnosticSourceKind`
- `Toolchain`, `ToolchainScope`, `ToolchainList`, `ToolchainMetadata`
- `ManifestName`
- `SoftWrap`
- LSP data types: `BinaryStatus`, `ServerHealth`,
`LanguageServerStatusUpdate`, `PromptResponseContext`, `ToLspPosition`

## What stays in `language`

- `Buffer`, `BufferSnapshot`, `SyntaxMap`, `Outline`, `DiagnosticSet`,
`LanguageScope`
- `LspAdapter`, `CachedLspAdapter`, `LspAdapterDelegate` (reference
`Arc<Language>` and `WorktreeId`)
- `ToolchainLister`, `LanguageToolchainStore` (reference `task` and
`settings` types)
- `ManifestQuery`, `ManifestProvider`, `ManifestDelegate` (reference
`WorktreeId`)
- Parser/query cursor pools, `PLAIN_TEXT`, point conversion functions

## What the `grammars` crate provides

- Embedded `.scm` query files and `config.toml` files for all built-in
languages (via `rust_embed`)
- `load_queries(name)`, `load_config(name)`,
`load_config_for_feature(name, grammars_loaded)`, and `get_file(path)`
functions
- `native_grammars()` for tree-sitter grammar registration (behind
`load-grammars` feature)

## Pre-cleanup (also in this PR)

- Removed unused `Option<&Buffer>` from
`LspAdapter::process_diagnostics`
- Removed unused `&App` from `LspAdapter::retain_old_diagnostic`
- Removed `fs: &dyn Fs` from `ToolchainLister` trait methods
(`PythonToolchainProvider` captures `fs` at construction time instead)
- Moved `Diagnostic`/`DiagnosticSourceKind` out of `buffer.rs` into
their own module

## Backward compatibility

The `language` crate re-exports everything from `language_core`, so
existing `use language::Grammar` (etc.) continues to work unchanged. The
only downstream change required is importing `CodeLabelExt` where
`.fallback_for_completion()` is called on the now-foreign `CodeLabel`
type.

Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
Co-authored-by: Tom Houlé <tom@tomhoule.com>
2026-03-25 23:41:09 +00:00
Abhiraj Damodare
e314c023b3
gpui: Add grid_cols_max_contentfor content-based column widths (#50839)
Summary
Add a new grid_cols_max_content GPUI styling API that uses minmax(0,
max-content) for grid column sizing. This allows columns to
automatically size based on their content width while remaining
responsive when the container shrinks.

Applied the fix to both markdown preview (markdown_renderer.rs) and
agent panel (markdown.rs) table rendering. Table borders now wrap
tightly around content instead of stretching to full container width.

Fixes #50044

Approach
A new grid_cols_max_content API is added (as discussed with
@MikaylaMaki):

style.rs — New grid_cols_max_content: Option<u16> field
styled.rs — New .grid_cols_max_content(cols) builder method
taffy.rs — New to_grid_repeat_max_content() using minmax(0, max-content)
markdown_renderer.rs — Swapped .grid_cols() → .grid_cols_max_content(),
moved border to grid div, wrapped in v_flex().items_start() so border
hugs content
markdown.rs — Applied same fix for agent panel tables:
grid_cols_max_content, border on grid div, wrapped in
div().flex().flex_col().items_start() container
Screenshots
Before (equal-width columns, border stretches full width):

<img width="1386" height="890" alt="Screenshot 2026-03-06 at 2 17 54 PM"
src="https://github.com/user-attachments/assets/42cf76c4-6eba-4919-9b16-78c7fc823315"
/>

<img width="2555" height="1308" alt="original issue"
src="https://github.com/user-attachments/assets/22b0fc02-5203-48bb-8f03-7aa8255197cc"
/>



After — Markdown Preview and Agent Panel
<img width="2554" height="1317" alt="Screenshot 2026-03-07 at 2 29
28 PM"
src="https://github.com/user-attachments/assets/8849988e-9ba8-4388-9c29-a255e0ecc52b"
/>


Before you mark this PR as ready for review, make sure that you have:

Added a solid test coverage and/or screenshots from doing manual testing
 Done a self-review taking into account security and performance aspects
 Aligned any UI changes with the UI checklist
Release Notes:

Fixed markdown table columns to use content-based auto-width instead of
equal-width distribution in both markdown preview and agent panel
(#50044).

---------

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2026-03-19 16:15:44 +00:00
iam-liam
bb769b937a
markdown: Render checkboxes in markdown table cells (#50595)
Render `[x]` and `[ ]` as checkbox widgets when they appear as the sole
content of a markdown table cell. Previously these were displayed as raw
text. List-item checkboxes were already rendered correctly; this extends
the same treatment to table cells.

Fixes #50045.

## What this does

- Table cells containing only `[x]`, `[X]`, or `[ ]` now render as
visual checkboxes instead of plain text
- Both markdown rendering paths are covered: the `markdown` crate (agent
panel, chat) and the `markdown_preview` crate (file preview)
- Checkboxes are display-only, matching the existing list-item checkbox
behavior

## How it works

pulldown-cmark splits `[x]` in table cells into three separate `Text`
events (`[`, `x`, `]`) rather than emitting a `TaskListMarker` event
(which only fires for list items per the GFM spec). The fix operates at
each crate's natural interception point:

- **`markdown` crate**: After all text events for a table cell have been
buffered, `replace_pending_checkbox()` checks the accumulated text
before the cell div is finalized. If it matches the checkbox pattern,
the pending text is replaced with a `Checkbox` widget.
- **`markdown_preview` crate**: In `render_markdown_text()`, text chunks
whose trimmed content matches the checkbox pattern are rendered as
`MarkdownCheckbox` widgets instead of `InteractiveText`.

## Scope

Three files, purely additive:

- `crates/markdown/src/markdown.rs` — `replace_pending_checkbox()` on
builder, called at `TableCell` end
- `crates/markdown_preview/src/markdown_renderer.rs` — checkbox
detection in `render_markdown_text()`
- `crates/markdown_preview/src/markdown_parser.rs` — test only

No changes to parser data models, GPUI, or any shared infrastructure.

## What's not in scope

- **HTML `<input type="checkbox">`** — pulldown-cmark strips these as
raw HTML. Supporting them requires HTML tag parsing, which is a separate
concern.
- **Interactive (click-to-toggle) checkboxes in tables** — table
checkboxes are display-only. List-item checkboxes in Zed support
Cmd+click toggling, but extending that to table cells would require
tracking source ranges across the split parser events, which is a
separate enhancement.

## Follow-up

Table checkbox interactivity (Cmd+click toggle) is straightforward to
add as a follow-up — the source ranges are already available in
`markdown_preview`, and the `markdown` crate would need minor callback
plumbing.

## Screenshots

**Markdown checkbox before**

<img width="1603" height="863" alt="md-checkbox-before-1"
src="https://github.com/user-attachments/assets/8539d79d-c74f-4d14-a3e5-525e4d0083aa"
/>

<img width="1599" height="892" alt="md-checkbox-before-2"
src="https://github.com/user-attachments/assets/7badfab1-651f-4fab-8879-deb109c56670"
/>

**Markdown checkbox after**

<img width="1832" height="889" alt="md-checkbox-after-1"
src="https://github.com/user-attachments/assets/463b6334-9f50-41c0-ab7e-24d238244873"
/>

<img width="1795" height="886" alt="md-checkbox-after-2"
src="https://github.com/user-attachments/assets/57d3d9de-1d23-42ba-bc0a-5aa0c699b13d"
/>

## Test plan

**Unit tests** (2 new):
- `test_table_with_checkboxes` (markdown_preview) — parser delivers
`[x]`/`[ ]` text into table cell structures
- `test_table_checkbox_detection` (markdown) — parser events accumulate
checkbox text in table cells, confirming `replace_pending_checkbox`
detection logic

**Automated**:
- [x] `cargo test -p markdown` — 27 tests pass (26 existing + 1 new)
- [x] `cargo test -p markdown_preview` — 61 tests pass (60 existing + 1
new)

**Manual** (verified against `test-checkbox-table.md`):
- [x] Basic `[x]`/`[ ]` in a status column
- [x] Checkbox-only column alongside text
- [x] Multiple checkbox columns in one table
- [x] Left, center, and right column alignments
- [x] Uppercase `[X]` variant
- [x] Leading/trailing whitespace in cell
- [x] Checkboxes alongside other inline elements (links, bold text)
- [x] Single-column and minimal two-column tables
- [x] Normal table text unaffected by detection
- [x] List checkboxes still render correctly (regression)
- [x] Agent panel: asked agent to output table with checkbox columns

Release Notes:

- Fixed `[x]` and `[ ]` checkboxes not rendering in markdown table cells
(#50045)
2026-03-19 15:39:03 +00:00
Kunall Banerjee
0be32ba939
markdown_preview: Enable parser options individually (#50440)
Closes #50170.

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Enable parser options individually to avoid rendering issues
2026-03-05 14:00:08 +00:00
Smit Barmase
92c99c6bfd
markdown: Fix horizontal autoscroll for code blocks in Agent Panel (#50416)
Release Notes:

- Fixed Agent Panel code blocks not scrolling horizontally during text
selection.
2026-03-01 02:42:35 +05:30
Piotr Osiewicz
bc31ad4a8c
gpui: Extract gpui_platform out of gpui (#49277)
#2874 on steroids

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [ ] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: Eric Holk <eric@zed.dev>
2026-02-19 18:57:49 +01:00
Dino
da7b8f2939
Fix font weight in multiple elements (#49539)
* Update the font weight used in the Agent Panel's editor to respect the
`buffer_font_weight` setting.
* Update the font weight used in the Command Palette to use the
`ui_font_weight` setting value, seeing as the command palette is using
the `ui_font` settings for the font family and features
* Update the font weight used in the popovers to match the
`buffer_font_weight`, as it's also using the buffer font family and
features
* Update the `LabelLike.buffer_font` method in order to correctly set
the font weight, which fixes the font weight used in the file header
when displaying a multibuffer editor

Release Notes:

- Fixed incorrect font weight in the Command Pallete input
- Fixed missing font weight the Agent Panel's buffer
- Fixed missing font weight the Hover Popover
- Fixed missing font weight in Markdown's code block and inline code

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-02-19 17:49:59 +00:00
Xiaobo Liu
70c47e96bd
markdown: Fix markdown table selection hit testing (#47720)
Release Notes:

- Fixed markdown table selection hit testing

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2026-02-02 16:37:58 +00:00
Kyle Kelley
446227cf6d
repl: Streamline Markdown output usage (#47713)
Brought the Markdown output up to date with how Markdown is used in the
Agent panel. This fixed an issue with outputs that were too large for
the execution view as well as made sure that markdown would wrap.

<img width="3222" height="2334" alt="image"
src="https://github.com/user-attachments/assets/c65efa53-b792-4529-909a-9117053e30be"
/>

Release Notes:

- N/A
2026-01-28 17:42:07 +00:00
Smit Barmase
1c7fa87d18
markdown: Improve double-click word selection using CharClassifier (#47844)
Previously, double-click word selection in markdown used simple
space-based boundaries, so `foo.bar()` would be selected as a single
word.

Now we use `CharClassifier` which properly handles word boundaries:

- **Regular markdown text**: Punctuation (`.`, `(`, `)`, etc.) now acts
as word boundaries. Double-clicking on `foo.bar()` selects just `foo` or
`bar`.
- **Code blocks**: Uses the language's word characters. For example, in
JavaScript, `$foo` and `#bar` are selected as whole words since `$` and
`#` are configured as word characters.

Release Notes:

- Improved double-click word selection in Agent Panel to respect
punctuation and language-specific word characters.
2026-01-28 16:30:24 +05:30
Danilo Leal
e1e7676b5a
ui: Improve performance in the CopyButton component (#47292)
This PR improves the performance of the `CopyButton` component by
tracking the copied state locally through a `CopyButtonState` struct
instead of making an OS call every time the component re-renders. Also
pushing a slight improvement here by resetting the state after two
seconds so as to make the check mark go away after you clicked to copy.

Release Notes:

- N/A
2026-01-21 13:40:42 -03:00
Kunall Banerjee
6718320373
agent_ui: Use .w_full() instead of .size_full() when rendering markdown tables in lists (#46783)
This way, the table:
- Determines its height by the grid’s content
- Still keeps `width: 100%` so it fills its container horizontally

| Before | After |
|--------|--------|
| <img width="1732" height="1125" alt="image"
src="https://github.com/user-attachments/assets/5d739664-5793-4c16-a765-dc373c7cb10f"
/> | <img width="1732" height="1125" alt="image"
src="https://github.com/user-attachments/assets/c857d28b-67c2-4ba1-b4a6-869a154b050b"
/> |

Closes #46768

Release Notes:

- Fixed issue where markdown tables rendered within lists would overlap
items above/below it
2026-01-19 12:05:13 -05:00
Conrad Irwin
22415e5f49
Fix copying from agent panel including extra backtick (#46763)
Closes #ISSUE

Release Notes:

- Fixed cmd-c in the agent panel to not include spurious trailing `'s.
2026-01-13 22:38:28 -07:00
drbh
74c3608350
Update pulldown-cmark to v0.13.0 to fix crash (#46267)
Hi Zed team thank you for the awesome editor!

I recently stumbled upon a markdown sequence that seems to cause a crash

```md
-	[	] -
\
-
```

*easier to read escape characters below

```rust
let crash_input = "-\t[\t] -\r\\\n-"
println!("{}", crash_input)
```

## how to reproduce

1. copy the markdown above
2. save the file
3. `[shift]` + `[cmd]` + `p` to open the command palette
4. select `markdown: open preview`
5. crash

I've confirmed that the issue is a bug in pulldown-cmark version 12, and
has been resolved in version
[v0.13.0](https://github.com/pulldown-cmark/pulldown-cmark/releases/tag/v0.13.0)
and specifically fixed in
https://github.com/pulldown-cmark/pulldown-cmark/pull/1017

this PR simply bumps the pulldown-cmark version in zed which resolves
the crash on my local machine.


## recording 



https://github.com/user-attachments/assets/dc77132f-0d43-40f3-9841-0bf34fe714fb


Release Notes:

- Fixes crash due to markdown parsing via bumping pulldown-cmark
2026-01-08 02:15:34 +01:00
Danilo Leal
6d947b7746
ui: Add a CopyButton component (#45821)
There were several places adding a copy icon button, so thought of
encapsulating the logic to copy a given string into the clipboard (and
other small details like swapping the icon and tooltip if copied) into a
component, making it easier to introduce this sort of functionality in
the future, with fewer lines of code.

All it takes (for the simplest case) is:

```rs
CopyButton::new(your_message)
```

<img width="600" height="714" alt="Screenshot 2025-12-29 at 10  50@2x"
src="https://github.com/user-attachments/assets/e6949863-a056-4855-82d8-e4ffb5d62c90"
/>

Release Notes:

- N/A
2025-12-29 11:01:19 -03:00
Danilo Leal
1281f4672c
markdown: Add support for right-click menu copy item (#45572)
In https://github.com/zed-industries/zed/pull/45440, we're implementing
the ability to right-click in the agent panel and copy the rendered
markdown. However, that presented itself as not as straightforward as
just making the menu item fire the `CopyAsMarkdown` action because any
selection in markdown is cleared after a new mouse click, and for the
right-click copy menu item to work, we need to persist that selection
even after the menu itself is opened and the "Copy" menu item is
clicked.

This all demanded a bit of work in the markdown file itself, and given
we may want to use this functionality for other non-agent thread view
markdown use cases in the future, I felt like it'd be better breaking it
down into a separate PR that we can more easily track in the future.

The context menu still needs to be built in the place where the markdown
is created and rendered, though. This PR only adds the infrastructure
needed so that this menu can simply fire the `CopyAsMarkdown` and make
the copying work.

Release Notes:

- N/A
2025-12-23 12:09:10 -03:00
Xipeng Jin
f084e20c56
Fix stale pending keybinding indicators on focus change (#44678)
Closes #ISSUE

Problem:

- The status bar’s pending keystroke indicator (shown next to --NORMAL--
in Vim mode) didn’t clear when focus moved to another context, e.g.
hitting g in the editor then clicking the Git panel. The keymap state
correctly canceled the prefix, but observers that render the indicator
never received a “pending input changed” notification, so the UI kept
showing stale prefixes until a new keystroke occurred.

Fix:

- The change introduces a `pending_input_changed_queued` flag and a new
helper `notify_pending_input_if_needed` which will flushes the queued
notification as soon as we have an App context. The
`pending_input_changed` now resets the flag after notifying subscribers.

Before:


https://github.com/user-attachments/assets/7bec4c34-acbf-42bd-b0d1-88df5ff099aa

After:



https://github.com/user-attachments/assets/2264dc93-3405-4d63-ad8f-50ada6733ae7



Release Notes:

- Fixed: pending keybinding prefixes on the status bar now clear
immediately when focus moves to another panel or UI context.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-12-17 16:51:16 +00:00
Danilo Leal
9b8bc63524
Revert "Remove CopyAsMarkdown" (#45101)
Reverts https://github.com/zed-industries/zed/pull/44933.

It turns out that if you're copying agent responses to paste it anywhere
else that isn't the message editor (e.g., for a follow up prompt),
getting Markdown formatting is helpful. However, with the revert, the
underlying issue in https://github.com/zed-industries/zed/issues/42958
remains, so I'll reopen that issue, unfortunately.

Release Notes:

- N/A
2025-12-17 09:49:19 -03:00
tidely
949cbc2b18
gpui: Remove intermediate allocations when reconstructing text from a TextLayout (#45037)
Closes #ISSUE

Remove some intermediate allocations when reconstructing text or wrapped
text from a `TextLayout`. Currently creates a intermediate `Vec<String>`
which gets joined, when you could join an `impl Iterator<Item = &str>`

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-12-17 08:56:05 +01:00