Skip to content

Save edited buffers before running a task#48861

Merged
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
abenea:push-yowqqywxulnr
Mar 19, 2026
Merged

Save edited buffers before running a task#48861
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
abenea:push-yowqqywxulnr

Conversation

@abenea
Copy link
Copy Markdown
Contributor

@abenea abenea commented Feb 10, 2026

Save edited buffers before running a task

Introduces a new task field for configuring which buffers are saved. For now, this defaults to saving all buffers, but in the future we could have a global task template to configure this setting for dynamically created tasks.

Closes #10251.

Release Notes:

  • Edited buffers are now saved before running a task. This can be configured with the new "save" field in tasks.json.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 10, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @abenea 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 Feb 10, 2026
@abenea
Copy link
Copy Markdown
Contributor Author

abenea commented Feb 10, 2026

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 10, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @abenea 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'.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 10, 2026

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

@abenea
Copy link
Copy Markdown
Contributor Author

abenea commented Feb 10, 2026

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 10, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 10, 2026

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

@abenea abenea changed the title Implement save_before_task_run setting (fixes #10251). Implement save_before_task_run setting Feb 10, 2026
@abenea abenea marked this pull request as draft February 13, 2026 03:34
@abenea abenea marked this pull request as ready for review February 14, 2026 12:31
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you, after a few tweaks this should be a nice way to add the functionality in general.

@abenea abenea force-pushed the push-yowqqywxulnr branch from 5a912b7 to 91f66bb Compare March 14, 2026 19:58
@abenea abenea requested a review from SomeoneToIgnore March 14, 2026 19:59
@abenea abenea force-pushed the push-yowqqywxulnr branch from 91f66bb to c333a61 Compare March 14, 2026 20:12
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Great to see entities not moved into tasks now, we're almost there.

To add to the settings discussion, let's add the "save the current file" when making the rest of the changes.
It makes sense to have the "save all" by default for now, and work on the "global template" to override global task defaults later.

@abenea abenea force-pushed the push-yowqqywxulnr branch from c333a61 to ef428dc Compare March 17, 2026 19:10
@abenea abenea changed the title Implement save_before_task_run setting Save edited buffers before running a task Mar 17, 2026
@abenea abenea requested a review from SomeoneToIgnore March 17, 2026 19:15
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Great, thank you!

All that's left are style nits and one extra doc entry and we're good to merge.

Introduces a new task field for configuring which buffers are saved. For now, this defaults to saving all buffers, but in the future we could have a global task template to configure this setting for dynamically created tasks.

Needed for zed-industries#10251.

Release Notes:

- Edited buffers are now saved before running a task. This can be configured with the new "save" field in `tasks.json`.
@abenea abenea force-pushed the push-yowqqywxulnr branch from ef428dc to 5634a12 Compare March 18, 2026 21:05
@abenea abenea requested a review from SomeoneToIgnore March 18, 2026 21:14
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) March 19, 2026 08:31
@github-actions github-actions bot added size/M and removed size/M labels Mar 19, 2026
@SomeoneToIgnore SomeoneToIgnore merged commit 0698ecc into zed-industries:main Mar 19, 2026
31 checks passed
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
Save edited buffers before running a task

Introduces a new task field for configuring which buffers are saved. For
now, this defaults to saving all buffers, but in the future we could
have a global task template to configure this setting for dynamically
created tasks.

Needed for zed-industries#10251.

Release Notes:

- Edited buffers are now saved before running a task. This can be
configured with the new "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
Save edited buffers before running a task

Introduces a new task field for configuring which buffers are saved. For
now, this defaults to saving all buffers, but in the future we could
have a global task template to configure this setting for dynamically
created tasks.

Needed for zed-industries#10251.

Release Notes:

- Edited buffers are now saved before running a task. This can be
configured with the new "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
Save edited buffers before running a task

Introduces a new task field for configuring which buffers are saved. For
now, this defaults to saving all buffers, but in the future we could
have a global task template to configure this setting for dynamically
created tasks.

Needed for zed-industries#10251.

Release Notes:

- Edited buffers are now saved before running a task. This can be
configured with the new "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
@injust
Copy link
Copy Markdown
Contributor

injust commented Apr 1, 2026

I don't think saving all buffers is a reasonable default, see #52926.

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

Indeed, seems that we cannot use the "save a single file" mode either and have to fall back to the "save nothing" mode until the global task template configuration is implemented?

@injust
Copy link
Copy Markdown
Contributor

injust commented Apr 1, 2026

seems that we cannot use the "save a single file" mode either

This is what I observed when testing the Python tasks:

  • The play button appears in the gutter for all Python buffers, but the button only works in saved files (Play button appears in gutter for unsaved buffers, but is a no-op #52942). So "save a single file" works fine here.
  • If you run the "task: spawn" command, the Python tasks appear if the current file is a saved Python buffer. However, they also appear as a recently run task. I haven't tested this, but I assume if you run that task while an unsaved buffer is focused, then it will try to save that file?

So defaulting to "save the current file" is significantly less breaking of a change, but there is still an edge case.

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

if you run that task while an unsaved buffer is focused, then it will try to save that file

Yes, well noted, so this implementation is not really ready to be the default in any of the saving options it seems.
It seems that we need more granularity when saving files, to allow us to limit saving to a certain worktree [and a certain buffer in it].

For now, let's keep the "nothing saved" default then, thank you.

@injust
Copy link
Copy Markdown
Contributor

injust commented Apr 2, 2026

For now, let's keep the "nothing saved" default then, thank you.

I put up a quick PR for this, but I haven't built and tested because I don't have a local dev environment set up.

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

Thank you, I've tested that on my machine and it works (had implemented the same fix essentially).

I've also tried to set up a branch with a forward fix where we skip non-worktree-related files, but got stuck at writing the test — maybe someone else later can take a stab at it.

SomeoneToIgnore added a commit that referenced this pull request Apr 2, 2026
Self-Review Checklist:

- [x] 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 #52926
Follow-up to #48861
cc @SomeoneToIgnore

Release Notes:

- Edited buffers are no longer saved by default before running a task,
but you can still configure this using the "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
github-actions bot pushed a commit that referenced this pull request Apr 2, 2026
Self-Review Checklist:

- [x] 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 #52926
Follow-up to #48861
cc @SomeoneToIgnore

Release Notes:

- Edited buffers are no longer saved by default before running a task,
but you can still configure this using the "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
github-actions bot pushed a commit that referenced this pull request Apr 2, 2026
Self-Review Checklist:

- [x] 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 #52926
Follow-up to #48861
cc @SomeoneToIgnore

Release Notes:

- Edited buffers are no longer saved by default before running a task,
but you can still configure this using the "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
SomeoneToIgnore added a commit that referenced this pull request Apr 2, 2026
…k to preview) (#52990)

Cherry-pick of #52976 to preview

----
Self-Review Checklist:

- [x] 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 #52926
Follow-up to #48861
cc @SomeoneToIgnore

Release Notes:

- Edited buffers are no longer saved by default before running a task,
but you can still configure this using the "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>

Co-authored-by: Justin Su <injustsu@gmail.com>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
SomeoneToIgnore added a commit that referenced this pull request Apr 2, 2026
Self-Review Checklist:

- [x] 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 #52926
Follow-up to #48861
cc @SomeoneToIgnore

Release Notes:

- Edited buffers are no longer saved by default before running a task,
but you can still configure this using the "save" field in `tasks.json`.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
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.

Optionally save dirty buffers before running a task

3 participants