-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: joining paths from different layers with Ctrl+J fails #3534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: joining paths from different layers with Ctrl+J fails #3534
Conversation
|
Hello and thanks for the PR. I need to mention that we do not accept PR descriptions written by AI because they increase the noise-to-signal ratio and usually serve to mislead with obscured inaccuracies. (The same applies to code, which must be written by you.) |
|
Oh, hey , I had this extension turned on in my IDE https://whatthediff.ai/ , will be mindful to disable it when creating PRs in this repo :) . Also regarding using AI in code, I did use claude code for targeting the files and the fix but did review that intensively before publishing . |
|
Thanks for the insight into your process (we've been seeing more highly-elaborate-but-not-insightful PR descriptions like this and it's good to know some of the details about what kinds of AI tools are producing them). For code authorship, AI is acceptable for auto-completing lines you would already be typing, but we need contributions to always come from the original thought processes of its human authors who can answer to the reasoning behind each line of changes. Code can't be mysteriously changed without anyone aware of why the change was made. Thanks for working to follow our requirements to building an effective software project. |
0HyperCube
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work. I have tried it with some simple lines with a transform.
I guess the vibes haven't fully completed the code.
cannot_join_lines_with_transform.mp4
|
Taking a look |
When using Ctrl+J to join two points from different layers, the operation failed because PointIds change during merge due to collision resolution. The fix uses index-based point tracking instead of PointIds: 1. Before merge: Record the index of each selected point in its layer 2. Calculate post-merge indices using the point offset from layer1 3. After merge: Retrieve the actual PointIds at those indices 4. Create the connecting segment using the resolved PointIds This works because Vector::concat() preserves point ordering during merge, so we can use exact index arithmetic to find points after remapping. Fixes GraphiteEditor#3519
27f0b7b to
d604ef6
Compare
|
After taking a second look at the issue, here is what I came up with: The fix uses index-based tracking to handle PointId remapping:
Other approaches I considered:
|
|
Let me know if I am missing something or if there could be any other edge case here |
Screen.Recording.2025-12-28.at.7.12.43.AM.movMore manual testing with data grid for when the conflicting PointId is not updated so the wrong segment is created , here it is not created . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail_with_repeat.mp4
However I guess it doesn't matter too much.
6ad186a to
2b7e6e6
Compare
|
I have a better solution for this, let me code it up So basically the issue with the current approach was when layers use the repeat modifier. The merge operation flattens repeated instances, breaking the expected point array structure. Expected behavior:
Actual behavior with repeat:
Since the old approach calculated indices using end_index = end_idx + layer1_count, it assumed layer1_count = 2, but after flattening the repeated instances, layer1 actually contributes 6 points. This causes the lookup to select the wrong points. Instead of relying on indices (which change when instances are flattened), we now:
|
screenrecording.graphite.mp4Some manual testing after the recent commit |
|
let me know if any other changes are required |
0HyperCube
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work if you have two lines in a group with a transform. You can press G with a group selected to apply a transform.
fail_to_join_group.mp4
|
taking a look ! |
|
Is this like a big limitation , this seems like a big change . I'll dig deeper if this is like a game breaker , and its happening on PROD as well , like its not related to my code changes . |
|
@Ayush2k02 I thought that this PR was meant to "fix: joining paths from different layers with Ctrl+J". From my very basic testing, it seems it still does not do this in some very common scenarios. I hope that helps to inform your approach. |
|
Oh, are there any more edge cases that you were able to find apart from this one "It doesn't work if you have two lines in a group with a transform. You can press G with a group selected to apply a transform" , |
|
I have not found any more issues with the current approach. However I will be sure to test it again if you decide to modify the code. |
2304190 to
f0a2bbe
Compare
|
Hey, fixed the case with group selection. Let me know if there is anything else or if some optimizations could be made |
|
When joining two points from the same layer, two segments are created. two_segments.mp4 |
|
Completely missed this, I did try the same layer case with using shift and creating some lines but did'nt look well enough for the underlying line . Let me fix this quick, most likely will keep the same functionality for the group case and remove this from the same layer case . Sorry for the negligence :P |
4f87474 to
a94a974
Compare
|
Fixed the last issue, the check for group / folder was broken Now I am checking if the layer has any children, means it is a group folder . The method |
|
It still seems to produce duplicate segments for me when joining points in the same layer inside a folder: duplicated_segments.mp4 |
|
Okay, so added a check for if the children are more than 1 means we are inside a group , then only go down the
|
|
wait, its still not correct. Dont review yet |
|
Hmmm, for some reason when I connect straight lines inside a group with cmd + j it fails the first time as the point ids are getting remapped but when the exact same thing with creating lines from the pen tool or the spline tool , it succeeds and create the segment in the first try , weird |
38799dc to
ba73f57
Compare
|
Okay, so changing the reorganisation method to use |
|
This is now reviewable from my side ! |
screenrecording.graphite.mp4
Fixes #3519