You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DiffParser $rangeNewCount sometimes incorrect #210
If a file change reduces the contents of a file from many lines to just one (e.g. compiled JS), the $rangeNewCount variable is given an inappropriate value.
This is because the git diff header for a single-line file excludes the length as there is no context available, e.g.:
Using $vars[2] here is basically using $rangeOldCount. So for the chunk header in the example above, $rangeNewCount => 121, which is incorrect as the diff format indicates that this will be a single line change.
What may be better in this case (imo) is to simply use the value 1, which would indicate more completely that this is a single line change and that there is no context other than the line of change:
$rangeNewCount = $vars[4] ?? 1;
Aside
This same logic could apply to the $rangeOldCount too, where it could be excluded because it is a single line file with no context available. Consider:
@@ -1 +1 @@
However, for a single-line file where the change results in a single-line file, the DiffParser logic will continue to look correct, because everything ($rangeOldCount, $rangeNewStart, $rangeNewCount) will just say 1, but this is kind of 'by mistake'.
This would make $rangeOldCount => 0 (and thus $rangeNewCount => 0) which I believe is also incorrect.
Activity
alexandresalome commentedon May 3, 2024
Presumably fixed by #211