]> Cypherpunks.ru repositories - goredo.git/commitdiff
Do not duplicate do-files
authorSergey Matveev <stargrave@stargrave.org>
Mon, 14 Dec 2020 16:38:25 +0000 (19:38 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 14 Dec 2020 16:38:25 +0000 (19:38 +0300)
It does not hurt redo workability itself, but confuses redo-whichdo.

do.go

diff --git a/do.go b/do.go
index 4ed91ddaa929c09112fb2c6021ab47b0c3307a45..360cc29b0e99fa51e306588b3e8024133a87f10d 100644 (file)
--- a/do.go
+++ b/do.go
@@ -49,6 +49,7 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) {
        if exists {
                return doFile, 0, nil
        }
+       doFileOrig := doFile
        levels := []string{}
        extsOrig := strings.Split(tgt, ".")[1:]
        dirAbsPrev := ""
@@ -59,6 +60,19 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) {
                        doFile = strings.Join(append(
                                []string{"default"}, append(exts, "do")...,
                        ), ".")
+                       if len(levels) > 0 || doFile != doFileOrig {
+                               exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile))
+                               if err != nil {
+                                       return "", 0, err
+                               }
+                               if exists {
+                                       return doFile, len(levels), nil
+                               }
+                       }
+                       exts = exts[1:]
+               }
+               doFile = "default.do"
+               if len(levels) > 0 || doFile != doFileOrig {
                        exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile))
                        if err != nil {
                                return "", 0, err
@@ -66,15 +80,6 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) {
                        if exists {
                                return doFile, len(levels), nil
                        }
-                       exts = exts[1:]
-               }
-               doFile = "default.do"
-               exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile))
-               if err != nil {
-                       return "", 0, err
-               }
-               if exists {
-                       return doFile, len(levels), nil
                }
                levels = append(levels, "..")
                dirAbs, err := filepath.Abs(updir)