From 6344a4c29e614f76abb3dfb71841dc0a8008d161 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Sun, 9 Jul 2023 19:45:50 +0200 Subject: [PATCH 1/2] Include spaces in .latexmkrc regex --- src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt b/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt index 4d933f10d..6096a13ff 100644 --- a/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt +++ b/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt @@ -107,7 +107,7 @@ object LatexmkRcFileFinder { * Get TEXINPUTS from latexmkrc. */ private fun getTexinputs(file: VirtualFile): String? { - return """ensure_path\('TEXINPUTS',\s*'(?[^']+)'\)""".toRegex().find(file.inputStream.reader().readText())?.groups?.get("path")?.value + return """ensure_path\(\s*'TEXINPUTS',\s*'(?[^']+)'\s*\)""".toRegex().find(file.inputStream.reader().readText())?.groups?.get("path")?.value } private var usesLatexmkrc: Boolean? = null From 3c7f8aaf9545d2c28010dff0f0b89b2790d8f513 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Sun, 9 Jul 2023 20:16:56 +0200 Subject: [PATCH 2/2] Read value of $TEXINPUTS when resolving a file reference, fix #3038 --- .../texifyidea/reference/InputFileReference.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt index 65a6a900e..430839b5b 100644 --- a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt +++ b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt @@ -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 /** @@ -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() .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