From 2117bf55c2ce8ddd7f0f19000ea953dda0c95617 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 17 Apr 2015 20:51:59 +0300 Subject: [PATCH] diff: do not try to detect charset This attempts will not help in most cases, but can make things complicated --- platform/diff-impl/diff-impl.iml | 1 - .../contents/FileAwareDocumentContent.java | 32 ------------------- 2 files changed, 33 deletions(-) diff --git a/platform/diff-impl/diff-impl.iml b/platform/diff-impl/diff-impl.iml index d0d53d801304..33ecce71f528 100644 --- a/platform/diff-impl/diff-impl.iml +++ b/platform/diff-impl/diff-impl.iml @@ -14,6 +14,5 @@ - \ No newline at end of file diff --git a/platform/diff-impl/src/com/intellij/diff/contents/FileAwareDocumentContent.java b/platform/diff-impl/src/com/intellij/diff/contents/FileAwareDocumentContent.java index 634b387142f2..eae71d723669 100644 --- a/platform/diff-impl/src/com/intellij/diff/contents/FileAwareDocumentContent.java +++ b/platform/diff-impl/src/com/intellij/diff/contents/FileAwareDocumentContent.java @@ -1,7 +1,5 @@ package com.intellij.diff.contents; -import com.intellij.ide.highlighter.ProjectFileType; -import com.intellij.lang.properties.charset.Native2AsciiCharset; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.fileEditor.OpenFileDescriptor; @@ -13,7 +11,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.util.LineSeparator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -102,8 +99,6 @@ public class FileAwareDocumentContent extends DocumentContentImpl { @NotNull private Builder create(@NotNull byte[] content) { assert myCharset != null; - - myCharset = guessCharset(content, myCharset, myFileType, myHighlightFile); return create(CharsetToolkit.decodeString(content, myCharset)); } @@ -113,31 +108,4 @@ public class FileAwareDocumentContent extends DocumentContentImpl { return new FileAwareDocumentContent(myProject, myDocument, myFileType, myHighlightFile, mySeparator, myCharset); } } - - @NotNull - private static Charset guessCharset(@NotNull byte[] content, - @NotNull Charset currentCharset, - @Nullable FileType fileType, - @Nullable VirtualFile highlightFile) { - - CharsetToolkit toolkit = new CharsetToolkit(content, currentCharset); - toolkit.setEnforce8Bit(true); - - Charset charset = toolkit.guessFromBOM(); - - if (charset == null) { - CharsetToolkit.GuessedEncoding guessed = toolkit.guessFromContent(content.length); - if (guessed == CharsetToolkit.GuessedEncoding.VALID_UTF8) charset = CharsetToolkit.UTF8_CHARSET; - } - - if (charset == null) { - charset = currentCharset; - } - - if (ProjectFileType.INSTANCE.equals(fileType) && EncodingManager.getInstance().isNative2AsciiForPropertiesFiles()) { - charset = Native2AsciiCharset.wrap(charset); - } - - return charset; - } }