feat(parser/diff): default max diff lines 50
This commit is contained in:
parent
29c05f4b36
commit
7f7eead5f7
|
@ -21,6 +21,7 @@ type Conf struct {
|
|||
AlwaysHide bool
|
||||
ForceQuitOnDiff bool
|
||||
MaxDiffLength int `default:"2048"` // just for reference
|
||||
MaxDiffLines int `default:"50"` // just for reference
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,13 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
|
|||
if output.MaxDiffLength == 0 { // real default value
|
||||
output.MaxDiffLength = 2048
|
||||
}
|
||||
if output.MaxDiffLines == 0 { // real default value
|
||||
output.MaxDiffLines = 50
|
||||
}
|
||||
// Convert answer to string and split by lines
|
||||
truncated := false
|
||||
answerStr := string(answer)
|
||||
resultStr := result.Files[output.FileName]
|
||||
truncated := false
|
||||
if len(answerStr) > output.MaxDiffLength {
|
||||
answerStr = answerStr[:output.MaxDiffLength]
|
||||
truncated = true
|
||||
|
@ -82,6 +85,14 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
|
|||
}
|
||||
answerLines := strings.Split(answerStr, "\n")
|
||||
resultLines := strings.Split(resultStr, "\n")
|
||||
if len(answerLines) > output.MaxDiffLines {
|
||||
answerLines = answerLines[:output.MaxDiffLines]
|
||||
truncated = true
|
||||
}
|
||||
if len(resultLines) > output.MaxDiffLines {
|
||||
resultLines = resultLines[:output.MaxDiffLines]
|
||||
truncated = true
|
||||
}
|
||||
diffs := patienceDiff(
|
||||
answerLines,
|
||||
resultLines,
|
||||
|
|
Loading…
Reference in New Issue
Block a user