Skip to content

Commit

Permalink
Let ctrl-g search more files for definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Dec 11, 2023
1 parent bb742ae commit c884fac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions v2/gotodef.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,22 @@ func (e *Editor) GoToDefinition(tty *vt100.TTY, c *vt100.Canvas, status *StatusB

ext := filepath.Ext(e.filename)

filenames, err := filepath.Glob("*" + ext)
if err == nil { // success
var filenames []string

if curDirFilenames, err := filepath.Glob("*" + ext); err == nil { // success
filenames = append(filenames, curDirFilenames...)
}
if absFilename, err := filepath.Abs(e.filename); err == nil { // success
sourceDir := filepath.Join(filepath.Dir(absFilename), "*"+ext)
if sourceDirFiles, err := filepath.Glob(sourceDir); err == nil { // success
filenames = append(filenames, sourceDirFiles...)
}
}
if filenamesParent, err := filepath.Glob("../*" + ext); err == nil { // success
filenames = append(filenames, filenamesParent...)
}

if len(filenames) > 0 { // success, found .go files to examine
for _, goFile := range filenames {
data, err := os.ReadFile(goFile)
if err != nil {
Expand Down

0 comments on commit c884fac

Please sign in to comment.