VS Code diff algorithm is slightly different from GitLab's (commenting ranges not in sync)
Summary
When we show commenting ranges for the new file version, we use GitLab API to tell us what lines are new. In certain cases the diff algorithm can choose where the diff hunk starts (see the above screenshot). GitLab seems to use some more complex heuristic to make nicer diff for JSON (and possibly other similar cases).
This causes a mismatch between what VS Code shows as added lines and what the extension understands as added lines.
Steps to reproduce
- Have a list of objects in JSON
- Create MR which adds one object in the middle of the list (it can't be the first or the last).
What is the current bug behavior?
VS Code shows different added lines than the commenting ranges we show (what GitLab API returns).
What is the expected correct behavior?
The added lines should match commenting range.
Relevant logs and/or screenshots
API response for the same diff:
curl -H "PRIVATE-TOKEN: $TOKEN" https://gitlab.com/api/v4/projects/5261717/merge_requests/283/versions/200751870 | jq .
@@ -123,6 +123,10 @@
"name": "CI_DISPOSABLE_ENVIRONMENT",
"description": "Only available if the job is executed in a disposable environment (something that is created only for this job and disposed of/destroyed after the execution - all executors except `shell` and `ssh`). `true` when available."
},
+ {
+ "name": "CI_ENVIRONMENT_ACTION",
+ "description": "The action annotation specified for this job's environment. Available if [`environment:action`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/ci/variables/../yaml/README.md#environmentaction) is set. Can be `start`, `prepare`, or `stop`."
+ },
{
"name": "CI_ENVIRONMENT_NAME",
"description": "The name of the environment for this job. Available if [`environment:name`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/ci/variables/../yaml/README.md#environmentname) is set."
Possible fixes
The impact is small enough that I suggest wontfix

