Skip to content

Commit db5e4ea

Browse files
committed
refactor: Optimize project file search and remove redundant code
1 parent 5b4dea6 commit db5e4ea

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/utils/ProjectFileUtil.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ fun Project.lookupFile(path: String): VirtualFile? {
1919

2020
fun Project.findFile(filename: String, caseSensitively: Boolean = true): VirtualFile? {
2121
ApplicationManager.getApplication().assertReadAccessAllowed()
22-
val currentTask = ApplicationManager.getApplication().executeOnPooledThread<VirtualFile?> {
23-
val searchedFiles = runReadAction {
24-
FilenameIndex.getVirtualFilesByName(filename, caseSensitively, ProjectScope.getContentScope(this))
25-
}
26-
return@executeOnPooledThread searchedFiles.firstOrNull()
27-
}
28-
29-
return currentTask.get(5, TimeUnit.SECONDS)
22+
return FilenameIndex.getVirtualFilesByName(filename, ProjectScope.getContentScope(this)).firstOrNull()
3023
}
3124

3225
fun VirtualFile.canBeAdded(): Boolean {

0 commit comments

Comments
 (0)