Skip to content

Implement linking to a single line number in Web IDE

Problem to Solve

Users often need to reference specific lines of files. You can do this in the repository view, but you're unable to link directly to a line to begin to edit a file in that position or share that link with someone as a reference point for discussion to begin editing.

Proposal

The Web IDE should support a hyperlink syntax that can reference a line number.

UX Proposal

  • Appending #LXX to the end of a Web IDE URL should cause the associated file to be opened with the line number (XX) to be visible with the cursor placed at the end of the line.
    • If the line referenced is not near the end or beginning of the file, the view should be scrolled so that 2.5 lines above the referenced line are visible.

image

  • Hovering a line in the editor should show a link icon with a link to the file including #LXX

image

Out of Scope

  • Linking to a range of lines
  • Special link formatting/syntax for usage in GitLab Markdown

Additional Considerations

  • The context of the editor needs to be considered when linked - review/edit mode

Availability and Testing

New tests required (system tests and one E2E), including coverage for the case when the user needs to link a line that also has a comment (see #249625 (closed)) and the negative case when the linked line doesn't exist. Please include the SET (@a_mcdonald) in the MR review.

Edited by Anastasia McDonald