Skip to content

Adjust unnapliable suggestions in expanded lines

What does this MR do?

When expanding diff lines and leaving suggestion comments, eventually, they showed as unnapliable even with no changes in the diff. It happens given the DiffNote#supports_suggestion? check was being made at Suggestion#appliable? in the discussions iteration.

The problem with DiffNote#supports_suggestion? as it is, is that it uses Position#diff_file, which has a RequestStore "cache".

So for instance, if we have 3 comments in expanded diff lines for the same diff file, just the first expansion would be considered (again, because of the RequestStore at Position#diff_file) , therefore, just the first suggestion within this set of comments on expanded lines would be appliable.

All in all, we're able to simply remove this check from the Suggestion#appliable? method given we already check if the note supports suggestions upon creation (Suggestions::CreateService).

As an extra outcome, we'll submit less Gitaly requests.

Issue: #31356 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Edited by 🤖 GitLab Bot 🤖

Merge request reports