Skip to content

Commit

Permalink
Add read actions
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Dec 13, 2024
1 parent ca8586e commit 815638f
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.hannahsten.texifyidea.index.file

import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task.Backgroundable
Expand Down Expand Up @@ -77,16 +78,20 @@ class LatexIndexableSetContributor : IndexableSetContributor() {
if (Cache.externalDirectFileInclusions == null && !DumbService.isDumb(project)) {
runInBackground(project, "Searching for external bib files...") {
// For now, just do this for bibliography and direct input commands, as there this is most common
val externalFiles = LatexIncludesIndex.Util.getCommandsByNames(CommandMagic.includeOnlyExtensions.entries.filter { it.value.contains("bib") || it.value.contains("tex") }.map { it.key }.toSet(), project, GlobalSearchScope.projectScope(project))
val commandNames = CommandMagic.includeOnlyExtensions.entries.filter { it.value.contains("bib") || it.value.contains("tex") }.map { it.key }.toSet()
val externalFiles = runReadAction {
LatexIncludesIndex.Util.getCommandsByNames(commandNames, project, GlobalSearchScope.projectScope(project))
}
// We can't add single files, so take the parent
.mapNotNull {
val path = it.requiredParameter(0) ?: return@mapNotNull null
if (File(path).isAbsolute) {
LocalFileSystem.getInstance().findFileByPath(path)?.parent
val path = runReadAction { it.requiredParameter(0) } ?: return@mapNotNull null
val file = if (File(path).isAbsolute) {
LocalFileSystem.getInstance().findFileByPath(path)
}
else {
it.containingFile.parent?.virtualFile?.findFileByRelativePath(path)?.parent
runReadAction { it.containingFile.parent }?.virtualFile?.findFileByRelativePath(path)
}
runReadAction { file?.parent }
}
Cache.externalDirectFileInclusions = externalFiles.toSet()
}
Expand Down

0 comments on commit 815638f

Please sign in to comment.