From 2572e63035e7fb480bf46dbdcd18a0e6ae1064e8 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 15 Aug 2023 20:09:48 +0200 Subject: [PATCH 1/4] Don't overwrite non-LaTeX icons --- src/nl/hannahsten/texifyidea/TexifyIcons.kt | 11 ++++++----- .../pathcompletion/LatexPathProviderBase.kt | 3 ++- .../texifyidea/gutter/LatexNavigationGutter.kt | 3 ++- .../texifyidea/ui/TeXiFyProjectViewNodeDecorator.kt | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/TexifyIcons.kt b/src/nl/hannahsten/texifyidea/TexifyIcons.kt index c02ce1c15..b5c08c3db 100644 --- a/src/nl/hannahsten/texifyidea/TexifyIcons.kt +++ b/src/nl/hannahsten/texifyidea/TexifyIcons.kt @@ -221,15 +221,16 @@ object TexifyIcons { * * This method ignores case. * - * @param extension - * The extension of the file to get the icon of without a dot. + * @param extension The extension of the file to get the icon of without a dot. + * @param default Use this if you want to get an icon also if the extension is not known to TeXiFy + * * @return The Icon that corresponds to the given extension. * @throws IllegalArgumentException * When `extension` is null. */ - fun getIconFromExtension(extension: String?): Icon { + fun getIconFromExtension(extension: String?, default: Icon?=null): Icon? { return if (extension == null) { - FILE + default } else when (extension.lowercase(Locale.getDefault())) { "tex" -> LATEX_FILE @@ -243,7 +244,7 @@ object TexifyIcons { "pdf" -> PDF_FILE "synctex.gz" -> SYNCTEX_FILE "dvi" -> DVI_FILE - else -> FILE + else -> default } } diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt index 0793f46c4..dd32564be 100644 --- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt +++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt @@ -12,6 +12,7 @@ import com.intellij.psi.util.parentOfTypes import com.intellij.util.PlatformIcons import com.intellij.util.ProcessingContext import nl.hannahsten.texifyidea.TexifyIcons +import nl.hannahsten.texifyidea.TexifyIcons.FILE import nl.hannahsten.texifyidea.completion.handlers.CompositeHandler import nl.hannahsten.texifyidea.completion.handlers.FileNameInsertionHandler import nl.hannahsten.texifyidea.completion.handlers.LatexReferenceInsertHandler @@ -172,7 +173,7 @@ abstract class LatexPathProviderBase : CompletionProvider( if (validExtensions!!.contains(foundFile.extension).not()) return } - val icon = TexifyIcons.getIconFromExtension(foundFile.extension) + val icon = TexifyIcons.getIconFromExtension(foundFile.extension, default=FILE) resultSet?.addElement( LookupElementBuilder.create(baseDir + foundFile.name) .withPresentableText(foundFile.presentableName) diff --git a/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.kt b/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.kt index 391c2b397..3a8efa32e 100644 --- a/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.kt +++ b/src/nl/hannahsten/texifyidea/gutter/LatexNavigationGutter.kt @@ -6,6 +6,7 @@ import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder import com.intellij.ide.util.gotoByName.GotoFileCellRenderer import com.intellij.psi.PsiElement import nl.hannahsten.texifyidea.TexifyIcons +import nl.hannahsten.texifyidea.TexifyIcons.FILE import nl.hannahsten.texifyidea.lang.commands.LatexCommand import nl.hannahsten.texifyidea.lang.commands.RequiredFileArgument import nl.hannahsten.texifyidea.psi.LatexCommands @@ -57,7 +58,7 @@ class LatexNavigationGutter : RelatedItemLineMarkerProvider() { if (it.name.endsWith("synctex.gz")) "synctex.gz" else it.extension } // Gutter requires a smaller icon per IJ SDK docs. - val icon = TexifyIcons.getIconFromExtension(extension) + val icon = TexifyIcons.getIconFromExtension(extension, default = FILE) ?: return try { val builder = NavigationGutterIconBuilder diff --git a/src/nl/hannahsten/texifyidea/ui/TeXiFyProjectViewNodeDecorator.kt b/src/nl/hannahsten/texifyidea/ui/TeXiFyProjectViewNodeDecorator.kt index 1bae215da..97a0545f6 100644 --- a/src/nl/hannahsten/texifyidea/ui/TeXiFyProjectViewNodeDecorator.kt +++ b/src/nl/hannahsten/texifyidea/ui/TeXiFyProjectViewNodeDecorator.kt @@ -30,7 +30,8 @@ class TeXiFyProjectViewNodeDecorator : ProjectViewNodeDecorator { // Allow Material design plugins to take over the icons // For file types registered in plugin.xml this happens automatically if (PluginManager.getLoadedPlugins().none { it.name.contains("Material") }) { - val icon = TexifyIcons.getIconFromExtension(extension.lowercase(Locale.getDefault())) + // Make sure to now override non-LaTeX extensions with the default icon + val icon = TexifyIcons.getIconFromExtension(extension.lowercase(Locale.getDefault()), default = null) ?: return presentationData.setIcon(icon) } } From 486167a888b78e84af6617a3043ca0c2ab2f099e Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 15 Aug 2023 20:23:26 +0200 Subject: [PATCH 2/4] Release 0.9.1 --- CHANGELOG.md | 12 +++++++++++- build.gradle.kts | 2 +- gradle.properties | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6d428650..a95fba0c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,19 @@ ## [Unreleased] +### Added + +### Fixed + +## [0.9.1] - 2023-08-15 + +This release fixes a bug related to the new file icons from the previous release. + ### Added * Improve performance on plugin installation ### Fixed +* Fix a bug where the plugin would override file icons of non-LaTeX files ## [0.9.0] - 2023-08-14 Welcome to TeXiFy IDEA 0.9.0! In this release, we celebrate the completely new icon set by @HannahSchellekens which blends in much better with the new IntelliJ UI. @@ -193,7 +202,8 @@ 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.0...HEAD +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1-alpha.1...HEAD +[0.9.1-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.0...v0.9.1-alpha.1 [0.9.0]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.33...v0.9.0 [0.7.33]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.32...v0.7.33 [0.7.32]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.31...v0.7.32 diff --git a/build.gradle.kts b/build.gradle.kts index eb8d37306..350c1639f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -136,7 +136,7 @@ dependencies { // Enable use of the JUnitPlatform Runner within the IDE testImplementation("org.junit.platform:junit-platform-runner:1.10.0") - testImplementation("io.mockk:mockk:1.13.5") + testImplementation("io.mockk:mockk:1.13.7") // Add custom ruleset from github.com/slideclimb/ktlint-ruleset ktlintRuleset(files("lib/ktlint-ruleset-0.2.jar")) diff --git a/gradle.properties b/gradle.properties index 67e28ad1c..139a07b09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.0 +pluginVersion = 0.9.1 # 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 f243b5a6a57a3a1fcde608b0a5481b9b2d996cac Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 15 Aug 2023 20:28:59 +0200 Subject: [PATCH 3/4] Changelog update --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a95fba0c1..b98fe0131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ ### Fixed ## [0.9.1] - 2023-08-15 - This release fixes a bug related to the new file icons from the previous release. ### Added @@ -202,8 +201,8 @@ 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.1-alpha.1...HEAD -[0.9.1-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.0...v0.9.1-alpha.1 +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1...HEAD +[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 [0.7.33]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.32...v0.7.33 [0.7.32]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.31...v0.7.32 From 95a631d0dd83950c38a733c7503305d7667424e7 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 15 Aug 2023 20:43:13 +0200 Subject: [PATCH 4/4] formatting --- src/nl/hannahsten/texifyidea/TexifyIcons.kt | 2 +- .../completion/pathcompletion/LatexPathProviderBase.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/TexifyIcons.kt b/src/nl/hannahsten/texifyidea/TexifyIcons.kt index b5c08c3db..c844e3fc0 100644 --- a/src/nl/hannahsten/texifyidea/TexifyIcons.kt +++ b/src/nl/hannahsten/texifyidea/TexifyIcons.kt @@ -228,7 +228,7 @@ object TexifyIcons { * @throws IllegalArgumentException * When `extension` is null. */ - fun getIconFromExtension(extension: String?, default: Icon?=null): Icon? { + fun getIconFromExtension(extension: String?, default: Icon? = null): Icon? { return if (extension == null) { default } diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt index dd32564be..e224636cd 100644 --- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt +++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt @@ -173,7 +173,7 @@ abstract class LatexPathProviderBase : CompletionProvider( if (validExtensions!!.contains(foundFile.extension).not()) return } - val icon = TexifyIcons.getIconFromExtension(foundFile.extension, default=FILE) + val icon = TexifyIcons.getIconFromExtension(foundFile.extension, default = FILE) resultSet?.addElement( LookupElementBuilder.create(baseDir + foundFile.name) .withPresentableText(foundFile.presentableName)