IDEA-152063 IntelliJ fails to use encoding from project settings for files containing breakpoints when project is opened: do not send event on encoding reset

This commit is contained in:
Anton Makeev
2016-06-21 11:53:34 +02:00
parent ee4f7c8a30
commit 98de86e2b5
2 changed files with 8 additions and 2 deletions
@@ -523,6 +523,10 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
}
public void setCharset(final Charset charset, @Nullable Runnable whenChanged) {
setCharset(charset, whenChanged, false);
}
public void setCharset(final Charset charset, @Nullable Runnable whenChanged, boolean suppressEvents) {
final Charset old = getStoredCharset();
storeCharset(charset);
if (Comparing.equal(charset, old)) return;
@@ -535,7 +539,9 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
if (old != null) { //do not send on detect
if (whenChanged != null) whenChanged.run();
VirtualFileManager.getInstance().notifyPropertyChanged(this, PROP_ENCODING, old, charset);
if (!suppressEvents) {
VirtualFileManager.getInstance().notifyPropertyChanged(this, PROP_ENCODING, old, charset);
}
}
}
@@ -638,7 +638,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
documentEx.setReadOnly(false);
LoadTextUtil.setCharsetWasDetectedFromBytes(file, null);
file.setBOM(null); // reset BOM in case we had one and the external change stripped it away
file.setCharset(null);
file.setCharset(null, null, true);
if (!isBinaryWithoutDecompiler(file)) {
documentEx.replaceText(LoadTextUtil.loadText(file), file.getModificationStamp());
documentEx.setReadOnly(!wasWritable);