Accept finished inline transformations only if the user saves manually (#16112)
Closes https://github.com/zed-industries/zed/issues/16042 This commit modifies the behavior of inline transformations to only accept finished transformations when the user manually saves the file. Previously, transformations were automatically accepted on any save event, including autosaves. This was achieved by updating the `Pane` and `Workspace` structs to emit a new `UserSavedItem` event when a manual save occurs, and modifying the `InlineAssistant` to register and handle this new event (instead of `editor::Saved`). Release Notes: - N/A
This commit is contained in:
parent
48f6193628
commit
a15a9565ab
4 changed files with 74 additions and 14 deletions
|
@ -166,16 +166,28 @@ impl DeploySearch {
|
|||
const MAX_NAVIGATION_HISTORY_LEN: usize = 1024;
|
||||
|
||||
pub enum Event {
|
||||
AddItem { item: Box<dyn ItemHandle> },
|
||||
ActivateItem { local: bool },
|
||||
AddItem {
|
||||
item: Box<dyn ItemHandle>,
|
||||
},
|
||||
ActivateItem {
|
||||
local: bool,
|
||||
},
|
||||
Remove,
|
||||
RemoveItem { idx: usize },
|
||||
RemovedItem { item_id: EntityId },
|
||||
RemoveItem {
|
||||
idx: usize,
|
||||
},
|
||||
RemovedItem {
|
||||
item_id: EntityId,
|
||||
},
|
||||
Split(SplitDirection),
|
||||
ChangeItemTitle,
|
||||
Focus,
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
UserSavedItem {
|
||||
item: Box<dyn WeakItemHandle>,
|
||||
save_intent: SaveIntent,
|
||||
},
|
||||
}
|
||||
|
||||
impl fmt::Debug for Event {
|
||||
|
@ -203,6 +215,11 @@ impl fmt::Debug for Event {
|
|||
Event::Focus => f.write_str("Focus"),
|
||||
Event::ZoomIn => f.write_str("ZoomIn"),
|
||||
Event::ZoomOut => f.write_str("ZoomOut"),
|
||||
Event::UserSavedItem { item, save_intent } => f
|
||||
.debug_struct("UserSavedItem")
|
||||
.field("item", &item.id())
|
||||
.field("save_intent", save_intent)
|
||||
.finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1494,7 +1511,13 @@ impl Pane {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(true)
|
||||
pane.update(cx, |_, cx| {
|
||||
cx.emit(Event::UserSavedItem {
|
||||
item: item.downgrade_item(),
|
||||
save_intent,
|
||||
});
|
||||
true
|
||||
})
|
||||
}
|
||||
|
||||
fn can_autosave_item(item: &dyn ItemHandle, cx: &AppContext) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue