Skip to content

Support multi-line suggestions

Oswaldo Ferreira requested to merge osw-support-multi-line-suggestions into master

What does this MR do?

What it supports

Extend the existing suggestion syntax to support multi-line suggestions allowing suggestion:+<x>, where x is a positive number.

In that case, the suggestion will target the replacement of:

<current-line>..<current-line>+<x>

  • Example 1: Using suggestion:+1 translates into replace from the commented (this) line to 1 line below by the provided content.
  • Example 2: Using suggestion:+3 translates into replace from the commented (this) line to 3 lines below by the provided content.
  • Example 3: Using suggestion:-3+4 translates into _replace from the commented (this) line to 3 lines above and 4 lines below by the provided content.

TODO

  • Support parsing the suggestion:-X+Y syntax
  • Return suggestions complete data on Preview request backend
  • Make necessary changes on frontend to present the Preview reliably (pre-persistence)
  • Persist from_content and to_content correctly
  • If a surpassing context is given (-30 if we're at line 7, go up to the limit, i.e. line 1. Save that offset into lines_above so we can know the context we need to track in order to outdate) backend
  • Return diff_lines with correct old and new lines to FE (for references.suggestions and note.suggestions) backend
  • When any of the changing lines of a suggestion changes, outdate the suggestion. This check needs to be made whenever a MR receives an update. A new column will be needed. This could be done on the fly, though, it's not cheap. backend
  • ~bug Preview diff refs are not right for preview (/diffs should use the latest revision)
  • Present Preview reliably (post-persistence) frontend
  • Make sure lack of limitation won't be a technical limitation
  • Get all backend MRs merged and add glue code on this MR

Backend split

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53310

Does this MR meet the acceptance criteria?

Edited by 🤖 GitLab Bot 🤖

Merge request reports