From 8a87fcdb50a5be5b012c4f9afc90bef79dbd269e Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Tue, 6 Jul 2021 09:42:08 +0200 Subject: [PATCH] Emit correct events when deselecting all nodes. (https://github.com/enso-org/ide/pull/1664) Original commit: https://github.com/enso-org/ide/commit/63ff1fe4319d24300e9882abfac25b05d422197a --- ide/CHANGELOG.md | 6 ++++++ ide/src/rust/ide/src/ide.rs | 2 +- ide/src/rust/ide/view/graph-editor/src/lib.rs | 5 +++++ ide/src/rust/ide/view/graph-editor/src/selection.rs | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ide/CHANGELOG.md b/ide/CHANGELOG.md index 8275ca603e27..a821e4971a42 100644 --- a/ide/CHANGELOG.md +++ b/ide/CHANGELOG.md @@ -18,6 +18,9 @@ undo last action and cmd+z to redo last undone action. This version of undo redo does not have proper support for text editor and undoing UI changes (like selecting nodes). +- [Fox node selection bug ][1664]. Fix nodes not being deselected correctly in + some circumstances. This would lead to nodes moving too fast when dragged + [1650] or the internal state of the project being inconsistent [1626]. #### EnsoGL (rendering engine) @@ -34,6 +37,9 @@ [1577]: https://github.com/enso-org/ide/pull/1577 [1587]: https://github.com/enso-org/ide/pull/1587 [1602]: https://github.com/enso-org/ide/pull/1602 +[1602]: https://github.com/enso-org/ide/pull/1664 +[1602]: https://github.com/enso-org/ide/pull/1650 +[1602]: https://github.com/enso-org/ide/pull/1626 # Enso 2.0.0-alpha.5 (2021-05-14) diff --git a/ide/src/rust/ide/src/ide.rs b/ide/src/rust/ide/src/ide.rs index 8a46e31bbc09..9538f106f1b5 100644 --- a/ide/src/rust/ide/src/ide.rs +++ b/ide/src/rust/ide/src/ide.rs @@ -65,7 +65,7 @@ impl Ide { let mouse = &scene.mouse.frp; let keyboard = &scene.keyboard.frp; - enso_frp::extend! { TRACE_ALL network + enso_frp::extend! { network on_log_sent <- source::<()>(); mouse_moved <- mouse.position.constant(()); any_mouse_press <- any(mouse.up,mouse.down).constant(()); diff --git a/ide/src/rust/ide/view/graph-editor/src/lib.rs b/ide/src/rust/ide/view/graph-editor/src/lib.rs index bdcba7ffa104..0367029b75e2 100644 --- a/ide/src/rust/ide/view/graph-editor/src/lib.rs +++ b/ide/src/rust/ide/view/graph-editor/src/lib.rs @@ -960,6 +960,11 @@ impl Nodes { fn select(&self, node_id:impl Into) { let node_id = node_id.into(); if let Some(node) = self.get_cloned_ref(&node_id) { + // Remove previous instances and add new selection at end of the list, indicating that + // this node was selected last, superseding the previous selection. + while self.selected.contains(&node_id) { + self.selected.remove_item(&node_id) + } self.selected.push(node_id); node.frp.select.emit(()); } diff --git a/ide/src/rust/ide/view/graph-editor/src/selection.rs b/ide/src/rust/ide/view/graph-editor/src/selection.rs index 9ca2dfe846e4..52ae632a72ab 100644 --- a/ide/src/rust/ide/view/graph-editor/src/selection.rs +++ b/ide/src/rust/ide/view/graph-editor/src/selection.rs @@ -310,6 +310,7 @@ impl Controller { frp::extend! { network + deselect_all_nodes <- any_(...); enable_area_selection <- source(); @@ -373,7 +374,7 @@ impl Controller { keep_selection <- selection_mode.map(|t| *t != Mode::Normal); deselect_on_select <- drag_start.gate_not(&keep_selection); - eval_ deselect_on_select ( nodes.deselect_all() ); + deselect_all_nodes <+ deselect_on_select; cursor_selection_nodes.insert <+ node_info; cursor_selection_nodes.remove_difference_with_vec <+ nodes_in_bb; @@ -417,7 +418,6 @@ impl Controller { |_,mode,was_selected| mode.single_should_deselect(*was_selected) ); - deselect_all_nodes <- any_(...); deselect_on_select <- node_to_select.gate_not(&keep_selection); deselect_all_nodes <+ deselect_on_select; deselect_all_nodes <+ editor.deselect_all_nodes;