This commit is contained in:
bflatastic committed 2026-11-18 23:19:19 +07:00
commit 4d8d5fa5f9
12 files changed
+745 -20

No files matched your search

+1 -2
View File
@@ -204,8 +204,7 @@ impl Session {
let _ = self.finish_tool_edit_later();
// The switch goes on whatever the lent tool's last actions did, as for the deactivation.
let _ = self.give_back_tool(view);
let acts = self.with_tool_cx(view, |t, cx| t.deactivate(cx));
let _ = self.apply_actions(acts);
let _ = self.deactivate_tool(view);
// A batch leaves its interaction open in the document it leaves, to keep or roll back with
// the rest of the batch; anything else in progress (a drag) is cancelled.
if self.batch_stash.is_none() {
+15 -5
View File
@@ -188,8 +188,7 @@ impl Session {
.then(|| self.tool.options().get("meshPoints").cloned())
.flatten()
.filter(|v| v.as_array().is_some_and(|a| !a.is_empty()));
let acts = self.with_tool_cx(view, |t, cx| t.deactivate(cx));
self.apply_actions(acts)?;
self.deactivate_tool(view)?;
self.keep_tool_settings();
self.tool = self.make_tool(id);
if let Some(selection) = text_selection {
@@ -205,6 +204,18 @@ impl Session {
Ok(())
}
/// Deactivate the tool and apply the actions it returns. In a batch, a Cancel is left out: the
/// batch settled the tool's drag when it began, and the open interaction holds the batch's
/// steps, which the batch keeps or rolls back as a whole.
pub(crate) fn deactivate_tool(&mut self, view: ViewInfo) -> Result<()> {
let mut acts = self.with_tool_cx(view, |t, cx| t.deactivate(cx));
if self.batch_stash.is_some() {
acts.retain(|a| !matches!(a, Action::Cancel));
}
self.apply_actions(acts)?;
Ok(())
}
/// The selection tools other than Direct Selection pick whole objects: with one of them chosen,
/// an object selected in a symbol instance's art gives way to the instance. The revision
/// changes with it, so panels that cache by revision show the instance.
@@ -297,8 +308,7 @@ impl Session {
// them all (#8090). Group Selection picks no mesh points, so the Eyedropper keeps its own.
let mesh_points =
(lender.id() == "eyedropper" && self.tool.id() != "groupSelection").then(|| self.tool.options().get("meshPoints").cloned()).flatten();
let acts = self.with_tool_cx(view, |t, cx| t.deactivate(cx));
let r = self.apply_actions(acts);
let r = self.deactivate_tool(view);
self.keep_tool_settings();
self.tool = lender;
if let Some(points) = mesh_points {
@@ -311,7 +321,7 @@ impl Session {
self.lent_selection = left;
}
self.after_command(None);
r.map(drop)
r
}
/// A fresh `id` tool with the options it keeps ([`settings`]): its last values, from this