From 91b391c374cf673eccfbaea4db02b07298d95f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20W?= Date: Thu, 2 Jul 2026 22:08:47 +0200 Subject: [PATCH] Increase limit on how many inline-chunks are allowed per line. Also use named constants. * The current limit was way too restrictive. Two similar (and perfectly ordinary) changed lines could easily fall into one being inline-highlighted and the other not. * A lot of work would already have been performed to calculate these inline-chunks, only to throw them away above this very restrictive limit. --- src/Commands/Diff.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 89248ddc1..fb008aeee 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -35,6 +35,9 @@ public partial class Diff : Command private const string SPECIAL_NO_NEWLINE = " No newline at end of file"; private const string SPECIAL_SUBMODULE = "Subproject commit "; + private const int MAX_INLINE_CONTENT_LENGTH = 1024; + private const int MAX_INLINE_CHUNKS_PER_LINE = 16; + public Diff(string repo, Models.DiffOption opt, int numContextLines, bool ignoreWhitespace, bool ignoreCRAtEOL) { _result.TextDiff = new Models.TextDiff(); @@ -330,11 +333,11 @@ private void ProcessInlineHighlights() var left = _deleted[i]; var right = _added[i]; - if (left.Content.Length > 1024 || right.Content.Length > 1024) + if (left.Content.Length > MAX_INLINE_CONTENT_LENGTH || right.Content.Length > MAX_INLINE_CONTENT_LENGTH) continue; var chunks = Models.TextInlineChange.Compare(left.Content, right.Content); - if (chunks.Count > 4) + if (chunks.Count > MAX_INLINE_CHUNKS_PER_LINE) continue; foreach (var chunk in chunks)