@@ -1897,31 +1897,42 @@ public static Collection<Pair<String, String>> getTwigPathFromYamlConfigResolved
18971897 Collection <Pair <String , String >> paths = new ArrayList <>();
18981898
18991899 for (Pair <String , String > pair : getTwigPathFromYamlConfig (yamlFile )) {
1900- String second = pair .getSecond ();
1900+ // normalize path; just to be error prune
1901+ String namespacePath = pair .getSecond ().replace ("\\ " , "/" ).replaceAll ("/+" , "/" );
1902+ String namespace = pair .getFirst ();
19011903
1902- if (second .startsWith ("%kernel.root_dir%" )) {
1904+ if (namespacePath .startsWith ("%kernel.root_dir%" )) {
19031905 // %kernel.root_dir%/../app
19041906 // %kernel.root_dir%/foo
19051907 for (VirtualFile appDir : FilesystemUtil .getAppDirectories (yamlFile .getProject ())) {
1906- String path = StringUtils .stripStart (second .substring ("%kernel.root_dir%" .length ()), "/" );
1908+ String path = StringUtils .stripStart (namespacePath .substring ("%kernel.root_dir%" .length ()), "/" );
19071909
19081910 VirtualFile relativeFile = VfsUtil .findRelativeFile (appDir , path .split ("/" ));
19091911 if (relativeFile != null ) {
19101912 String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
19111913 if (relativePath != null ) {
1912- paths .add (Pair .create (pair . getFirst () , relativePath ));
1914+ paths .add (Pair .create (namespace , relativePath ));
19131915 }
19141916 }
19151917 }
1916- } else if (second .startsWith ("%kernel.project_dir%" )) {
1918+ } else if (namespacePath .startsWith ("%kernel.project_dir%" )) {
19171919 // '%kernel.root_dir%/test'
1918- String path = StringUtils .stripStart (second .substring ("%kernel.project_dir%" .length ()), "/" );
1920+ String path = StringUtils .stripStart (namespacePath .substring ("%kernel.project_dir%" .length ()), "/" );
19191921
1920- VirtualFile relativeFile = VfsUtil .findRelativeFile (yamlFile . getProject (). getBaseDir () , path .split ("/" ));
1922+ VirtualFile relativeFile = VfsUtil .findRelativeFile (baseDir , path .split ("/" ));
19211923 if (relativeFile != null ) {
19221924 String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
19231925 if (relativePath != null ) {
1924- paths .add (Pair .create (pair .getFirst (), relativePath ));
1926+ paths .add (Pair .create (namespace , relativePath ));
1927+ }
1928+ }
1929+ } else if (!namespacePath .startsWith ("/" ) && !namespacePath .startsWith ("\\ " )) {
1930+ // 'test/foo'
1931+ VirtualFile relativeFile = VfsUtil .findRelativeFile (baseDir , namespacePath .split ("/" ));
1932+ if (relativeFile != null ) {
1933+ String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
1934+ if (relativePath != null ) {
1935+ paths .add (Pair .create (namespace , relativePath ));
19251936 }
19261937 }
19271938 }
0 commit comments