File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/main/java/com/tang/intellij/lua/ext Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,23 @@ import com.tang.intellij.lua.project.LuaSettings
2525class LuaFileAdditionalResolver : ILuaFileResolver {
2626 override fun find (project : Project , shortUrl : String , extNames : Array <String >): VirtualFile ? {
2727 val sourcesRoot = LuaSettings .instance.additionalSourcesRoot
28+ var firstMatch: VirtualFile ? = null
2829 for (sr in sourcesRoot) {
2930 for (ext in extNames) {
3031 val path = " $sr /$shortUrl$ext "
3132 val file = VirtualFileManager .getInstance().findFileByUrl(VfsUtil .pathToUrl(path))
3233 if (file != null && ! file.isDirectory) {
33- return file
34+ firstMatch = firstMatch ? : file
35+ val filePath = file.canonicalPath
36+ val projectBasePath = project.basePath
37+ // Is the file in the project folder?
38+ if (filePath != null && projectBasePath != null && filePath.startsWith(projectBasePath))
39+ return file
3440 }
3541 }
3642 }
37- return null
43+ // If no file is found or found files do not in project folder, return the first match (maybe bull)
44+ // the same as previous behaviour
45+ return firstMatch
3846 }
3947}
You can’t perform that action at this time.
0 commit comments