MCPcopy Create free account
hub / github.com/cogentcore/core / ExampleGetContextDiffString

Function ExampleGetContextDiffString

texteditor/difflib/bytes/bytes_test.go:202–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200}
201
202func ExampleGetContextDiffString() {
203 a := `one
204two
205three
206four`
207 b := `zero
208one
209tree
210four`
211 diff := ContextDiff{
212 A: SplitLines([]byte(a)),
213 B: SplitLines([]byte(b)),
214 FromFile: "Original",
215 ToFile: "Current",
216 Context: 3,
217 Eol: []byte{'\n'},
218 }
219 result, _ := GetContextDiffString(diff)
220 fmt.Print(strings.Replace(string(result), "\t", " ", -1))
221 // Output:
222 // *** Original
223 // --- Current
224 // ***************
225 // *** 1,4 ****
226 // one
227 // ! two
228 // ! three
229 // four
230 // --- 1,4 ----
231 // + zero
232 // one
233 // ! tree
234 // four
235}
236
237func rep(s string, count int) string {
238 return strings.Repeat(s, count)

Callers

nothing calls this directly

Calls 3

SplitLinesFunction · 0.70
GetContextDiffStringFunction · 0.70
PrintMethod · 0.45

Tested by

no test coverage detected