Skip to content

MR Review: add commenting ranges

Problem to solve

This issue implements logic related to tracking which lines in the diff have been added/removed/unchanged. This feature needs to be behind a feature flag because we'll implement submitting new comments in a subsequent issue.

Commenting ranges

To be able to create new comments (not replies to a thread) we need to create a CommentingRangeProvider. We implement a function that receives a file URI and returns all the lines that the user can comment on.

Without these ranges, the user can only respond to existing comments (#339 (closed)).

Proposal

We'll need to use the textual diff that we retrieve from the MR Diff version API endpoint.

{
  "old_path": "new_file.ts",
  "new_path": "new_file.ts",
  "a_mode": "0",
  "b_mode": "100644",
  "new_file": true,
  "renamed_file": false,
  "deleted_file": false,
  "diff": "@@ -0,0 +1,3 @@\n+export class NewFile{\n+    private property: string;\n+}\n"
}

We'll have to praise the diff property to find all changed lines.

Further details

There is a follow up issue that might have to build on the logic implemented here: #344 (closed)

Example:

no ranges with ranges
gitlab_comment_thread_test_ts___197____gitlab-vscode-extension Extension_Development_Host_-_gitlab_comment_thread_test_ts___197____gitlab-vscode-extension-TEST

Links / references

Edited by Tomas Vik