diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorComponentImpl.java index 88d16b461454..fee9ae48faba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorComponentImpl.java @@ -1185,9 +1185,6 @@ public final class EditorComponentImpl extends JTextComponent implements Scrolla final Integer pos = event.getOffset(); if (ApplicationManager.getApplication().isDispatchThread()) { firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, pos); - // Fire caret changed event when the document changes because caretPositionChanged might not be called in some cases - // (e.g., when deleting text or adding/removing tab indentation, see CaretListener#caretPositionChanged). - firePropertyChange(ACCESSIBLE_CARET_PROPERTY, null, pos); if (SystemInfo.isMac) { // For MacOSX we also need to fire a JTextComponent event to anyone listening // to our Document, since *that* rather than the accessible property @@ -1197,7 +1194,6 @@ public final class EditorComponentImpl extends JTextComponent implements Scrolla } else { ApplicationManager.getApplication().invokeLater(() -> { firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, pos); - firePropertyChange(ACCESSIBLE_CARET_PROPERTY, null, pos); fireJTextComponentDocumentChange(event); }); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AccessibleCaretTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AccessibleCaretTest.kt index b3ed89d09594..9995fe62edc7 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AccessibleCaretTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AccessibleCaretTest.kt @@ -5,6 +5,15 @@ import com.intellij.openapi.fileTypes.PlainTextFileType import javax.accessibility.AccessibleContext class AccessibleCaretTest : AbstractEditorTest() { + fun `test accessible caret property change on left and right arrow press`() { + val accessibleCaret = initEditor(3) + + left() + assertEquals(2, accessibleCaret.position) + right() + assertEquals(3, accessibleCaret.position) + } + fun `test accessible caret property change on backspace`() { val accessibleCaret = initEditor(3) @@ -31,7 +40,7 @@ class AccessibleCaretTest : AbstractEditorTest() { initText("12345") editor.caretModel.moveToOffset(caretPosition.position) editor.contentComponent.accessibleContext.addPropertyChangeListener { evt -> - if (evt.propertyName == AccessibleContext.ACCESSIBLE_CARET_PROPERTY) { + if (evt.propertyName == AccessibleContext.ACCESSIBLE_CARET_PROPERTY || evt.propertyName == AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) { caretPosition.position = evt.newValue as Int } }