From c3ba14d32145a8c3e6cd88bbd50c8da75cd49048 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Tue, 15 Jul 2025 09:22:24 -0700 Subject: [PATCH] fix(parser/diff): try n-1 --- internal/parser/diff/parser.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/parser/diff/parser.go b/internal/parser/diff/parser.go index d90ddbf..2751f08 100644 --- a/internal/parser/diff/parser.go +++ b/internal/parser/diff/parser.go @@ -85,7 +85,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( } answerLines := strings.Split(answerStr, "\n") resultLines := strings.Split(resultStr, "\n") - commonPreixLineCount := 0 + commonPrefixLineCount := 0 if output.HideCommonPrefix { n := 0 for ; n < len(answerLines) && @@ -97,9 +97,9 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( ); n += 1 { } if n > 0 { - answerLines = answerLines[n:] - resultLines = resultLines[n:] - commonPreixLineCount = n + answerLines = answerLines[n-1:] + resultLines = resultLines[n-1:] + commonPrefixLineCount = n } } if len(answerLines) > output.MaxDiffLines { @@ -121,10 +121,10 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( if truncated { diffOutput += "\n\n(truncated)" } - if commonPreixLineCount > 0 { + if commonPrefixLineCount > 0 { diffOutput = fmt.Sprintf( "(%d line(s) of common prefix hidden)\n\n", - commonPreixLineCount, + commonPrefixLineCount, ) + diffOutput } comment += fmt.Sprintf(