Merge pull request #59 from kkngsm/constant-snap

fix ConstantOnly bug of port snapping
This commit is contained in:
setzer22 2022-08-30 16:31:19 +00:00 committed by GitHub
commit 4db5eea1ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,12 +186,13 @@ where
ports
.iter()
.find_map(|(port_id, _)| {
let port_pos = port_locations[&port_id.into()];
if port_pos.distance(cursor_pos) < DISTANCE_TO_CONNECT {
Some(port_pos)
} else {
None
}
port_locations.get(&port_id.into()).and_then(|port_pos| {
if port_pos.distance(cursor_pos) < DISTANCE_TO_CONNECT {
Some(*port_pos)
} else {
None
}
})
})
.unwrap_or(cursor_pos)
}