From dd7134a76226d1e2279d15f166a5fb70e66c80a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:38:41 +0200 Subject: [PATCH] buffer: Remove superfluous `rehighlight` from `LineArray` ...which isn't used so far and probably handled better in a different way. --- internal/buffer/line_array.go | 48 +++++++++++------------------------ 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/internal/buffer/line_array.go b/internal/buffer/line_array.go index 9897e720..08847271 100644 --- a/internal/buffer/line_array.go +++ b/internal/buffer/line_array.go @@ -46,10 +46,9 @@ type searchState struct { type Line struct { data []byte - state highlight.State - match highlight.LineMatch - rehighlight bool - lock sync.Mutex + state highlight.State + match highlight.LineMatch + lock sync.Mutex // The search states for the line, used for highlighting of search matches, // separately from the syntax highlighting. @@ -148,20 +147,18 @@ func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray if err != nil { if err == io.EOF { la.lines = Append(la.lines, Line{ - data: data, - state: nil, - match: nil, - rehighlight: false, + data: data, + state: nil, + match: nil, }) } // Last line was read break } else { la.lines = Append(la.lines, Line{ - data: data[:dlen-1], - state: nil, - match: nil, - rehighlight: false, + data: data[:dlen-1], + state: nil, + match: nil, }) } n++ @@ -191,17 +188,15 @@ func (la *LineArray) Bytes() []byte { // newlineBelow adds a newline below the given line number func (la *LineArray) newlineBelow(y int) { la.lines = append(la.lines, Line{ - data: []byte{' '}, - state: nil, - match: nil, - rehighlight: false, + data: []byte{' '}, + state: nil, + match: nil, }) copy(la.lines[y+2:], la.lines[y+1:]) la.lines[y+1] = Line{ - data: []byte{}, - state: la.lines[y].state, - match: nil, - rehighlight: false, + data: []byte{}, + state: la.lines[y].state, + match: nil, } } @@ -249,7 +244,6 @@ func (la *LineArray) split(pos Loc) { la.lines[pos.Y].state = nil la.lines[pos.Y].match = nil la.lines[pos.Y+1].match = nil - la.lines[pos.Y].rehighlight = true la.deleteToEnd(Loc{pos.X, pos.Y}) } @@ -369,18 +363,6 @@ func (la *LineArray) Match(lineN int) highlight.LineMatch { return la.lines[lineN].match } -func (la *LineArray) Rehighlight(lineN int) bool { - la.lines[lineN].lock.Lock() - defer la.lines[lineN].lock.Unlock() - return la.lines[lineN].rehighlight -} - -func (la *LineArray) SetRehighlight(lineN int, on bool) { - la.lines[lineN].lock.Lock() - defer la.lines[lineN].lock.Unlock() - la.lines[lineN].rehighlight = on -} - // Locks the whole LineArray func (la *LineArray) Lock() { la.lock.Lock()