mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: do not try to detect charset
This attempts will not help in most cases, but can make things complicated
This commit is contained in:
@@ -14,6 +14,5 @@
|
||||
<orderEntry type="module" module-name="platform-api" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="vcs-api-core" />
|
||||
<orderEntry type="module" module-name="boot" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user