Repository navigation
fix(server): review guide stops no longer show the same lines twice #23725
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
Changes from all commits
47b0af8
dc795e9
a3a3aa3
dc3e13e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,26 +87,29 @@ function clampExcerpt( | |
| function mergeExcerpts( | ||
| excerpts: ReadonlyArray<PullRequestReviewGuideExcerpt>, | ||
| ): Array<PullRequestReviewGuideExcerpt> { | ||
| const merged: Array<PullRequestReviewGuideExcerpt> = []; | ||
| let merged: Array<PullRequestReviewGuideExcerpt> = []; | ||
| for (const excerpt of excerpts) { | ||
| const index = merged.findIndex( | ||
| (other) => | ||
| other.path === excerpt.path && | ||
| other.side === excerpt.side && | ||
| other.start <= excerpt.end + 1 && | ||
| excerpt.start <= other.end + 1, | ||
| ); | ||
| const other = merged[index]; | ||
| if (other === undefined) { | ||
| const touches = (other: PullRequestReviewGuideExcerpt) => | ||
| other.path === excerpt.path && | ||
| other.side === excerpt.side && | ||
| other.start <= excerpt.end + 1 && | ||
| excerpt.start <= other.end + 1; | ||
| // An excerpt can bridge several earlier ones; fold them all into the first. | ||
| const group = merged.filter(touches); | ||
| const first = group[0]; | ||
| if (first === undefined) { | ||
| merged.push(excerpt); | ||
| continue; | ||
| } | ||
| merged[index] = { | ||
| ...other, | ||
| start: Math.min(other.start, excerpt.start), | ||
| end: Math.max(other.end, excerpt.end), | ||
| caption: other.caption || excerpt.caption, | ||
| const combined = { | ||
| ...first, | ||
| start: Math.min(excerpt.start, ...group.map((other) => other.start)), | ||
| end: Math.max(excerpt.end, ...group.map((other) => other.end)), | ||
| caption: group.find((other) => other.caption)?.caption ?? excerpt.caption, | ||
| }; | ||
| merged = merged.flatMap((other) => | ||
| other === first ? [combined] : touches(other) ? [] : [other], | ||
| ); | ||
| } | ||
| return merged.map((excerpt) => ({ | ||
| ...excerpt, | ||
|
Comment on lines
114
to
115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.