Skip to content

Insert Suggestion uses wrong line of code with multiple comments open

Summary

When using the Insert Suggestion feature with multiple comments open, the suggestion contains the incorrect line of code.

Steps to reproduce

  1. Navigate to an MR to review
  2. Click to create a comment on a line of code changed in the MR
  3. Click to create another comment on another line of code changed in the MR
  4. Click insert suggestion on the second open comment box

Example Project

56KBs/gitlab-suggestion-bug!31 (diffs)

What is the current bug behavior?

When clicking insert suggestion on the second (or third, etc) open commenting box, the first comment boxes line of code is used as the suggestion.

What is the expected correct behavior?

The suggestion should be the line of code from the comment box that the insert suggestion button was pressed on.

Relevant logs and/or screenshots

GIF of issue

recording__14_

Output of checks

This bug happens on GitLab.com

Possible fixes