-
Notifications
You must be signed in to change notification settings - Fork 6
Improve line matching mechanism by introducing line ids #2
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?
Conversation
This change allows for matching lines that were edited.
AppVeyor fails due to issues with configuration @greg-1-anderson, please review |
Don't worry about the Appveyor failure; the cause is that they only offer one version of PHP at a time, and they recently switched from 7.3 to 7.4 as their one version. We'd have to add PHP 7.4 support here to bring back Appveyor testing. Probably not hard, but optional. |
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.
Could you better explain how getLineId is working, and how that helps identify and re-assemble the content and comment lines?
As far as I understand the existing code is not able to match comments with edited lines. Such comments will be lost. My patch tries to work around this issue by introducing line ids. Let's go with the slightly changed example from tests: # Top comments
top:
# Top one
one:
# Top two
two: two
# Bottom comments
bottom:
# Bottom one
one:
# Bottom two
two: 2 My code generates ids based on keys (discarding values). Additionally, duplicating keys are taken into account as well. The following ids will be generated:
This approach (partially) handles this issue:
As a result, I was able to preserve all comments in my interactively edited yaml file. Hope my explanations are clear :) |
That explanation is good; could you make it a code comment or part of the documentation, though? Also, somewhere it would be good to compare/contrast what happens if this remapping is not done. For example, in the existing implementation of this code, I think that maybe the comment "Bottom two" would end up being attached to both "two:" elements. |
The README implies that the existing code works in the same way as the new code. Maybe you could move just the test to another PR, so that we can see a failing test? |
# Conflicts: # tests/TestComments.php
hi @greg-1-anderson:
|
hi @greg-1-anderson - any updates on this one? |
hi @greg-1-anderson - are you planning to commit this PR? |
hi @greg-1-anderson - any chance this would be committed? It's been almost half of a year now :) Just let me know. Don't want to fork but unless this is the only option - I will. Thanks! P.S. Hope, you are safe |
This change allows for matching lines that were edited.