Skip to content

Commit f88fc0a

Browse files
authored
Increase limit on how many inline-chunks are allowed per line. Also use named constants. (sourcegit-scm#2619)
* 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.
1 parent ffea3e1 commit f88fc0a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Commands/Diff.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public partial class Diff : Command
3535
private const string SPECIAL_NO_NEWLINE = " No newline at end of file";
3636
private const string SPECIAL_SUBMODULE = "Subproject commit ";
3737

38+
private const int MAX_INLINE_CONTENT_LENGTH = 1024;
39+
private const int MAX_INLINE_CHUNKS_PER_LINE = 16;
40+
3841
public Diff(string repo, Models.DiffOption opt, int numContextLines, bool ignoreWhitespace, bool ignoreCRAtEOL)
3942
{
4043
_result.TextDiff = new Models.TextDiff();
@@ -330,11 +333,11 @@ private void ProcessInlineHighlights()
330333
var left = _deleted[i];
331334
var right = _added[i];
332335

333-
if (left.Content.Length > 1024 || right.Content.Length > 1024)
336+
if (left.Content.Length > MAX_INLINE_CONTENT_LENGTH || right.Content.Length > MAX_INLINE_CONTENT_LENGTH)
334337
continue;
335338

336339
var chunks = Models.TextInlineChange.Compare(left.Content, right.Content);
337-
if (chunks.Count > 4)
340+
if (chunks.Count > MAX_INLINE_CHUNKS_PER_LINE)
338341
continue;
339342

340343
foreach (var chunk in chunks)

0 commit comments

Comments
 (0)