Skip to content

Commit 12ad51b

Browse files
committed
git-review-rebase: fix coloring of different token on the left side.
The original code had a workaround to avoid highlighting all the spaces from the last character on the left side, but it was a bit too eager depending on the lexer used, for example with the Make lexer we wouldn't get two tokens, one for spaces and one for the newline. Instead, stop on the previous but last token only if it's only spaces/newlines. This doesn't change the highlighting for C source code but allows the highlighting on the left side of a Make diff. Signed-off-by: Quentin Casasnovas <quentin.casasnovas@vates.tech>
1 parent cfa8f59 commit 12ad51b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎scripts/git-review-rebase/src/git_review_rebase/ui/diff_table.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def highlight_diff_tokens(self, left_text: Text, middle_text: Text, right_text:
9595
continue
9696

9797
for i in range(l1, l2):
98-
if i == len(left_tokens) - 1 or i == len(left_tokens) - 2:
98+
if i == len(left_tokens) - 1 or (
99+
i == len(left_tokens) - 2 and not left_tokens[i].strip()
100+
):
99101
break
100102
left_text.stylize(bg, left_idx + 1, left_idx + len(left_tokens[i]) + 1)
101103
left_idx += len(left_tokens[i])

0 commit comments

Comments
 (0)