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

Function DiffFiles

texteditor/diffeditor.go:34–49  ·  view source on GitHub ↗

DiffFiles shows the diffs between this file as the A file, and other file as B file, in a DiffEditorDialog

(ctx core.Widget, afile, bfile string)

Source from the content-addressed store, hash-verified

32// DiffFiles shows the diffs between this file as the A file, and other file as B file,
33// in a DiffEditorDialog
34func DiffFiles(ctx core.Widget, afile, bfile string) (*DiffEditor, error) {
35 ab, err := os.ReadFile(afile)
36 if err != nil {
37 slog.Error(err.Error())
38 return nil, err
39 }
40 bb, err := os.ReadFile(bfile)
41 if err != nil {
42 slog.Error(err.Error())
43 return nil, err
44 }
45 astr := stringsx.SplitLines(string(ab))
46 bstr := stringsx.SplitLines(string(bb))
47 dlg := DiffEditorDialog(ctx, "Diff File View", astr, bstr, afile, bfile, "", "")
48 return dlg, nil
49}
50
51// DiffEditorDialogFromRevs opens a dialog for displaying diff between file
52// at two different revisions from given repository

Callers 1

pasteFilesMethod · 0.92

Calls 4

SplitLinesFunction · 0.92
DiffEditorDialogFunction · 0.85
ReadFileMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected