From a1488967bef8d6dedb7ee1e49de099dc02307f4f Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 4 Dec 2019 14:35:52 +0300 Subject: [PATCH] IDEA-225722 Quick doc popup font is either too small or too big add migration from old setting GitOrigin-RevId: edcf12d2ac230267c554a54178d8d584900b34b5 --- .../documentation/DocumentationComponent.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index 53548f575e38..4020c67fe39c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -127,7 +127,8 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr private SmartPsiElementPointer myElement; private long myModificationCount; - private static final String QUICK_DOC_FONT_SIZE_PROPERTY = "quick.doc.font.size"; + private static final String QUICK_DOC_FONT_SIZE_OLD_PROPERTY = "quick.doc.font.size"; + private static final String QUICK_DOC_FONT_SIZE_PROPERTY = "quick.doc.font.size.v2"; private final Stack myBackStack = new Stack<>(); private final Stack myForwardStack = new Stack<>(); @@ -656,16 +657,31 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr @NotNull public static FontSize getQuickDocFontSize() { - String strValue = PropertiesComponent.getInstance().getValue(QUICK_DOC_FONT_SIZE_PROPERTY); + FontSize fontSize = readFontSizeFromSettings(QUICK_DOC_FONT_SIZE_PROPERTY); + if (fontSize != null) return fontSize; + FontSize oldFontSize = readFontSizeFromSettings(QUICK_DOC_FONT_SIZE_OLD_PROPERTY); + if (oldFontSize != null) { + // migrate old-scale setting + PropertiesComponent.getInstance().unsetValue(QUICK_DOC_FONT_SIZE_OLD_PROPERTY); + FontSize newFontSize = oldFontSize == FontSize.X_LARGE ? FontSize.XX_LARGE + : oldFontSize == FontSize.LARGE ? FontSize.X_LARGE + : oldFontSize; + setQuickDocFontSize(newFontSize); + return newFontSize; + } + return FontSize.SMALL; + } + + @Nullable + private static FontSize readFontSizeFromSettings(@NotNull String propertyName) { + String strValue = PropertiesComponent.getInstance().getValue(propertyName); if (strValue != null) { try { return FontSize.valueOf(strValue); } - catch (IllegalArgumentException iae) { - // ignore, fall back to default font. - } + catch (IllegalArgumentException ignored) {} } - return FontSize.SMALL; + return null; } public static void setQuickDocFontSize(@NotNull FontSize fontSize) {