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

Function ExampleGetContextDiffString

texteditor/difflib/difflib_test.go:185–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183}
184
185func ExampleGetContextDiffString() {
186 a := `one
187two
188three
189four`
190 b := `zero
191one
192tree
193four`
194 diff := ContextDiff{
195 A: SplitLines(a),
196 B: SplitLines(b),
197 FromFile: "Original",
198 ToFile: "Current",
199 Context: 3,
200 Eol: "\n",
201 }
202 result, _ := GetContextDiffString(diff)
203 fmt.Print(strings.Replace(result, "\t", " ", -1))
204 // Output:
205 // *** Original
206 // --- Current
207 // ***************
208 // *** 1,4 ****
209 // one
210 // ! two
211 // ! three
212 // four
213 // --- 1,4 ----
214 // + zero
215 // one
216 // ! tree
217 // four
218}
219
220func rep(s string, count int) string {
221 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