Repository: GraphiteEditor/Graphite
File: editor/src/messages/tool/common_functionality/shape_editor.rs (Rust)

Code before:
			adjust_handle_colinearity(handle2, end, nc2, &vector, layer, responses);

			if let Some(adjacent_handles) = temporary_adjacent_handles_while_molding {
				if let Some(other_handle1) = adjacent_handles[0] {
					restore_g1_continuity(handle1, other_handle1, nc1, start, &vector, layer, responses);
				}
				if let Some(other_handle2) = adjacent_handles[1] {
					restore_g1_continuity(handle2, other_handle2, nc2, end, &vector, layer, responses);
				}
			}
			None
		}
	}
}

// TODO Consider keeping a list of selected manipulators to minimize traversals of the layers
impl ShapeState {
	pub fn is_selected_layer(&self, layer: LayerNodeIdentifier) -> bool {
		self.selected_shape_state.contains_key(&layer)
	}

	pub fn is_point_ignored(&self, point: &ManipulatorPointId) -> bool {
		(point.as_handle().is_some() && self.ignore_handles) || (point.as_anchor().is_some() && self.ignore_anchors)
	}

	/// Creates a dummy modification to trigger graph reorganization.
	fn add_dummy_modification_to_trigger_graph_reorganization(layer: LayerNodeIdentifier, start_point: PointId, _end_point: PointId, responses: &mut VecDeque<Message>) {
		// Apply a zero-delta to one of the points to trigger reorganization
		let dummy_modification = VectorModificationType::ApplyPointDelta {
			point: start_point,
			delta: DVec2::ZERO,
		};
		responses.add(GraphOperationMessage::Vector {
			layer,
			modification_type: dummy_modification,
		});
		responses.add(NodeGraphMessage::RunDocumentGraph);
	}

	/// a two-step process: trigger reorganization, then use position-based lookup.
	fn handle_grouped_transform_close_path(document: &DocumentMessageHandler, layer: LayerNodeIdentifier, start_point: PointId, end_point: PointId, responses: &mut VecDeque<Message>) {
		// Get the layer's transform (handles rotation, scaling, translation)
		let layer_transform = document.metadata().transform_to_document(layer);

		let start_local_pos = document.network_interface.compute_modified_vector(layer).and_then(|v| v.point_domain.position_from_id(start_point));
		let end_local_pos = document.network_interface.compute_modified_vector(layer).and_then(|v| v.point_domain.position_from_id(end_point));

		if let (Some(start_local), Some(end_local)) = (start_local_pos, end_local_pos) {
			// Transform positions to document/world space
			// These positions are stable (won't change during reorganization)
			let start_pos = layer_transform.transform_point2(start_local);

Review comment (suggestion):
Perhaps the specific "graph reorganization" could be explained:
```suggestion
	/// Applies a dummy vector modification to the layer. In the case where a group containing some vector data is selected, this triggers the creation of a «Flatten Path» node.
```

Code after:
			adjust_handle_colinearity(handle2, end, nc2, &vector, layer, responses);

			if let Some(adjacent_handles) = temporary_adjacent_handles_while_molding {
				if let Some(other_handle1) = adjacent_handles[0] {
					restore_g1_continuity(handle1, other_handle1, nc1, start, &vector, layer, responses);
				}
				if let Some(other_handle2) = adjacent_handles[1] {
					restore_g1_continuity(handle2, other_handle2, nc2, end, &vector, layer, responses);
				}
			}
			None
		}
	}
}

// TODO Consider keeping a list of selected manipulators to minimize traversals of the layers
impl ShapeState {
	pub fn is_selected_layer(&self, layer: LayerNodeIdentifier) -> bool {
		self.selected_shape_state.contains_key(&layer)
	}

	pub fn is_point_ignored(&self, point: &ManipulatorPointId) -> bool {
		(point.as_handle().is_some() && self.ignore_handles) || (point.as_anchor().is_some() && self.ignore_anchors)
	}

	/// Applies a dummy vector modification to the layer. In the case where a group containing some vector data is selected, this triggers the creation of a «Flatten Path» node.
	fn add_dummy_modification_to_trigger_graph_reorganization(layer: LayerNodeIdentifier, start_point: PointId, _end_point: PointId, responses: &mut VecDeque<Message>) {
		// Apply a zero-delta to one of the points to trigger reorganization
		let dummy_modification = VectorModificationType::ApplyPointDelta {
			point: start_point,
			delta: DVec2::ZERO,
		};
		responses.add(GraphOperationMessage::Vector {
			layer,
			modification_type: dummy_modification,
		});
		responses.add(NodeGraphMessage::RunDocumentGraph);
	}

	fn defer_connect_points_by_position(
		document: &DocumentMessageHandler,
		layer1: LayerNodeIdentifier,
		start_point: PointId,
		layer2: LayerNodeIdentifier,
		end_point: PointId,
		target_layer: LayerNodeIdentifier,
		responses: &mut VecDeque<Message>,
	) {
		// Get the local positions of the selected points
		let start_local_pos = document.network_interface.compute_modified_vector(layer1).and_then(|v| v.point_domain.position_from_id(start_point));
		let end_local_pos = document.network_interface.compute_modified_vector(layer2).and_then(|v| v.point_domain.position_from_id(end_point));