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
|
AlwaysHide bool
|
||||||
ForceQuitOnDiff bool
|
ForceQuitOnDiff bool
|
||||||
MaxDiffLength int `default:"2048"` // just for reference
|
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
|
if output.MaxDiffLength == 0 { // real default value
|
||||||
output.MaxDiffLength = 2048
|
output.MaxDiffLength = 2048
|
||||||
}
|
}
|
||||||
|
if output.MaxDiffLines == 0 { // real default value
|
||||||
|
output.MaxDiffLines = 50
|
||||||
|
}
|
||||||
// Convert answer to string and split by lines
|
// Convert answer to string and split by lines
|
||||||
|
truncated := false
|
||||||
answerStr := string(answer)
|
answerStr := string(answer)
|
||||||
resultStr := result.Files[output.FileName]
|
resultStr := result.Files[output.FileName]
|
||||||
truncated := false
|
|
||||||
if len(answerStr) > output.MaxDiffLength {
|
if len(answerStr) > output.MaxDiffLength {
|
||||||
answerStr = answerStr[:output.MaxDiffLength]
|
answerStr = answerStr[:output.MaxDiffLength]
|
||||||
truncated = true
|
truncated = true
|
||||||
|
@ -82,6 +85,14 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
|
||||||
}
|
}
|
||||||
answerLines := strings.Split(answerStr, "\n")
|
answerLines := strings.Split(answerStr, "\n")
|
||||||
resultLines := strings.Split(resultStr, "\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(
|
diffs := patienceDiff(
|
||||||
answerLines,
|
answerLines,
|
||||||
resultLines,
|
resultLines,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user