Skip to content

markdown_preview: Fix Ctrl+S saving checkbox toggle state - #53236

Merged
osiewicz merged 6 commits into
zed-industries:mainfrom
Priyansh4444:fix-markdown-preview-save-from-preview
Apr 27, 2026
Merged

markdown_preview: Fix Ctrl+S saving checkbox toggle state#53236
osiewicz merged 6 commits into
zed-industries:mainfrom
Priyansh4444:fix-markdown-preview-save-from-preview

Conversation

@Priyansh4444

@Priyansh4444 Priyansh4444 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Changes Made:

  • Adding the Item::can_save(), save(), save_as(), can_save_as() functions to help the Editor save when a checkbox is toggled
  • Small refactor to seperate checkbox toggle and refreshing preview
  • Adding support for both /... and \\... for windows users. [NOTE: I no longer own a window's machine and I am unsure if this is correct, and will fix it immediately if this is wrong]
  • Resolving preview paths, strips out the fragment, and image paths are coalesced to None if they don't exist
  • Adding Tests for the added behaviour [NOTE: would love feedback since this is the first time I am writing tests, and had a bit of assistance from an AI, but manually reviewed the code and ran the application and it seemed fine]

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
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #46901

Release Notes:

  • Fixed Crtl+S saving while toggling checkbox in preview mode

MarkdownPreviewView

- Implement `can_save`, `can_save_as`, `save`, and `save_as` for
  `MarkdownPreviewView` (to help save when a checkbox is toggled)
- Fix preview path resolution to ignore URL fragments and handle
  workspace-absolute image paths correctly

- Add and update tests for path and image resolution, including fragment
  and URL-encoded cases
- Add test dependencies to Cargo.toml for improved test coverage
@cla-bot

cla-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Priyansh4444 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 6, 2026
@Priyansh4444

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 6, 2026
@cla-bot

cla-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

…w-save-from-preview

# Conflicts:
#	Cargo.lock
#	crates/markdown_preview/src/markdown_preview_view.rs
@Priyansh4444
Priyansh4444 marked this pull request as ready for review April 7, 2026 00:31
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from a team, nathansobo and osiewicz and removed request for a team April 7, 2026 00:32
@Priyansh4444

Copy link
Copy Markdown
Contributor Author

CC: @esthertrapadoux

@Priyansh4444

Copy link
Copy Markdown
Contributor Author
2026-04-06.17-41-34.mp4

@maxdeviant maxdeviant changed the title markdown_preview: fix: Crtl+S saving checkbox toggle state markdown_preview: Fix Ctrl+S saving checkbox toggle state Apr 7, 2026
Comment thread crates/markdown_preview/src/markdown_preview_view.rs Outdated
Comment thread crates/markdown_preview/src/markdown_preview_view.rs Outdated
Comment thread crates/markdown_preview/src/markdown_preview_view.rs
Comment thread crates/markdown_preview/src/markdown_preview_view.rs
@Priyansh4444
Priyansh4444 requested a review from osiewicz April 22, 2026 07:54
@Priyansh4444

Copy link
Copy Markdown
Contributor Author

Thank you so much for the comments @osiewicz, it is ready for review again!

@osiewicz osiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@osiewicz
osiewicz added this pull request to the merge queue Apr 27, 2026
Merged via the queue into zed-industries:main with commit df92d59 Apr 27, 2026
31 checks passed
@Priyansh4444
Priyansh4444 deleted the fix-markdown-preview-save-from-preview branch April 27, 2026 11:20
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
…ries#53236)

Changes Made:

- Adding the `Item::can_save()`, `save()`, `save_as()`, `can_save_as()`
functions to help the Editor save when a checkbox is toggled
- Small refactor to seperate checkbox toggle and refreshing preview
- Adding support for both `/...` and `\\...` for windows users. [NOTE: I
no longer own a window's machine and I am unsure if this is correct, and
will fix it immediately if this is wrong]
- Resolving preview paths, strips out the fragment, and image paths are
coalesced to None if they don't exist
- Adding Tests for the added behaviour [NOTE: would love feedback since
this is the first time I am writing tests, and had a bit of assistance
from an AI, but manually reviewed the code and ran the application and
it seemed fine]

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 zed-industries#46901

Release Notes:

- Fixed Crtl+S saving while toggling checkbox in preview mode
benbrandt added a commit that referenced this pull request May 7, 2026
If you implement can_save, you need to also support reload. Fix a bug
introduced in #53236
zed-zippy Bot added a commit that referenced this pull request May 7, 2026
…56026)

