@@ -22,8 +22,8 @@ private IsFileInEditableModuleUtil() {}
22
22
* @return boolean
23
23
*/
24
24
public static boolean execute (final PsiFile file ) {
25
- Project project = file .getProject ();
26
- VirtualFile virtualFile = file .getVirtualFile ();
25
+ final Project project = file .getProject ();
26
+ final VirtualFile virtualFile = file .getVirtualFile ();
27
27
28
28
return execute (project , virtualFile );
29
29
}
@@ -35,10 +35,10 @@ public static boolean execute(final PsiFile file) {
35
35
* @param virtualFile the file to check against editable module directories
36
36
* @return true if the file is in an editable module directory, false otherwise
37
37
*/
38
- public static boolean execute (Project project , VirtualFile virtualFile ) {
39
- Settings settings = Settings .getInstance (project );
38
+ public static boolean execute (final Project project , final VirtualFile virtualFile ) {
39
+ final Settings settings = Settings .getInstance (project );
40
40
List <String > magentoToFolders = settings .getMagentoFolders ();
41
- String magentoPathUrl = MagentoPathUrlUtil .execute (project );
41
+ final String magentoPathUrl = MagentoPathUrlUtil .execute (project );
42
42
if (magentoPathUrl != null ) {
43
43
if (magentoToFolders == null ) {
44
44
magentoToFolders = List .of (
@@ -52,17 +52,31 @@ public static boolean execute(Project project, VirtualFile virtualFile) {
52
52
}
53
53
54
54
55
- final String filePath = virtualFile .getUrl ();
56
55
57
56
if (magentoToFolders == null ) {
58
57
return false ;
59
58
}
60
59
61
- for (String editablePath : magentoToFolders ) {
62
- if (filePath .startsWith (editablePath )) {
60
+ final String filePath = virtualFile .getUrl ();
61
+ for (final String editablePath : magentoToFolders ) {
62
+ if (normalizeUrl (filePath ).startsWith (normalizeUrl (editablePath ))) {
63
63
return true ;
64
64
}
65
65
}
66
66
return false ;
67
67
}
68
+
69
+ /**
70
+ * Normalizes a URL by removing the scheme (e.g., temp://, file://) to allow proper comparisons.
71
+ *
72
+ * @param url the URL to normalize
73
+ * @return the normalized URL as a String
74
+ */
75
+ private static String normalizeUrl (final String url ) {
76
+ final int schemeSeparatorIndex = url .indexOf ("://" );
77
+ if (schemeSeparatorIndex != -1 ) {
78
+ return url .substring (schemeSeparatorIndex + 3 );
79
+ }
80
+ return url ;
81
+ }
68
82
}
0 commit comments