mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[diff] promote diff navigation actions when navigating in diff over all other actions
#IJPL-179930 Fixed GitOrigin-RevId: fc70769864e8347409df4eea792a98d7e61a6539
This commit is contained in:
committed by
intellij-monorepo-bot
parent
adae0152c2
commit
7cb63072b1
@@ -14,6 +14,8 @@
|
||||
order="before hide-hints"/>
|
||||
|
||||
<mergeableGutterIconRendererProvider implementation="com.intellij.diff.util.DiffGutterRendererMergeableRendererProvider" />
|
||||
|
||||
<actionPromoter implementation="com.intellij.diff.actions.impl.DiffNavigationActionPromoter"/>
|
||||
</extensions>
|
||||
|
||||
<applicationListeners>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.diff.actions.impl
|
||||
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.openapi.actionSystem.ActionPromoter
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
|
||||
/**
|
||||
* When iterating over diff, iteration actions take precedence over anything else
|
||||
*/
|
||||
internal class DiffNavigationActionPromoter : ActionPromoter {
|
||||
override fun suppress(actions: List<AnAction>, context: DataContext): List<AnAction> {
|
||||
if (context.getData(DiffDataKeys.PREV_NEXT_FILE_ITERABLE) != null && actions.any(::isFileNavigationAction)) {
|
||||
return actions.filterNot(::isFileNavigationAction)
|
||||
}
|
||||
|
||||
if (context.getData(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE) != null && actions.any(::isDifferenceNavigationAction)) {
|
||||
return actions.filterNot(::isDifferenceNavigationAction)
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isFileNavigationAction(action: AnAction) = action is DiffNextFileAction || action is DiffPreviousFileAction
|
||||
|
||||
private fun isDifferenceNavigationAction(action: AnAction) = action is DiffNextDifferenceAction || action is DiffPreviousDifferenceAction
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.diff.actions.impl
|
||||
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.diff.util.DiffUtil
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
@@ -12,14 +11,13 @@ internal open class DiffNextDifferenceAction : AnAction(), DumbAware {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
if (DiffUtil.isFromShortcut(e)) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE)
|
||||
if (iterable == null) {
|
||||
e.presentation.setEnabledAndVisible(false)
|
||||
return
|
||||
}
|
||||
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE)
|
||||
if (iterable != null && iterable.canGoNext()) {
|
||||
e.presentation.setEnabled(true)
|
||||
else if (iterable.canGoNext()) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.diff.actions.impl
|
||||
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.diff.util.DiffUtil
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
@@ -12,11 +11,6 @@ internal open class DiffNextFileAction : AnAction(), DumbAware {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
if (DiffUtil.isFromShortcut(e)) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
return
|
||||
}
|
||||
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_FILE_ITERABLE)
|
||||
if (iterable == null) {
|
||||
e.presentation.setEnabledAndVisible(false)
|
||||
|
||||
+5
-7
@@ -2,7 +2,6 @@
|
||||
package com.intellij.diff.actions.impl
|
||||
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.diff.util.DiffUtil
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
@@ -12,14 +11,13 @@ internal open class DiffPreviousDifferenceAction : AnAction(), DumbAware {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
if (DiffUtil.isFromShortcut(e)) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE)
|
||||
if (iterable == null) {
|
||||
e.presentation.setEnabledAndVisible(false)
|
||||
return
|
||||
}
|
||||
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE)
|
||||
if (iterable != null && iterable.canGoPrev()) {
|
||||
e.presentation.setEnabled(true)
|
||||
else if (iterable.canGoPrev()) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.diff.actions.impl
|
||||
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.diff.util.DiffUtil
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
@@ -12,11 +11,6 @@ internal class DiffPreviousFileAction : AnAction(), DumbAware {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
if (DiffUtil.isFromShortcut(e)) {
|
||||
e.presentation.setEnabledAndVisible(true)
|
||||
return
|
||||
}
|
||||
|
||||
val iterable = e.getData(DiffDataKeys.PREV_NEXT_FILE_ITERABLE)
|
||||
if (iterable == null) {
|
||||
e.presentation.setEnabledAndVisible(false)
|
||||
|
||||
Reference in New Issue
Block a user