From 8dfb665829618534b8a4d8ff6379d03d082697bf Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Wed, 11 Aug 2010 18:50:45 +0400 Subject: [PATCH] IDEA-53596 Soft wrap for editors Symbol width caching algorihtm is corrected --- .../DefaultEditorTextRepresentationHelper.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DefaultEditorTextRepresentationHelper.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DefaultEditorTextRepresentationHelper.java index af2e6edf8e4e..182ca872f136 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DefaultEditorTextRepresentationHelper.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DefaultEditorTextRepresentationHelper.java @@ -76,6 +76,7 @@ public class DefaultEditorTextRepresentationHelper implements EditorTextRepresen for (int i = startToUse; i < end; i++) { char c = text.charAt(i); if (c != '\t') { + mySharedKey.c = c; result += charWidth(c); continue; } @@ -102,23 +103,25 @@ public class DefaultEditorTextRepresentationHelper implements EditorTextRepresen } private static class Key { - public String fontName; - private int fontSize; - private int fontType; + public String fontName; + private int fontSize; + private int fontType; + private char c; private Key() { - this(null, 0, 0); + this(null, 0, 0, ' '); } - Key(String fontName, int fontSize, int fontType) { + Key(String fontName, int fontSize, int fontType, char c) { this.fontName = fontName; this.fontSize = fontSize; this.fontType = fontType; + this.c = c; } @Override protected Key clone() { - return new Key(fontName, fontSize, fontType); + return new Key(fontName, fontSize, fontType, c); } @Override @@ -126,6 +129,7 @@ public class DefaultEditorTextRepresentationHelper implements EditorTextRepresen int result = fontName != null ? fontName.hashCode() : 0; result = 31 * result + fontSize; result = 31 * result + fontType; + result = 31 * result + c; return result; } @@ -138,6 +142,7 @@ public class DefaultEditorTextRepresentationHelper implements EditorTextRepresen if (fontSize != key.fontSize) return false; if (fontType != key.fontType) return false; + if (c != key.c) return false; if (fontName != null ? !fontName.equals(key.fontName) : key.fontName != null) return false; return true;