@@ -10,48 +10,36 @@ export function getFilePath(text: string, document: TextDocument) {
1010}
1111
1212export function getFilePaths ( text : string , document : TextDocument ) {
13- let paths = scanViewPaths ( document ) ;
14- let config = workspace . getConfiguration ( 'laravel_goto_view' ) ;
1513 let workspaceFolder = workspace . getWorkspaceFolder ( document . uri ) . uri . fsPath ;
16- text = text . replace ( / \" | \' / g, '' ) ;
14+ let config = workspace . getConfiguration ( 'laravel_goto_view' ) ;
15+ let paths = scanViewPaths ( workspaceFolder , config ) ;
16+ let file = text . replace ( / \" | \' / g, '' ) . replace ( / : : | \. / g, '/' ) ;
1717 let result = [ ] ;
18- if ( text . indexOf ( "::" ) != - 1 ) {
19- let info = text . split ( '::' ) ;
18+
19+ for ( let item in paths ) {
2020 for ( let extension in config . extensions ) {
21- let showPath = paths [ info [ 0 ] ] + "/" + info [ 1 ] . replace ( / \. / g , '/' ) + config . extensions [ extension ] ;
21+ let showPath = paths [ item ] + `/ ${ file } ` + config . extensions [ extension ] ;
2222 let filePath = workspaceFolder + showPath ;
23+
2324 if ( fs . existsSync ( filePath ) ) {
2425 result . push ( {
25- "name" : info [ 0 ] ,
26+ "name" : item ,
2627 "showPath" : showPath ,
2728 "fileUri" : Uri . file ( filePath )
2829 } ) ;
2930 }
3031 }
31- } else {
32- for ( let item in paths ) {
33- for ( let extension in config . extensions ) {
34- let showPath = paths [ item ] + "/" + text . replace ( / \. / g, '/' ) + config . extensions [ extension ] ;
35- let filePath = workspaceFolder + showPath ;
36- if ( fs . existsSync ( filePath ) ) {
37- result . push ( {
38- "name" : item ,
39- "showPath" : showPath ,
40- "fileUri" : Uri . file ( filePath )
41- } ) ;
42- }
43- }
44- }
4532 }
4633
4734 return result ;
4835}
4936
50- export function scanViewPaths ( document : TextDocument ) {
51- let configFolders = workspace . getConfiguration ( 'laravel_goto_view.folders' ) ;
37+ export function scanViewPaths ( workspaceFolder , config ) {
38+ let configFolders = config . folders ;
39+
40+ // Modules
5241 let folders = { } ;
5342 Object . assign ( folders , configFolders ) ;
54- let workspaceFolder = workspace . getWorkspaceFolder ( document . uri ) . uri . fsPath ;
5543 let modulePath = path . join ( workspaceFolder , 'Modules' ) ;
5644 if ( fs . existsSync ( modulePath ) ) {
5745 fs . readdirSync ( modulePath ) . forEach ( element => {
@@ -61,5 +49,6 @@ export function scanViewPaths(document: TextDocument) {
6149 }
6250 } ) ;
6351 }
52+
6453 return folders ;
65- }
54+ }
0 commit comments