Skip to content

Commit

Permalink
Fix #1874 (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed May 8, 2021
1 parent 2b1c753 commit 1a66cdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiFile
Expand Down Expand Up @@ -67,7 +68,12 @@ class LatexUnicodeInspection : TexifyInspectionBase() {
internal fun unicodeEnabled(file: PsiFile): Boolean {
// TeX Live 2018 is UTF-8 by default and loads inputenc automatically
val compilerCompat = file.project.selectedRunConfig()?.compiler ?: return false
if (compilerCompat == LatexCompiler.LUALATEX || compilerCompat == LatexCompiler.XELATEX || TexliveSdk.version >= 2018) {
if (compilerCompat == LatexCompiler.LUALATEX
|| compilerCompat == LatexCompiler.XELATEX
|| TexliveSdk.version >= 2018
// On Mac we cannot find the TeX Live version
|| SystemInfo.isMac
) {
return true
}

Expand Down
11 changes: 5 additions & 6 deletions src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.hannahsten.texifyidea.util

import com.intellij.execution.configurations.GeneralCommandLine
import java.io.File
import java.io.IOException
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -39,12 +40,10 @@ class SystemEnvironment {
*/
fun runCommand(vararg commands: String, workingDirectory: File? = null): String? {
return try {
val command = arrayListOf(*commands)
val proc = ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.directory(workingDirectory)
.start()
val proc = GeneralCommandLine(*commands)
.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
.withWorkDirectory(workingDirectory)
.createProcess()

if (proc.waitFor(3, TimeUnit.SECONDS)) {
proc.inputStream.bufferedReader().readText().trim() + proc.errorStream.bufferedReader().readText().trim()
Expand Down

0 comments on commit 1a66cdb

Please sign in to comment.