diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java index 15684417acfc..2d989eea40e6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -568,6 +568,10 @@ public final class EditorUtil { return width > 0 ? width : 1; } + public static int getPlainSpaceWidth(@NotNull Editor editor) { + return getSpaceWidth(Font.PLAIN, editor); + } + public static int getTabSize(@NotNull Editor editor) { return editor.getSettings().getTabSize(editor.getProject()); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 92f98cced438..d922a1a9115d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -7045,7 +7045,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return column; } - boolean isInDistractionFreeMode() { + public boolean isInDistractionFreeMode() { return EditorUtil.isRealFileEditor(this) && (Registry.is("editor.distraction.free.mode") || isInPresentationMode()); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java index 49d7b9b1db0d..02ef771f9ece 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1107,14 +1107,18 @@ public class SoftWrapApplianceManager implements Dumpable { private static class DefaultVisibleAreaWidthProvider implements VisibleAreaWidthProvider { - private final Editor myEditor; + private final EditorImpl myEditor; - DefaultVisibleAreaWidthProvider(Editor editor) { + DefaultVisibleAreaWidthProvider(EditorImpl editor) { myEditor = editor; } @Override public int getVisibleAreaWidth() { + if (myEditor.isInDistractionFreeMode()) { + int rightMargin = myEditor.getSettings().getRightMargin(myEditor.getProject()); + if (rightMargin > 0) return rightMargin * EditorUtil.getPlainSpaceWidth(myEditor); + } return myEditor.getScrollingModel().getVisibleArea().width; } }