From 8da92fb2714773562218d0a72159a3d1d3f35db2 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Mon, 24 Jun 2024 20:00:29 +0200 Subject: [PATCH] Handling invalid editor states from preview releases (#1636) --- CHANGELOG.adoc | 4 ++++ .../java/org/asciidoc/intellij/ui/SplitFileEditor.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 336473966..371c258c3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -7,6 +7,10 @@ This document provides a high-level view of the changes introduced by release. [[releasenotes]] == Release notes +=== 0.42.2 + +- Handling invalid editor states from preview releases (#1636) + === 0.42.1 - Reworking the changes for EAP, restoring preview and menu bar functionality (#1636) diff --git a/src/main/java/org/asciidoc/intellij/ui/SplitFileEditor.java b/src/main/java/org/asciidoc/intellij/ui/SplitFileEditor.java index 6d731ca0e..c3e81417d 100644 --- a/src/main/java/org/asciidoc/intellij/ui/SplitFileEditor.java +++ b/src/main/java/org/asciidoc/intellij/ui/SplitFileEditor.java @@ -22,6 +22,7 @@ import org.asciidoc.intellij.toolbar.AsciiDocToolbarPanel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jruby.util.ResourceException; import javax.swing.*; import java.awt.*; @@ -202,7 +203,12 @@ public void setState(@NotNull FileEditorState state) { mySecondEditor.setState(compositeState.getSecondState()); } if (compositeState.getSplitLayout() != null) { - mySplitEditorLayout = SplitEditorLayout.valueOf(compositeState.getSplitLayout()); + try { + mySplitEditorLayout = SplitEditorLayout.valueOf(compositeState.getSplitLayout()); + } catch (IllegalArgumentException ignore) { + // found an obsolete or old value, using the default value + mySplitEditorLayout = AsciiDocApplicationSettings.getInstance().getAsciiDocPreviewSettings().getSplitEditorLayout(); + } invalidateLayout(); } }