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

Method saveFile

texteditor/diffeditor.go:293–306  ·  view source on GitHub ↗

saveFile writes A or B edits to file, with no prompting, etc

(ab bool, filename core.Filename)

Source from the content-addressed store, hash-verified

291
292// saveFile writes A or B edits to file, with no prompting, etc
293func (dv *DiffEditor) saveFile(ab bool, filename core.Filename) error {
294 var txt string
295 if ab {
296 txt = strings.Join(dv.diffs.B.Edit, "\n")
297 } else {
298 txt = strings.Join(dv.diffs.A.Edit, "\n")
299 }
300 err := os.WriteFile(string(filename), []byte(txt), 0644)
301 if err != nil {
302 core.ErrorSnackbar(dv, err)
303 slog.Error(err.Error())
304 }
305 return err
306}
307
308// saveFileA saves the current state of file A to given filename
309func (dv *DiffEditor) saveFileA(fname core.Filename) { //types:add

Callers 1

saveAsMethod · 0.95

Calls 2

ErrorSnackbarFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected