Fix blob preview diff hiding blank added lines

What does this MR do and why?

In the single-file editor's Preview Changes diff, a blank added (or removed) line was dropped from the view — even though the file was saved correctly. This fixes the preview rendering.

A blank added/removed line arrives as the bare prefix character (e.g. "+"), which is not blank? in Rails. The diff_line_content helper stripped the prefix and returned "", so the cell rendered as a zero-height table row and the line appeared to vanish. We now fall back to a non-breaking space so the row keeps visible height — the same convention already used for fully-blank lines one branch up in the helper.

The shared helper is safe to change: all other callers (MR/commit/parallel diff views) pass line.rich_text (non-empty highlighted HTML), so only the blob preview path — which passes raw line.text — is affected.

References

Screenshots or screen recordings

Before After
CleanShot_2026-07-02_at_15.46.38 CleanShot 2026-07-02 at 15.59.47.png

How to set up and validate locally

  1. Edit a file with two methods separated by one blank line in the single-file editor.
  2. Insert a new method between them, leaving one blank line above and below it.
  3. Open the Preview Changes tab.
  4. Both blank lines now render as visible added rows (previously the line below was missing).

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Chaoyue Zhao

Merge request reports

Loading