editor: Save base buffers when applying changes from their branches (#19562)

This PR makes it so that when we apply changes within a branch
buffer—currently just the edits buffer—we save the underlying buffer.

This also fixes an issue where new files created via edits were not
properly flushed to disk.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Marshall Bowers 2024-10-22 14:10:11 -04:00 committed by GitHub
parent d8d84bf5d4
commit 5dbf68ddc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 30 deletions

View file

@ -298,6 +298,20 @@ impl Item for ProposedChangesEditor {
Item::set_nav_history(editor, nav_history, cx)
});
}
fn can_save(&self, cx: &AppContext) -> bool {
self.editor.read(cx).can_save(cx)
}
fn save(
&mut self,
format: bool,
project: Model<Project>,
cx: &mut ViewContext<Self>,
) -> Task<gpui::Result<()>> {
self.editor
.update(cx, |editor, cx| Item::save(editor, format, project, cx))
}
}
impl ProposedChangesEditorToolbar {
@ -323,7 +337,7 @@ impl Render for ProposedChangesEditorToolbar {
if let Some(editor) = &editor {
editor.update(cx, |editor, cx| {
editor.editor.update(cx, |editor, cx| {
editor.apply_all_changes(cx);
editor.apply_all_diff_hunks(cx);
})
});
}