aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-04-12 19:07:51 +0700
committerShulhan <ms@kilabit.info>2026-04-12 19:08:21 +0700
commit26a02a8396684fcb58f4ba431ae5ae799eb35d68 (patch)
tree0d6da4a081edaff24d8c22048122ca92ac23429c
parentbfa79cf52d62418f622289cee7c1fe5807c73be6 (diff)
downloadpakakeh.go-26a02a8396684fcb58f4ba431ae5ae799eb35d68.tar.xz
text/diff: remove LineChanges
Defining []T as new type does not help on readability only make it confusing for future maintenances.
-rw-r--r--lib/text/diff/diff.go22
-rw-r--r--lib/text/diff/linechanges.go27
2 files changed, 1 insertions, 48 deletions
diff --git a/lib/text/diff/diff.go b/lib/text/diff/diff.go
index 2e4102c0..1c0ae70d 100644
--- a/lib/text/diff/diff.go
+++ b/lib/text/diff/diff.go
@@ -8,8 +8,6 @@ import (
"bytes"
"fmt"
"strings"
-
- "git.sr.ht/~shulhan/pakakeh.go/lib/text"
)
// Data stores additions, deletions, and changes between two texts.
@@ -24,7 +22,7 @@ type Data struct {
Adds []Line
Dels []Line
- Changes LineChanges
+ Changes []LineChange
// Unified contains the result of [Unified] diff, without the label
// ("@@ ... @@") and context lines.
@@ -223,24 +221,6 @@ func (diff *Data) checkIsMatched() {
diff.IsMatched = true
}
-// GetAllAdds returns chunks of additions including the line changes.
-func (diff Data) GetAllAdds() (chunks text.Chunks) {
- for _, add := range diff.Adds {
- chunks = append(chunks, text.Chunk{StartAt: 0, V: add.Val})
- }
- chunks = append(chunks, diff.Changes.GetAllAdds()...)
- return
-}
-
-// GetAllDels returns chunks of deletions including the line changes.
-func (diff Data) GetAllDels() (chunks text.Chunks) {
- for _, del := range diff.Dels {
- chunks = append(chunks, text.Chunk{StartAt: 0, V: del.Val})
- }
- chunks = append(chunks, diff.Changes.GetAllDels()...)
- return
-}
-
// PushAdd adds new line to slice of Adds.
func (diff *Data) PushAdd(new Line) {
new.Kind = LineKindAdd
diff --git a/lib/text/diff/linechanges.go b/lib/text/diff/linechanges.go
deleted file mode 100644
index 5549f568..00000000
--- a/lib/text/diff/linechanges.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-// SPDX-FileCopyrightText: 2018 Shulhan <ms@kilabit.info>
-
-package diff
-
-import (
- "git.sr.ht/~shulhan/pakakeh.go/lib/text"
-)
-
-// LineChanges represents a set of change in text.
-type LineChanges []LineChange
-
-// GetAllDels return all deleted chunks.
-func (changes *LineChanges) GetAllDels() (allDels text.Chunks) {
- for _, change := range *changes {
- allDels = append(allDels, change.Dels...)
- }
- return
-}
-
-// GetAllAdds return all addition chunks.
-func (changes *LineChanges) GetAllAdds() (allAdds text.Chunks) {
- for _, change := range *changes {
- allAdds = append(allAdds, change.Adds...)
- }
- return
-}