From adc8d6ff25c6e7419b8d380610a7d5b10c086a01 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon O'Neill Date: Wed, 29 Jan 2025 08:49:16 -0700 Subject: [PATCH] Allow diff context records to be adjusted This commit enables the number context records to be adjusted, allowing for greater readability in some debugging scenarios. Closes #358 --- cmp/report_compare.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmp/report_compare.go b/cmp/report_compare.go index 2050bf6..5d127d2 100644 --- a/cmp/report_compare.go +++ b/cmp/report_compare.go @@ -10,7 +10,15 @@ import ( ) // numContextRecords is the number of surrounding equal records to print. -const numContextRecords = 2 +var numContextRecords = 2 + +func SetNumContextRecords(n int) { + numContextRecords = n +} + +func GetNumContextRecords() int { + return numContextRecords +} type diffMode byte @@ -57,15 +65,18 @@ func (opts formatOptions) WithDiffMode(d diffMode) formatOptions { opts.DiffMode = d return opts } + func (opts formatOptions) WithTypeMode(t typeMode) formatOptions { opts.TypeMode = t return opts } + func (opts formatOptions) WithVerbosity(level int) formatOptions { opts.VerbosityLevel = level opts.LimitVerbosity = true return opts } + func (opts formatOptions) verbosity() uint { switch { case opts.VerbosityLevel < 0: