IDEA-53596 Soft wrap for editors

Symbol width caching algorihtm is corrected
This commit is contained in:
Denis Zhdanov
2010-08-11 18:51:43 +04:00
parent 4ae699956b
commit 8dfb665829
@@ -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;