Skip to content

Commit

Permalink
open source of generated files, not the generated file, for errors an…
Browse files Browse the repository at this point in the history
…d other links.
  • Loading branch information
rcoreilly committed Oct 8, 2024
1 parent 65cef3a commit f99204d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions code/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ func (cv *Code) OpenFileURL(ur string, ftv *texteditor.Editor) bool {
}
}
pos := up.Fragment

tv, _, ok := cv.LinkViewFile(core.Filename(fpath))
if !ok {
_, fnm := filepath.Split(fpath)
Expand Down
24 changes: 23 additions & 1 deletion code/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"cogentcore.org/core/base/fileinfo"
"cogentcore.org/core/base/fsx"
"cogentcore.org/core/core"
"cogentcore.org/core/events"
"cogentcore.org/core/filetree"
Expand Down Expand Up @@ -319,13 +320,34 @@ func (cv *Code) LinkViewFileNode(fn *filetree.Node) (*TextEditor, int) {
return tv, idx
}

// GeneratedFileExts are file extensions for the source file that generates
// another file. If a file is opened that is marked as generated, this list is
// used to look for another file with the same name and the source extention,
// and it is opened instead.
var GeneratedFileExts = map[string]string{
".goal": ".go",
}

// LinkViewFile opens the file in the 2nd texteditor, which is next to
// the tabs where links are clicked, if it is not collapsed -- else 1st
func (cv *Code) LinkViewFile(fnm core.Filename) (*TextEditor, int, bool) {
fn := cv.FileNodeForFile(string(fnm), true)
fn := cv.FileNodeForFile(string(fnm), true) // add if not found
if fn == nil {
return nil, -1, false
}
if fn.Info.Generated {

Check failure on line 338 in code/files.go

View workflow job for this annotation

GitHub Actions / build

fn.Info.Generated undefined (type fileinfo.FileInfo has no field or method Generated)
bfnm, ext := fsx.ExtSplit(string(fnm))
for ex, fex := range GeneratedFileExts {
if fex == ext {
nfnm := bfnm + ex
nfn := cv.FileNodeForFile(nfnm, false)
if nfn != nil {
fn = nfn
break
}
}
}
}
tv, idx, ok := cv.TextEditorForFileNode(fn)
if ok {
if idx == 1 {
Expand Down

0 comments on commit f99204d

Please sign in to comment.