From 2b47630c2f68794a95d5065a7989d489990f7a19 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 23 Mar 2021 09:37:02 +0000 Subject: context aware grep with -max -after and -before not work --- internal/lcontext/lcontext.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'internal/lcontext') diff --git a/internal/lcontext/lcontext.go b/internal/lcontext/lcontext.go index bd51d94..89cb7c3 100644 --- a/internal/lcontext/lcontext.go +++ b/internal/lcontext/lcontext.go @@ -6,3 +6,17 @@ type LContext struct { BeforeContext int MaxCount int } + +// Has returns true if it has any parameter set. +func (c LContext) Has() bool { + if c.AfterContext > 0 { + return true + } + if c.BeforeContext > 0 { + return true + } + if c.MaxCount > 0 { + return true + } + return false +} -- cgit v1.2.3