Skip to content

Commit

Permalink
Fix document becoming unsaved (*) when clicking with Select tool (Gra…
Browse files Browse the repository at this point in the history
…phiteEditor#1509)

Fix star on select tool
  • Loading branch information
0HyperCube authored Dec 11, 2023
1 parent 421e7c0 commit 6bce72d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions editor/src/messages/tool/tool_messages/select_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ impl Fsm for SelectToolFsmState {

SelectToolFsmState::Dragging
} else {
responses.add(DocumentMessage::StartTransaction);
tool_data.layers_dragging = selected;

if !input.keyboard.key(add_to_selection) && tool_data.nested_selection_behavior == NestedSelectionBehavior::Deepest {
Expand All @@ -541,6 +540,8 @@ impl Fsm for SelectToolFsmState {
}

if let Some(intersection) = intersection {
responses.add(DocumentMessage::StartTransaction);

tool_data.layer_selected_on_start = Some(intersection);
selected = vec![intersection];

Expand Down Expand Up @@ -780,11 +781,16 @@ impl Fsm for SelectToolFsmState {
}
(SelectToolFsmState::DrawingBox, SelectToolMessage::DragStop { .. } | SelectToolMessage::Enter) => {
let quad = tool_data.selection_quad();
// For shallow select we don't update dragging layers until inside drag_start_shallowest_manipulation()
tool_data.layers_dragging = document.document_legacy.intersect_quad(quad, &document.document_legacy.document_network).collect();
responses.add_front(NodeGraphMessage::SelectedNodesSet {
nodes: tool_data.layers_dragging.iter().map(|layer| layer.to_node()).collect(),
});
let new_selected: HashSet<_> = document.document_legacy.intersect_quad(quad, &document.document_legacy.document_network).collect();
let current_selected: HashSet<_> = document.metadata().selected_layers().collect();
if new_selected != current_selected {
tool_data.layers_dragging = new_selected.into_iter().collect();
responses.add(DocumentMessage::StartTransaction);
responses.add(NodeGraphMessage::SelectedNodesSet {
nodes: tool_data.layers_dragging.iter().map(|layer| layer.to_node()).collect(),
});
}

responses.add_front(DocumentMessage::Overlays(
Operation::DeleteLayer {
path: tool_data.drag_box_overlay_layer.take().unwrap(),
Expand Down

0 comments on commit 6bce72d

Please sign in to comment.