Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AceJump doesn't work in a commit message editor, doing a jump in the code editor instead #415

Open
h0tk3y opened this issue Oct 27, 2022 · 2 comments
Labels

Comments

@h0tk3y
Copy link

h0tk3y commented Oct 27, 2022

Describe the bug
If I try to use AceJump in the IntelliJ IDEA commit message editor, it won't display the jump labels in the commit message editor and will instead work as if the focus was in the code editor. After a jump is completed, the code editor's cursor, which is invisible due to being unfocused, will move, but the code editor will still be out of focus.

To Reproduce
Steps to reproduce the behavior:

  1. Open a project under Git version control in IntelliJ IDEA.

  2. Make some changes to the tracked files.

  3. Open the "Commit" tool window and focus the commit message editor.

  4. Type some commit message.

  5. Run any of the jump actions.

  6. See the labels displayed in the code editor rather than the commit message editor.
    If there is no code editor (e.g. you closed all the tabs), then AceJump throws an exception. Here's the stack trace:

    Stack trace
    java.util.NoSuchElementException: Collection is empty.
        at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:201)
        at org.acejump.view.TextHighlighter.showSearchNotification(TextHighlighter.kt:96)
        at org.acejump.view.TextHighlighter.render(TextHighlighter.kt:78)
        at org.acejump.session.Session.updateSearch(Session.kt:117)
        at org.acejump.session.Session.access$updateSearch(Session.kt:34)
        at org.acejump.session.Session$1.execute(Session.kt:96)
        at org.acejump.input.EditorKeyListener.execute(EditorKeyListener.kt:19)
        at com.intellij.openapi.editor.actionSystem.TypedAction.lambda$actionPerformed$2(TypedAction.java:200)
        at com.intellij.reporting.FreezeLoggerImpl.runUnderPerformanceMonitor(FreezeLoggerImpl.java:28)
        at com.intellij.openapi.editor.actionSystem.TypedAction.lambda$actionPerformed$3(TypedAction.java:199)
        at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:167)
        at com.intellij.openapi.editor.actionSystem.TypedAction.actionPerformed(TypedAction.java:199)
        at com.intellij.openapi.editor.impl.EditorImpl.processKeyTypedNormally(EditorImpl.java:1333)
        at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:1315)
        at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:3492)
        at com.intellij.openapi.editor.impl.EditorImpl$7.keyTyped(EditorImpl.java:1148)
        at java.desktop/java.awt.AWTEventMulticaster.keyTyped(AWTEventMulticaster.java:247)
        at java.desktop/java.awt.Component.processKeyEvent(Component.java:6603)
        at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2899)
        at java.desktop/java.awt.Component.processEvent(Component.java:6425)
        at java.desktop/java.awt.Container.processEvent(Container.java:2266)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5022)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
        at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1953)
        at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:886)
        at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1166)
        at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1023)
        at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:849)
        at com.intellij.ide.IdeKeyboardFocusManager.lambda$dispatchEvent$0(IdeKeyboardFocusManager.java:32)
        at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
        at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
        at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.java:32)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4903)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2802)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:754)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:752)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:751)
        at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909)
        at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:818)
        at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:750)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437)
        at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:774)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436)
        at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
        at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434)
        at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
        at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
    
    
  7. If you complete the jump, the cursor changes its position in the code editor, though the code editor is still out of focus.

Expected behavior
AceJump actions work in the commit message editor, allowing one to jump around in the commit message.
Alternatively, if the design of AceJump only concerns the code editor, it should either focus the code editor or not trigger the action at all if the focus is in the commit message editor.

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS
  • IntelliJ IDEA 2022.x
  • AceJump version 3.8.8

Additional context
There might be other editors in IntelliJ that would expose similar issues with AceJump.
One example is the Diff Viewer mentioned in #414.

@h0tk3y h0tk3y added the bug label Oct 27, 2022
@breandan
Copy link
Collaborator

breandan commented Apr 4, 2023

Thanks for reporting. Can you suggest a reliable way to locate the current editor? As suggested by the developer documentation, we are currently using AnActionEvent.getData(CommonDataKeys.EDITOR) to retrieve the editor, but it does not return the correct editor when the cursor is placed inside the commit message editor, or diff viewer editor. I have tried several methods, including,

  • AnActionEvent.getData(CommonDataKeys.HOST_EDITOR)
  • FileEditorManager.getInstance(project).selectedTextEditor
  • (IdeFocusManager.getInstance(it)?.focusOwner as? EditorComponentImpl)?.editor

but none of them seem to retrieve the correct editor instance. Is there another API endpoint to access the relevant editor? cc: @halirutan @karollewandowski

@karollewandowski
Copy link

karollewandowski commented Apr 4, 2023

Hi, please try with getData(VcsDataKeys.COMMIT_MESSAGE_DOCUMENT) and com.intellij.openapi.vcs.ui.CommitMessage#getEditor(Document).

If it doesn't solve the issue, please ask on the forum so that other developers can find this knowledge more easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants