Skip to content
12 changes: 12 additions & 0 deletions editor/src/messages/tool/common_functionality/shape_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use graphene_std::vector::algorithms::bezpath_algorithms::pathseg_compute_lookup
use graphene_std::vector::misc::{HandleId, ManipulatorPointId, dvec2_to_point, point_to_dvec2};
use graphene_std::vector::{HandleExt, PointId, SegmentId, Vector, VectorModificationType};
use kurbo::{Affine, DEFAULT_ACCURACY, Line, ParamCurve, ParamCurveNearest, PathSeg, Rect, Shape};
use std::collections::hash_map::DefaultHasher;
use std::f64::consts::TAU;
use std::hash::{Hash, Hasher};

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum SelectionChange {
Expand Down Expand Up @@ -461,6 +463,16 @@ impl ShapeState {
} else {
// Merge the layers
merge_layers(document, layer1, layer2, responses);

let resolve_id = |layer: LayerNodeIdentifier, point_id: PointId, index: usize| {
let mut hasher = DefaultHasher::new();
(index, 0_usize, layer).hash(&mut hasher);
point_id.generate_from_hash(hasher.finish())
};

let start_point = resolve_id(layer1, start_point, 0);
let end_point = resolve_id(layer2, end_point, 1);
Comment on lines +473 to +474
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only ids in layer2 will change (since the layer1 will probably have no conflicts).

Furthermore it is possible that there is no conflict, in which case the original PointId must be used (like before this PR). You therefore need to check if there was some conflict by checking all of the point ids in the first path.

I don't care if this doesn't work for tables with several vector data, since I find them annoying.


// Create segment between the two points
let segment_id = SegmentId::generate();
let modification_type = VectorModificationType::InsertSegment {
Expand Down
Loading