mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IJPL-172124 Allow to listen for command history popup events
IJ-CR-148020 (cherry picked from commit a8ae3afc201097a0644567d414cd4350d9c9373c) GitOrigin-RevId: a598174be294a320242914cf1d7a5a931bfb3b92
This commit is contained in:
committed by
intellij-monorepo-bot
parent
41b2b42995
commit
d598a63db6
@@ -0,0 +1,18 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.terminal.block.history
|
||||
|
||||
import com.intellij.util.messages.Topic
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.plugins.terminal.block.prompt.TerminalPromptModel
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface CommandHistoryListener {
|
||||
fun commandHistoryShown(promptModel: TerminalPromptModel) {}
|
||||
|
||||
fun commandHistoryAborted(promptModel: TerminalPromptModel) {}
|
||||
|
||||
companion object {
|
||||
@Topic.ProjectLevel
|
||||
val TOPIC: Topic<CommandHistoryListener> = Topic(CommandHistoryListener::class.java, Topic.BroadcastDirection.NONE)
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.UserDataHolder
|
||||
import org.jetbrains.plugins.terminal.block.ui.getDisposed
|
||||
import org.jetbrains.plugins.terminal.block.ui.invokeLater
|
||||
import org.jetbrains.plugins.terminal.block.prompt.TerminalPromptController
|
||||
import org.jetbrains.plugins.terminal.block.prompt.TerminalPromptModel
|
||||
import org.jetbrains.plugins.terminal.block.ui.getDisposed
|
||||
import org.jetbrains.plugins.terminal.block.ui.invokeLater
|
||||
|
||||
internal class CommandHistoryPresenter(
|
||||
private val project: Project,
|
||||
@@ -68,6 +68,7 @@ internal class CommandHistoryPresenter(
|
||||
|
||||
if (lookup.showLookup()) {
|
||||
lookup.ensureSelectionVisible(false)
|
||||
project.messageBus.syncPublisher(CommandHistoryListener.TOPIC).commandHistoryShown(promptModel)
|
||||
}
|
||||
else thisLogger().error("Failed to show command history")
|
||||
}
|
||||
@@ -83,6 +84,8 @@ internal class CommandHistoryPresenter(
|
||||
invokeLater(editor.getDisposed()) {
|
||||
promptModel.commandText = commandToRestore
|
||||
editor.caretModel.moveToOffset(editor.document.textLength)
|
||||
|
||||
project.messageBus.syncPublisher(CommandHistoryListener.TOPIC).commandHistoryAborted(promptModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user