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.