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

Method OpenBuf

filetree/node.go:452–472  ·  view source on GitHub ↗

OpenBuf opens the file in its buffer if it is not already open. returns true if file is newly opened

()

Source from the content-addressed store, hash-verified

450// OpenBuf opens the file in its buffer if it is not already open.
451// returns true if file is newly opened
452func (fn *Node) OpenBuf() (bool, error) {
453 if fn.IsDir() {
454 err := fmt.Errorf("filetree.Node cannot open directory in editor: %v", fn.Filepath)
455 log.Println(err)
456 return false, err
457 }
458 if fn.Buffer != nil {
459 if fn.Buffer.Filename == fn.Filepath { // close resets filename
460 return false, nil
461 }
462 } else {
463 fn.Buffer = texteditor.NewBuffer()
464 fn.Buffer.OnChange(func(e events.Event) {
465 if fn.Info.VCS == vcs.Stored {
466 fn.Info.VCS = vcs.Modified
467 }
468 })
469 }
470 fn.Buffer.SetHighlighting(NodeHighlighting)
471 return true, fn.Buffer.Open(fn.Filepath)
472}
473
474// removeFromExterns removes file from list of external files
475func (fn *Node) removeFromExterns() { //types:add

Callers

nothing calls this directly

Calls 7

IsDirMethod · 0.95
NewBufferFunction · 0.92
PrintlnMethod · 0.80
SetHighlightingMethod · 0.80
ErrorfMethod · 0.65
OpenMethod · 0.65
OnChangeMethod · 0.45

Tested by

no test coverage detected