Cherry-pick of #56016 to preview

----
If you implement can_save, you need to also support reload. Fix a bug
introduced in #53236

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 missing reload implementation for markdown preview.

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
zed-zippy Bot added a commit that referenced this pull request May 7, 2026
…56027)

Cherry-pick of #56016 to stable

----
If you implement can_save, you need to also support reload. Fix a bug
introduced in #53236

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 missing reload implementation for markdown preview.

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
strank pushed a commit to strank/zed that referenced this pull request May 7, 2026
If you implement can_save, you need to also support reload. Fix a bug
introduced in zed-industries#53236

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 missing reload implementation for markdown preview.
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
…ries#53236)

Changes Made:

- Adding the `Item::can_save()`, `save()`, `save_as()`, `can_save_as()`
functions to help the Editor save when a checkbox is toggled
- Small refactor to seperate checkbox toggle and refreshing preview
- Adding support for both `/...` and `\\...` for windows users. [NOTE: I
no longer own a window's machine and I am unsure if this is correct, and
will fix it immediately if this is wrong]
- Resolving preview paths, strips out the fragment, and image paths are
coalesced to None if they don't exist
- Adding Tests for the added behaviour [NOTE: would love feedback since
this is the first time I am writing tests, and had a bit of assistance
from an AI, but manually reviewed the code and ran the application and
it seemed fine]

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 zed-industries#46901

Release Notes:

- Fixed Crtl+S saving while toggling checkbox in preview mode
Nkr1shna pushed a commit to neozed-industries/neo-zed that referenced this pull request May 11, 2026
…k to stable) (zed-industries#56027)

Cherry-pick of zed-industries#56016 to stable

----
If you implement can_save, you need to also support reload. Fix a bug
introduced in zed-industries#53236

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 missing reload implementation for markdown preview.

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
Nkr1shna pushed a commit to neozed-industries/neo-zed that referenced this pull request May 13, 2026
…k to stable) (zed-industries#56027)

Cherry-pick of zed-industries#56016 to stable

----
If you implement can_save, you need to also support reload. Fix a bug
introduced in zed-industries#53236

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 missing reload implementation for markdown preview.

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…ries#53236)

Changes Made:

- Adding the `Item::can_save()`, `save()`, `save_as()`, `can_save_as()`
functions to help the Editor save when a checkbox is toggled
- Small refactor to seperate checkbox toggle and refreshing preview
- Adding support for both `/...` and `\\...` for windows users. [NOTE: I
no longer own a window's machine and I am unsure if this is correct, and
will fix it immediately if this is wrong]
- Resolving preview paths, strips out the fragment, and image paths are
coalesced to None if they don't exist
- Adding Tests for the added behaviour [NOTE: would love feedback since
this is the first time I am writing tests, and had a bit of assistance
from an AI, but manually reviewed the code and ran the application and
it seemed fine]

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 zed-industries#46901

Release Notes:

- Fixed Crtl+S saving while toggling checkbox in preview mode
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
If you implement can_save, you need to also support reload. Fix a bug
introduced in zed-industries#53236

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 missing reload implementation for markdown preview.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ries#53236)

Changes Made:

- Adding the `Item::can_save()`, `save()`, `save_as()`, `can_save_as()`
functions to help the Editor save when a checkbox is toggled
- Small refactor to seperate checkbox toggle and refreshing preview
- Adding support for both `/...` and `\\...` for windows users. [NOTE: I
no longer own a window's machine and I am unsure if this is correct, and
will fix it immediately if this is wrong]
- Resolving preview paths, strips out the fragment, and image paths are
coalesced to None if they don't exist
- Adding Tests for the added behaviour [NOTE: would love feedback since
this is the first time I am writing tests, and had a bit of assistance
from an AI, but manually reviewed the code and ran the application and
it seemed fine]

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 zed-industries#46901

Release Notes:

- Fixed Crtl+S saving while toggling checkbox in preview mode
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
If you implement can_save, you need to also support reload. Fix a bug
introduced in zed-industries#53236

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 missing reload implementation for markdown preview.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to save source Markdown file via Ctrl+S when focused in preview pane after toggling task items

4 participants