Revise DCR comment position by matching with line content
What does this MR do and why?
We occasionally see DCR's comment is left on a line where the code suggestion cannot be applied as is.
Here is one example for that https://gitlab.com/gitlab-org/gitlab/-/issues/538977#note_2531824490
This MR improves DCR comment line placement by using the content in to find the matching diff_line when needed.
Here is what's changed:
- Verify the line matched by line numbers using content if available. Prefer the line matched by the content if they do not match
- Fallback to the line matched by line numbers if content matching fails
- When the line couldn't be matched using the line numbers, try match with the content as much as possible.
Since the same line could appear multiple times within a diff, I've chosen to go with minimum 3 lines to attempt content matching.
It's possible that the content within tag could appear multiple times within a diff, but I've chosen to ignore that for now as it is unlikely.
Also, I've left AIGW version out for now to keep this MR small, but I'll create a follow up MR once this one gets merged.
References
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #533266 (closed)