void () { char utf8character = '\u00e9'; EditorTestUtil.saveEncodingsIn(myProject, null, WINDOWS_1251, () -> PlatformTestUtil.withEncoding(WINDOWS_1251.name(), () -> { assertEquals(CharsetToolkit.UTF8, EncodingManager.getInstance().getDefaultCharsetName()); VirtualFile virtualFile = createFileInCommand("f.java"); VirtualFile virtualFile2 = createFileInCommand("g.java"); assertEquals(WINDOWS_1251, virtualFile.getCharset()); assertEquals(WINDOWS_1251, virtualFile2.getCharset()); EncodingProjectManager.getInstance(myProject).setEncoding(virtualFile, StandardCharsets.UTF_8); UIUtil.dispatchAllInvocationEvents(); assertEquals(StandardCharsets.UTF_8, virtualFile.getCharset()); assertEquals(WINDOWS_1251, virtualFile2.getCharset()); Editor editor = getEditor(virtualFile); Editor editor2 = getEditor(virtualFile2); String string = StringUtil.repeat(String.valueOf(utf8character), 1024); typeInText(editor, string); typeInText(editor2, string); WriteCommandAction.runWriteCommandAction(getProject(), () -> editor.getDocument().deleteString(0, editor.getDocument().getTextLength())); undo(editor); UIUtil.dispatchAllInvocationEvents(); assertEquals(utf8character, (int)editor.getDocument().getText().charAt(0)); WriteCommandAction.runWriteCommandAction(getProject(), () -> editor2.getDocument().deleteString(0, editor2.getDocument().getTextLength())); undo(editor2); UIUtil.dispatchAllInvocationEvents(); assertEquals(utf8character, (int)editor2.getDocument().getText().charAt(0)); })); }