mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-346408 diff: hide promo badge if Combined diff was enabled in FindAction
GitOrigin-RevId: 46bc4032f2aa86b968213934e60f23a951d5ddaa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
740a4c4f34
commit
0bccf48a3d
+5
@@ -3,6 +3,7 @@ package com.intellij.collaboration.ui.codereview
|
||||
|
||||
import com.intellij.collaboration.file.codereview.CodeReviewDiffVirtualFile
|
||||
import com.intellij.diff.editor.DiffEditorViewerFileEditor
|
||||
import com.intellij.diff.tools.combined.CombinedDiffRegistry
|
||||
import com.intellij.diff.util.CombinedDiffToggle
|
||||
import com.intellij.idea.AppMode
|
||||
import com.intellij.openapi.options.advanced.AdvancedSettings
|
||||
@@ -16,6 +17,10 @@ object CodeReviewAdvancedSettings {
|
||||
|
||||
private fun setCombinedDiffEnabled(enabled: Boolean) {
|
||||
AdvancedSettings.setBoolean(COMBINED_DIFF_SETTING_ID, enabled)
|
||||
|
||||
if (enabled) {
|
||||
CombinedDiffRegistry.resetBadge()
|
||||
}
|
||||
}
|
||||
|
||||
val CodeReviewCombinedDiffToggle: CombinedDiffToggle = object : CombinedDiffToggle {
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.intellij.openapi.actionSystem.impl.PresentationFactory
|
||||
import com.intellij.openapi.diff.DiffBundle
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.ui.popup.JBPopup
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil
|
||||
@@ -46,18 +45,13 @@ class SetEditorSettingsAction(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val popup = createMainPopup(editorSettingsActionGroup, e.dataContext)
|
||||
|
||||
val popup = MyPopup(editorSettingsActionGroup, e.dataContext)
|
||||
PopupUtil.showForActionButtonEvent(popup, e)
|
||||
val diffModeToggle = getDiffModeToggle(e) ?: return
|
||||
|
||||
popup.addListener(object : JBPopupListener {
|
||||
override fun onClosed(event: LightweightWindowEvent) {
|
||||
if (!diffModeToggle.isCombinedDiffEnabled) {
|
||||
CombinedDiffRegistry.resetBadge()
|
||||
}
|
||||
CombinedDiffRegistry.resetBadge()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -75,16 +69,12 @@ class SetEditorSettingsAction(
|
||||
|
||||
private val presentationFactory = PresentationFactory()
|
||||
|
||||
private fun createMainPopup(actionGroup: ActionGroup, dataContext: DataContext): JBPopup {
|
||||
return MyPopup(actionGroup, dataContext)
|
||||
}
|
||||
|
||||
private fun getDiffModeToggle(e: AnActionEvent): CombinedDiffToggle? {
|
||||
val context = e.getData(DiffDataKeys.DIFF_CONTEXT) ?: return null
|
||||
return context.getUserData(DiffUserDataKeysEx.COMBINED_DIFF_TOGGLE)
|
||||
}
|
||||
|
||||
inner class MyPopup(
|
||||
private inner class MyPopup(
|
||||
group: ActionGroup,
|
||||
context: DataContext
|
||||
) : PopupFactoryImpl.ActionGroupPopup(null, group, context, false, false, true, true, null, -1, null, null, presentationFactory, false) {
|
||||
|
||||
@@ -19,6 +19,10 @@ object CombinedDiffRegistry {
|
||||
|
||||
fun setCombinedDiffEnabled(enabled: Boolean) {
|
||||
AdvancedSettings.setBoolean(COMBINED_DIFF_SETTING_ID, enabled)
|
||||
|
||||
if (enabled) {
|
||||
resetBadge()
|
||||
}
|
||||
}
|
||||
|
||||
fun getPreloadedBlocksCount(): Int = Registry.intValue("combined.diff.visible.viewport.delta", 3, 1, 100)
|
||||
|
||||
Reference in New Issue
Block a user