Skip to content

Make code suggestions be aware of multi-line comment context in Diffs

Problem to solve

When suggesting code edits in a MR, a user needs to manually edit the offset (i.e.: the :-0+0). E.g.:

image

The user experience isn't intuitive because the offset is auto-populated for a single line:

image

But not for multiple lines:

image

The documentation for multi-line suggestions isn't linked from the feature (i.e.: there's a link to Markdown is supported instead).

Intended users

User experience goal

A user should be able to suggest multi-line code changes without resorting to documentation search.

Proposal

The value of "Commenting on lines" can be taken into consideration when the user clicks "Insert suggestion" to automatically populate the offset.

Using the example above, it would look like -3+0:

image

The suggestion feature is only available in the Markdown toolbar and suggestions are only valid for comments that span added and/or unchanged lines. If such a comment spans both the “old” and “new” sides of the file diff, the suggestion feature only “looks” at the “new” side.

Further details

Permissions and Security

Documentation

Availability & Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Links / references

Extra information from #217691 (closed)

The following discussion from !29516 (merged) should be addressed:

  • @pedroms started a discussion: (+1 comment)

    @jboyson 🤔 Question: One thing I didn't test: how are suggestions being handled? Do suggestions on multi-line comments automatically prefill to the range of the comment? That would address #28044 (closed).

Edited by Pedro Moreira da Silva