forked from toolshed/abra
chore: bump deps
This commit is contained in:
39
vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go
generated
vendored
39
vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go
generated
vendored
@ -1146,13 +1146,28 @@ func (dmp *DiffMatchPatch) DiffPrettyText(diffs []Diff) string {
|
||||
|
||||
switch diff.Type {
|
||||
case DiffInsert:
|
||||
_, _ = buff.WriteString("\x1b[32m")
|
||||
_, _ = buff.WriteString(text)
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
lines := strings.Split(text, "\n")
|
||||
for i, line := range lines {
|
||||
_, _ = buff.WriteString("\x1b[32m")
|
||||
_, _ = buff.WriteString(line)
|
||||
if i < len(lines)-1 {
|
||||
_, _ = buff.WriteString("\x1b[0m\n")
|
||||
} else {
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
}
|
||||
}
|
||||
|
||||
case DiffDelete:
|
||||
_, _ = buff.WriteString("\x1b[31m")
|
||||
_, _ = buff.WriteString(text)
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
lines := strings.Split(text, "\n")
|
||||
for i, line := range lines {
|
||||
_, _ = buff.WriteString("\x1b[31m")
|
||||
_, _ = buff.WriteString(line)
|
||||
if i < len(lines)-1 {
|
||||
_, _ = buff.WriteString("\x1b[0m\n")
|
||||
} else {
|
||||
_, _ = buff.WriteString("\x1b[0m")
|
||||
}
|
||||
}
|
||||
case DiffEqual:
|
||||
_, _ = buff.WriteString(text)
|
||||
}
|
||||
@ -1305,7 +1320,6 @@ func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Di
|
||||
|
||||
// diffLinesToStrings splits two texts into a list of strings. Each string represents one line.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, string, []string) {
|
||||
// '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character.
|
||||
lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n'
|
||||
|
||||
lineHash := make(map[string]int)
|
||||
@ -1316,12 +1330,11 @@ func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, stri
|
||||
return intArrayToString(strIndexArray1), intArrayToString(strIndexArray2), lineArray
|
||||
}
|
||||
|
||||
// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []string.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []uint32 {
|
||||
// Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect.
|
||||
// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
|
||||
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []index {
|
||||
lineStart := 0
|
||||
lineEnd := -1
|
||||
strs := []uint32{}
|
||||
strs := []index{}
|
||||
|
||||
for lineEnd < len(text)-1 {
|
||||
lineEnd = indexOf(text, "\n", lineStart)
|
||||
@ -1335,11 +1348,11 @@ func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]str
|
||||
lineValue, ok := lineHash[line]
|
||||
|
||||
if ok {
|
||||
strs = append(strs, uint32(lineValue))
|
||||
strs = append(strs, index(lineValue))
|
||||
} else {
|
||||
*lineArray = append(*lineArray, line)
|
||||
lineHash[line] = len(*lineArray) - 1
|
||||
strs = append(strs, uint32(len(*lineArray)-1))
|
||||
strs = append(strs, index(len(*lineArray)-1))
|
||||
}
|
||||
}
|
||||
|
||||
|
32
vendor/github.com/sergi/go-diff/diffmatchpatch/index.go
generated
vendored
Normal file
32
vendor/github.com/sergi/go-diff/diffmatchpatch/index.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package diffmatchpatch
|
||||
|
||||
type index uint32
|
||||
|
||||
const runeSkipStart = 0xd800
|
||||
const runeSkipEnd = 0xdfff + 1
|
||||
const runeMax = 0x110000 // next invalid code point
|
||||
|
||||
func stringToIndex(text string) []index {
|
||||
runes := []rune(text)
|
||||
indexes := make([]index, len(runes))
|
||||
for i, r := range runes {
|
||||
if r < runeSkipEnd {
|
||||
indexes[i] = index(r)
|
||||
} else {
|
||||
indexes[i] = index(r) - (runeSkipEnd - runeSkipStart)
|
||||
}
|
||||
}
|
||||
return indexes
|
||||
}
|
||||
|
||||
func indexesToString(indexes []index) string {
|
||||
runes := make([]rune, len(indexes))
|
||||
for i, index := range indexes {
|
||||
if index < runeSkipStart {
|
||||
runes[i] = rune(index)
|
||||
} else {
|
||||
runes[i] = rune(index + (runeSkipEnd - runeSkipStart))
|
||||
}
|
||||
}
|
||||
return string(runes)
|
||||
}
|
4
vendor/github.com/sergi/go-diff/diffmatchpatch/stringutil.go
generated
vendored
4
vendor/github.com/sergi/go-diff/diffmatchpatch/stringutil.go
generated
vendored
@ -93,14 +93,14 @@ func runesIndex(r1, r2 []rune) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func intArrayToString(ns []uint32) string {
|
||||
func intArrayToString(ns []index) string {
|
||||
if len(ns) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
b := []rune{}
|
||||
for _, n := range ns {
|
||||
b = append(b, intToRune(n))
|
||||
b = append(b, intToRune(uint32(n)))
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
Reference in New Issue
Block a user