Skip to content

Commit

Permalink
Read value of $TEXINPUTS when resolving a file reference, fix #3038
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Jul 9, 2023
1 parent 6344a4c commit 3c7f8aa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/nl/hannahsten/texifyidea/reference/InputFileReference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ import nl.hannahsten.texifyidea.psi.LatexCommands
import nl.hannahsten.texifyidea.psi.LatexPsiHelper
import nl.hannahsten.texifyidea.run.latex.LatexRunConfiguration
import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil
import nl.hannahsten.texifyidea.util.LatexmkRcFileFinder
import nl.hannahsten.texifyidea.util.expandCommandsOnce
import nl.hannahsten.texifyidea.util.*
import nl.hannahsten.texifyidea.util.files.*
import nl.hannahsten.texifyidea.util.includedPackages
import nl.hannahsten.texifyidea.util.isTestProject
import nl.hannahsten.texifyidea.util.magic.CommandMagic

/**
Expand Down Expand Up @@ -122,15 +119,17 @@ class InputFileReference(

// Check environment variables
val runManager = RunManagerImpl.getInstanceImpl(element.project) as RunManager
val texInputPath = runManager.allConfigurationsList
val texinputsVariable = runManager.allConfigurationsList
.filterIsInstance<LatexRunConfiguration>()
.firstOrNull { it.mainFile in rootFiles }
?.environmentVariables
?.envs
?.getOrDefault("TEXINPUTS", null)
// Not sure which of these takes precedence, or if they are joined together
?: LatexmkRcFileFinder.getTexinputsVariable(element.containingFile, null)
?: runCommand("kpsewhich", "--expand-var", "'\$TEXINPUTS'")

if (texInputPath != null) {
for (texInputPath in texinputsVariable?.split(":")?.filter { it.isNotBlank() } ?: emptyList()) {
val path = texInputPath.trimEnd(':')
searchPaths.add(path.trimEnd('/'))
// See the kpathsea manual, // expands to subdirs
Expand Down

0 comments on commit 3c7f8aa

Please sign in to comment.