From fab8ccdf71029d05c9e84203703c426c6443b672 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Thu, 11 Jan 2024 12:43:23 +0100 Subject: [PATCH 1/4] Improve user feedback for preview when Inkscape is not installed --- .../action/preview/InkscapePreviewer.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt b/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt index 37962f263..38f23ecc6 100644 --- a/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt +++ b/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt @@ -87,10 +87,13 @@ $previewCode previewForm ) ?: return - runInkscape(tempBasename, tempDirectory, waitTime, previewForm) - val image = ImageIO.read(File("$tempBasename.png")) - SwingUtilities.invokeLater { - previewForm.setPreview(image, latexStdoutText) + // Sets error message to the UI if any + val success = runInkscape(tempBasename, tempDirectory, waitTime, previewForm) + if (success) { + val image = ImageIO.read(File("$tempBasename.png")) + SwingUtilities.invokeLater { + previewForm.setPreview(image, latexStdoutText) + } } } finally { @@ -106,7 +109,7 @@ $previewCode waitTime: Long, previewForm: PreviewForm ): String? { - val result = runCommandWithExitCode(command, *args, workingDirectory = workDirectory, timeout = waitTime) + val result = runCommandWithExitCode(command, *args, workingDirectory = workDirectory, timeout = waitTime, returnExceptionMessage = true) if (result.second != 0) { previewForm.setLatexErrorMessage("$command exited with ${result.second}\n${result.first ?: ""}") @@ -118,10 +121,12 @@ $previewCode /** * Run inkscape command to convert pdf to png, depending on the version of inkscape. + * + * @return If successful */ - private fun runInkscape(tempBasename: String, tempDirectory: File, waitTime: Long, previewForm: PreviewForm) { + private fun runInkscape(tempBasename: String, tempDirectory: File, waitTime: Long, previewForm: PreviewForm): Boolean { // If 1.0 or higher - if (SystemEnvironment.inkscapeMajorVersion >= 1) { + if (SystemEnvironment.inkscapeMajorVersion >= 1 || !SystemEnvironment.isAvailable("inkscape")) { runPreviewFormCommand( inkscapeExecutable(), arrayOf( @@ -135,7 +140,7 @@ $previewCode tempDirectory, waitTime, previewForm - ) ?: throw AccessDeniedException(tempDirectory) + ) ?: return false } else { runPreviewFormCommand( @@ -147,7 +152,7 @@ $previewCode tempDirectory, waitTime, previewForm - ) ?: return + ) ?: return false runPreviewFormCommand( inkscapeExecutable(), @@ -161,8 +166,9 @@ $previewCode tempDirectory, waitTime, previewForm - ) ?: throw AccessDeniedException(tempDirectory) + ) ?: return false } + return true } private fun inkscapeExecutable(): String { From 6d5889e3b1b272969cc73810abe9e2a03c50786c Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Thu, 11 Jan 2024 14:04:48 +0100 Subject: [PATCH 2/4] Add progress indicator --- .../texifyidea/action/preview/InkscapePreviewer.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt b/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt index 38f23ecc6..f67039f5f 100644 --- a/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt +++ b/src/nl/hannahsten/texifyidea/action/preview/InkscapePreviewer.kt @@ -1,10 +1,11 @@ package nl.hannahsten.texifyidea.action.preview +import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.progress.ProgressManager +import com.intellij.openapi.progress.Task import com.intellij.openapi.project.Project import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil import nl.hannahsten.texifyidea.util.SystemEnvironment import nl.hannahsten.texifyidea.util.runCommandWithExitCode @@ -21,8 +22,8 @@ import javax.swing.SwingUtilities class InkscapePreviewer : Previewer { override fun preview(input: String, previewForm: PreviewForm, project: Project, preamble: String, waitTime: Long) { - runBlocking { - launch { + ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Generating preview...") { + override fun run(indicator: ProgressIndicator) { try { // Snap apps are confined to the users home directory if (SystemEnvironment.isInkscapeInstalledAsSnap) { @@ -46,7 +47,7 @@ class InkscapePreviewer : Previewer { previewForm.setLatexErrorMessage("${exception.message}") } } - } + }) } /** From 0c2d3152c832189a0c2a2ad9895d8062c2c2a625 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 12 Jan 2024 08:48:49 +0100 Subject: [PATCH 3/4] 0.9.3-alpha.4 --- CHANGELOG.md | 21 +++++++++++++++++++-- gradle.properties | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e991ba3f6..7f2401c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,18 +6,34 @@ ### Fixed -## [0.9.3-alpha.3] - 2024-01-08 +## [0.9.3-alpha.4] - 2024-01-12 ### Added +* Improve autocompletion performance after starting IDE * Improve plugin loading performance ### Fixed +* Fix incorrectly inserted \items in enumeration environments, by @jojo2357 +* Fix false positives for equation gathering inspection, by @jojo2357 +* Don't attempt to use mthelp when it is not available, by @jojo2357 +* Fix #3361: false positive on duplicate identifier on @string entries in bib files +* Replace code deprecated in 2023.3 * Avoid creating output directories recursively and improve the cleanup process + +## [0.9.3-alpha.3] - 2024-01-08 + +### Added + +* Improve plugin loading performance + +### Fixed + * Don't attempt to use mthelp when it is not available, by @jojo2357 * Fix #3361: false positive on duplicate identifier on @string entries in bib files * Replace code deprecated in 2023.3 +* Avoid creating output directories recursively and improve the cleanup process ## [0.9.2] - 2023-11-24 @@ -268,8 +284,9 @@ Thanks to @jojo2357 and @MisterDeenis for contributing to this release! * Fix some intention previews. ([#2796](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2796)) * Other small bug fixes and improvements. ([#2776](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2776), [#2774](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2774), [#2765](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2765)-[#2773](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2773)) -[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3-alpha.3...HEAD +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3-alpha.4...HEAD [0.9.3-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2...v0.9.3-alpha.3 +[0.9.3-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3-alpha.3...v0.9.3-alpha.4 [0.9.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1...v0.9.2 [0.9.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.0...v0.9.1 [0.9.0]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.33...v0.9.0 diff --git a/gradle.properties b/gradle.properties index 2a85fdb8e..47fce7c79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.3-alpha.3 +pluginVersion = 0.9.3-alpha.4 # Info about build ranges: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.* From d74d3acfae11cf18b4eae12a53d825c56f21c485 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 12 Jan 2024 09:05:27 +0100 Subject: [PATCH 4/4] Raise since build to avoid compatibility problems --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 47fce7c79..ef31a30de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginVersion = 0.9.3-alpha.4 # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.* # means that the first possible build is the next branch number after xyz, so e.g. # a since build of 173.* is equal to 181 -pluginSinceBuild = 232 +pluginSinceBuild = 233 # Token for releasing to Jetbrains using the Gradle intellij/publishPlugin task, for more information see the Gradle build file. intellijPublishToken=mytoken