IDEA-158439 Newline in FoldingBuilder.getPlaceholderText is displayed differently cross-platform

This commit is contained in:
Dmitry Batrak
2016-07-13 12:21:31 +03:00
parent 60ad7ba58c
commit dd4fa95b79
2 changed files with 5 additions and 3 deletions
@@ -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) {
@@ -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);
}