Follow mid-edit renames in the preview renderer

What does this MR do and why?

Resolves "Preview" tab does not follow mid-edit file ren... (#616115 - closed), focusing on the preview renderer.

Pick the renderer from the file name currently in the editor, rather than the name of the committed blob.

Scope

Making the "Preview" tab's mode selection (the Markdown live preview or the rendered preview pane) follow renames is covered in Follow mid-edit renames to Markdown in the "Pre... (!250889 - merged).

Backward compatibility

When file_path is missing or blank, the renderer falls back to blob.name as before, so requests from older frontends keep working during a rolling deploy.

Screen recordings

Manually verified in GDK-in-a-box:

Switches the markup (→ another markup) Switches to a diff (→ non-markup)

How to set up and validate locally

  1. In a repository, create a file named foo.rst with some reStructuredText content and commit it
  2. Open foo.rst in the single file editor and replace the content with some Org-mode content (e.g. * Title)
  3. Rename the file to foo.org
  4. Click the "Preview" tab
  5. Verify that the preview renders the content as Org-mode, not as reStructuredText (e.g. * Title becomes a heading, not a bullet list)

Notes

  • Backend engineer, but fairly new to Rails – feedback on Rails conventions welcome.
  • I don't work on the frontend regularly — a careful look at this approach would be very helpful.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by skkzsh

Merge request reports

Loading
Loading