fix: handle line codes with an empty line number - #593
Draft
Enceradeira wants to merge 1 commit into
Draft
Enceradeira wants to merge 1 commit into
Enceradeira wants to merge 1 commit into
Conversation
GitLab leaves the old or new number of a line code empty when the line has no counterpart on the other side (e.g. "<sha>__44"). parse_line_code returned nil for both numbers in that case and get_line_numbers_for_range crashed with "attempt to perform arithmetic on local 'new_end_line' (a nil value)" while setting diagnostics in the reviewer. Parse empty numbers as nil and fall back to a single-line range.
Collaborator
|
Hi @Enceradeira, are these empty line numbers created by gitlab.nvim or by Gitlab in the browser? I'm asking because maybe this is not the right place to fix this. If the missing line numbers are caused by gitlab.nvim, then we should fix the line code creation. |
Collaborator
|
By the way there is #587 - is it solving the same problem? The author of that other PR never replied to my question, so I didn't bother to merge it :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening a file in the reviewer that has a multi-line discussion fails in the
DiffviewDiffBufWinEnterhook:parse_line_codematches%w+_(%d+)_(%d+)and returnsnil, nilwhen either number of the line code is empty (e.g.<sha>__44, as GitLab produces when a line has no counterpart on the other side).get_line_numbers_for_rangethen does arithmetic on thenilvalues; the old-SHA branch (line 265) has the same problem.Changes
parse_line_codeaccepts empty numbers (%d*) and returnsnilfor them; anilline code no longer throws.get_line_numbers_for_rangefalls back to a single-line range when either end of the range has no number (old-SHA and new-SHA branches).tests/spec/line_code_spec.lua, which reproduces the error without the fix.🤖 Generated with Claude Code