@@ -18,6 +18,7 @@ func UpdateLibraryPath(pkg *models.Package) {
18
18
updateGlobalLibraryPath ()
19
19
} else {
20
20
updateDprojLibraryPath (pkg )
21
+ updateGlobalBrowsingPath ()
21
22
}
22
23
23
24
}
@@ -40,6 +41,27 @@ func cleanPath(paths []string, fullPath bool) []string {
40
41
return processedPaths
41
42
}
42
43
44
+ func GetNewBrowsingPaths (paths []string , fullPath bool , rootPath string ) []string {
45
+ paths = cleanPath (paths , fullPath )
46
+ var path = env .GetModulesDir ()
47
+
48
+ matches , _ := ioutil .ReadDir (path )
49
+
50
+ for _ , value := range matches {
51
+
52
+ var packagePath = filepath .Join (path , value .Name (), consts .FilePackage )
53
+ if _ , err := os .Stat (packagePath ); ! os .IsNotExist (err ) {
54
+
55
+ other , _ := models .LoadPackageOther (packagePath )
56
+ if other .BrowsingPath != "" {
57
+ paths = getNewBrowsingPathsFromDir (filepath .Join (path , value .Name (), other .BrowsingPath ), paths , fullPath , rootPath )
58
+ }
59
+
60
+ }
61
+ }
62
+ return paths
63
+ }
64
+
43
65
func GetNewPaths (paths []string , fullPath bool , rootPath string ) []string {
44
66
paths = cleanPath (paths , fullPath )
45
67
var path = env .GetModulesDir ()
@@ -99,6 +121,33 @@ func cleanEmpty(paths []string) []string {
99
121
return paths
100
122
}
101
123
124
+ func getNewBrowsingPathsFromDir (path string , paths []string , fullPath bool , rootPath string ) []string {
125
+ _ , e := os .Stat (path )
126
+ if os .IsNotExist (e ) {
127
+ return paths
128
+ }
129
+
130
+ _ = filepath .Walk (path , func (path string , info os.FileInfo , err error ) error {
131
+ matched , _ := regexp .MatchString (consts .RegexArtifacts , info .Name ())
132
+ if matched {
133
+ dir , _ := filepath .Split (path )
134
+ if ! fullPath {
135
+ dir , _ = filepath .Rel (rootPath , dir )
136
+ }
137
+ if ! utils .Contains (paths , dir ) {
138
+ paths = append (paths , dir )
139
+ }
140
+ // add ..\ prefixed path -> @MeroFuruya fix #146
141
+ //prefixedPath := "..\\" + dir
142
+ //if !utils.Contains(paths, prefixedPath) {
143
+ // paths = append(paths, prefixedPath)
144
+ //}
145
+ }
146
+ return nil
147
+ })
148
+ return cleanEmpty (paths )
149
+ }
150
+
102
151
func getNewPathsFromDir (path string , paths []string , fullPath bool , rootPath string ) []string {
103
152
_ , e := os .Stat (path )
104
153
if os .IsNotExist (e ) {
0 commit comments