summaryrefslogtreecommitdiff
path: root/vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2019-11-12 10:54:20 -0500
committerGitHub <noreply@github.com>2019-11-12 10:54:20 -0500
commit677ea79e35e3010ab574e617670e5240ef7a7cba (patch)
tree4fcd1348fc74e17d3ee1e55aacb74346dbc26afb /vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go
parentede87d4afa31ddf55e1a115e22c01c2f4a7b8e74 (diff)
parent744dfe262acc681c78549c250b6db8e31312f2c9 (diff)
Merge pull request #661 from hairyhenderson/git-datasource
New git datasource
Diffstat (limited to 'vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go')
-rw-r--r--vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go b/vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go
new file mode 100644
index 00000000..d3acc32c
--- /dev/null
+++ b/vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go
@@ -0,0 +1,46 @@
+// Copyright (c) 2012-2016 The go-diff authors. All rights reserved.
+// https://github.com/sergi/go-diff
+// See the included LICENSE file for license details.
+//
+// go-diff is a Go implementation of Google's Diff, Match, and Patch library
+// Original library is Copyright (c) 2006 Google Inc.
+// http://code.google.com/p/google-diff-match-patch/
+
+// Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text.
+package diffmatchpatch
+
+import (
+ "time"
+)
+
+// DiffMatchPatch holds the configuration for diff-match-patch operations.
+type DiffMatchPatch struct {
+ // Number of seconds to map a diff before giving up (0 for infinity).
+ DiffTimeout time.Duration
+ // Cost of an empty edit operation in terms of edit characters.
+ DiffEditCost int
+ // How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match).
+ MatchDistance int
+ // When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that MatchThreshold controls how closely the end points of a delete need to match.
+ PatchDeleteThreshold float64
+ // Chunk size for context length.
+ PatchMargin int
+ // The number of bits in an int.
+ MatchMaxBits int
+ // At what point is no match declared (0.0 = perfection, 1.0 = very loose).
+ MatchThreshold float64
+}
+
+// New creates a new DiffMatchPatch object with default parameters.
+func New() *DiffMatchPatch {
+ // Defaults.
+ return &DiffMatchPatch{
+ DiffTimeout: time.Second,
+ DiffEditCost: 4,
+ MatchThreshold: 0.5,
+ MatchDistance: 1000,
+ PatchDeleteThreshold: 0.5,
+ PatchMargin: 4,
+ MatchMaxBits: 32,
+ }
+}