Skip to content

Fix git blame syntax highlighting when different commits break up lines

What does this MR do?

This MR fixes a bug where syntax highlighting would not work properly in certain lines when doing a git blame view of a file. Also, this MR reuses the Rugments lexer and formatter for each git blame commit block, which should make things faster and reduce overhead.

Why was this MR needed?

When doing a git blame, GitLab feeds the Rugments lexer/formatter blocks of code based on the latest commit for each line. However, this can cause lexer to fail because the state is cleared between each block of code, which causes highlight to fallback to the plaintext lexer. For example, notice this unhighlighted line in this file:

image

The fixed version looks like this:

image

This MR requires a patch to rugments to allow the continue option to be passed to the lexer.

What are the relevant issue numbers?

Closes #1521 (closed)

Merge request reports