From dd4fa95b79c898ff072266db26f6396db4a351d7 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 13 Jul 2016 12:19:48 +0300 Subject: [PATCH] IDEA-158439 Newline in FoldingBuilder.getPlaceholderText is displayed differently cross-platform --- .../impl/softwrap/mapping/SoftWrapApplianceManager.java | 5 +++-- .../com/intellij/openapi/editor/impl/view/EditorView.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) 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 1e98bf863dbe..f745f83d5ee8 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 @@ -344,8 +344,9 @@ public class SoftWrapApplianceManager implements Dumpable { String placeholder = foldRegion.getPlaceholderText(); int placeholderWidthInPixels = 0; for (int i = 0; i < placeholder.length(); i++) { - placeholderWidthInPixels += SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor) - .charWidth(placeholder.charAt(i), myContext.fontType); + char c = placeholder.charAt(i); + if (myEditor.myUseNewRendering && c == '\n') c = ' '; // we display \n as space (see com.intellij.openapi.editor.impl.view.EditorView.getFoldRegionLayout) + placeholderWidthInPixels += SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor).charWidth(c, myContext.fontType); } if (myContext.delayedSoftWrap == null) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java index 88a620ca5ac9..eb1740cdfed8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java @@ -30,6 +30,7 @@ import com.intellij.openapi.editor.impl.TextDrawingCallback; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -472,7 +473,7 @@ public class EditorView implements TextDrawingCallback, Disposable, Dumpable { LineLayout layout = foldRegion.getUserData(FOLD_REGION_TEXT_LAYOUT); if (layout == null) { TextAttributes placeholderAttributes = myEditor.getFoldingModel().getPlaceholderAttributes(); - layout = LineLayout.create(this, foldRegion.getPlaceholderText(), + layout = LineLayout.create(this, StringUtil.replace(foldRegion.getPlaceholderText(), "\n", " "), placeholderAttributes == null ? Font.PLAIN : placeholderAttributes.getFontType()); foldRegion.putUserData(FOLD_REGION_TEXT_LAYOUT, layout); }