From f06bc994b70f83d33b24ad65df3666a645be5ef1 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 4 Mar 2019 17:21:14 +0300 Subject: [PATCH] editor: do not ignore initial state of "Hide tabs if there is not space" flag We should update layout after changing the "mySupportsCompression" flag, just like we update it on "hideTabsIfNeed" settings change. JBEditorTabs sets `mySupportsCompression` flag in constructor, but it is used in super constructor via `createSingleRowLayout` method. Thus, initial state of "hideTabsIfNeed" flag was ignored as "unsupported". --- .../com/intellij/ui/tabs/impl/JBTabsImpl.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 967552f537ed..f1c4d085f72d 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -320,22 +320,26 @@ public class JBTabsImpl extends JComponent } boolean oldHideTabsIfNeed = mySingleRowLayout instanceof ScrollableSingleRowLayout; boolean newHideTabsIfNeed = UISettings.getInstance().getHideTabsIfNeed(); - boolean wasSingleRow = isSingleRow(); if (oldHideTabsIfNeed != newHideTabsIfNeed) { - if (mySingleRowLayout != null) { - remove(mySingleRowLayout.myLeftGhost); - remove(mySingleRowLayout.myRightGhost); - } - mySingleRowLayout = createSingleRowLayout(); - if (wasSingleRow) { - myLayout = mySingleRowLayout; - } - add(mySingleRowLayout.myLeftGhost); - add(mySingleRowLayout.myRightGhost); - relayout(true, true); + updateRowLayout(); } } + private void updateRowLayout() { + boolean wasSingleRow = isSingleRow(); + if (mySingleRowLayout != null) { + remove(mySingleRowLayout.myLeftGhost); + remove(mySingleRowLayout.myRightGhost); + } + mySingleRowLayout = createSingleRowLayout(); + if (wasSingleRow) { + myLayout = mySingleRowLayout; + } + add(mySingleRowLayout.myLeftGhost); + add(mySingleRowLayout.myRightGhost); + relayout(true, true); + } + protected SingleRowLayout createSingleRowLayout() { return new SingleRowLayout(this); } @@ -3292,6 +3296,7 @@ public class JBTabsImpl extends JComponent @Override public JBTabsPresentation setSupportsCompression(boolean supportsCompression) { mySupportsCompression = supportsCompression; + updateRowLayout(); return this; }