Skip to content

Fix #4618: Prevent colinear handles when extending from points connec… - #4680

Open
shubhtrek wants to merge 5 commits into
GraphiteEditor:masterfrom
shubhtrek:fix-colinear-handles-extension
Open

shubhtrek wants to merge 5 commits into
GraphiteEditor:masterfrom
shubhtrek:fix-colinear-handles-extension

Conversation

@shubhtrek

Copy link
Copy Markdown

Closes #4618

Description

When using the Pen tool to extend a path from a point connected to multiple segments, the editor was mirroring the existing handle and making it colinear with the new handle. This was causing weird handle behaviour when editing the path.

Now, handle mirroring and colinearity are applied only when extending from an endpoint connected to one or zero segments. If the point is already connected to multiple segments, the new handle stays at the anchor point until we drag it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@shubhtrek

Copy link
Copy Markdown
Author

@0HyperCube Hey, could you please take a look at this PR when you get time?

@0HyperCube 0HyperCube left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix. The code looks reasonable and works well.

Please consider adding a test to avoid regressions in this area.

@shubhtrek

Copy link
Copy Markdown
Author

@Keavon PTAL.

@0HyperCube

Copy link
Copy Markdown
Contributor

PTAL.

@shubhtrek this is perhaps not especially helpful. Keavon has a large review backlog.

Please consider adding a test to avoid regressions in this area.

Have you considered adding tests? Tests are vital when maintaining large pieces of software. Thanks.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread editor/src/messages/tool/tool_messages/pen_tool.rs Outdated
@shubhtrek

Copy link
Copy Markdown
Author

@0HyperCube Hey! Added a unit test

@0HyperCube 0HyperCube left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for adding the test. It seems to be written reasonably, I have just a couple of nits regarding adding some utility functions that could be shared with other tests.

Perhaps also an additional test to show that clicking when there is just one segment connected uses the handle (as shown) could really solidify the desired behaviour?

using_handle_when_one_connected.mp4

Comment on lines +2919 to +2928
let b_id = vector
.point_domain
.ids()
.iter()
.copied()
.find(|&id| {
let pos = vector.point_domain.position_from_id(id).unwrap();
layer_to_viewport.transform_point2(pos).distance(B) < 1e-6
})
.expect("Anchor B should exist");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider creating a helper function e.g. get_anchor_near.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ohk!

Comment on lines +2941 to +2951
let bd_segment = vector
.segment_domain
.ids()
.iter()
.copied()
.find(|&segment| {
let start = vector.segment_start_from_id(segment);
let end = vector.segment_end_from_id(segment);
(start == Some(b_id) && end == Some(d_id)) || (start == Some(d_id) && end == Some(b_id))
})
.expect("Segment between B and D should exist");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider making this also a function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done!

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread editor/src/messages/tool/tool_messages/pen_tool.rs Outdated
@shubhtrek
shubhtrek force-pushed the fix-colinear-handles-extension branch from 4e4aee1 to f79bb57 Compare October 14, 2026 15:06
…egment colinear handle test

Address review nits from 0HyperCube:

- Extract repeated point-lookup into a reusable get_anchor_near helper

- Extract repeated segment-lookup into a reusable get_segment_between helper

- Add test verifying single-segment anchors preserve colinear handles
@shubhtrek
shubhtrek force-pushed the fix-colinear-handles-extension branch from f79bb57 to cf57806 Compare October 14, 2026 15:07
@shubhtrek
shubhtrek force-pushed the fix-colinear-handles-extension branch from cf57806 to 69d3b46 Compare October 14, 2026 15:09
@shubhtrek

Copy link
Copy Markdown
Author

@0HyperCube PTAL

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extending from point allows a handle to be colinear with 2 others

2 participants