Add logic to collapse trailing \n lines in diff segments