From 2f51eb2b414f3e27f0d3ab3f4ef1a3f3a48c6d06 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 27 May 2024 01:20:56 +0900 Subject: Different marker for the first and last line of multi-line entries Can be configured via `--marker-multi-line` --- src/util/chars.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/util') diff --git a/src/util/chars.go b/src/util/chars.go index 7c706ae8..82773f40 100644 --- a/src/util/chars.go +++ b/src/util/chars.go @@ -75,18 +75,18 @@ func (chars *Chars) Bytes() []byte { return chars.slice } -func (chars *Chars) NumLines(atMost int) int { +func (chars *Chars) NumLines(atMost int) (int, bool) { lines := 1 if runes := chars.optionalRunes(); runes != nil { for _, r := range runes { if r == '\n' { lines++ } - if lines >= atMost { - return atMost + if lines > atMost { + return atMost, true } } - return lines + return lines, false } for idx := 0; idx < len(chars.slice); idx++ { @@ -97,11 +97,11 @@ func (chars *Chars) NumLines(atMost int) int { idx += found lines++ - if lines >= atMost { - return atMost + if lines > atMost { + return atMost, true } } - return lines + return lines, false } func (chars *Chars) optionalRunes() []rune { -- cgit v1.2.3