Backport #39969 Co-authored-by: schop-rob <49682405+schop-rob@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1. refactor the legacy code and add more comments, remove the "+1/-1" tricks, clarify the BuildBlobExcerptDiffSection behavior 2. fix a line-counting bug (see screenshot below)
Fix a regression from #38517 (the tail section index is not correctly assigned). And add a test to cover GetDiffForRender.