Open the linked file when a Rapid Diffs URL has a file fragment

What

A diff URL can end in a #<file-hash> fragment that identifies a single file. With the "Show one file at a time" diff preference enabled, legacy diffs opened that specific file when following such a link. In Rapid Diffs, the linked file was selected internally but the first file of the merge request was displayed instead, so the user landed on the wrong diff. This fixes that mismatch and re-enables spec/features/merge_request/user_views_auto_expanding_diff_spec.rb's "shows diffs file-by-file" example.

Reproduction

  1. Enable the rapid_diffs_default_on_mr_show feature flag and turn on the "Show one file at a time" diff preference.
  2. Open a merge request's Changes tab.
  3. Copy the anchor link (#<hash> URL) for a file that is not the first file in the diff.
  4. Open that URL in a new tab. The linked file is displayed, not the first file.

Merge request reports

Loading
Loading