void () { VirtualFile dir = getTempDir().createVirtualDir(); ModuleRootModificationUtil.addContentRoot(getModule(), dir); VirtualFile file = createChildData(dir, "my.txt"); setFileText(file, "xxx"); file.setCharset(US_ASCII); FileDocumentManager.getInstance().saveAllDocuments(); UIUtil.dispatchAllInvocationEvents(); assertNull(FileDocumentManager.getInstance().getCachedDocument(file)); assertEquals(US_ASCII, file.getCharset()); ((EncodingProjectManagerImpl)EncodingProjectManager.getInstance(getProject())).setMapping(Collections.singletonMap(dir, WINDOWS_1251)); assertEquals(WINDOWS_1251, file.getCharset()); }