fix: copy hotkey conflicts with ctrlc

(cherry picked from commit b499667cbb)
This commit is contained in:
Srar
2025-12-10 14:54:49 +08:00
committed by hstyi
parent c727925791
commit bfc63a3983
2 changed files with 11 additions and 3 deletions

View File

@@ -20,6 +20,10 @@ class TerminalCopyAction : AnAction() {
override fun actionPerformed(evt: AnActionEvent) {
val terminalPanel = evt.getData(DataProviders.TerminalPanel) ?: return
val selectionModel = terminalPanel.terminal.getSelectionModel()
if (!selectionModel.hasSelection()) {
return
}
val text = terminalPanel.copy()
val systemClipboard = terminalPanel.toolkit.systemClipboard

View File

@@ -1,5 +1,6 @@
package app.termora.terminal.panel
import app.termora.actions.TerminalCopyAction
import app.termora.keymap.KeyShortcut
import app.termora.keymap.KeymapManager
import app.termora.plugin.internal.AltKeyModifier
@@ -71,6 +72,7 @@ class TerminalPanelKeyAdapter(
}
val keyStroke = KeyStroke.getKeyStrokeForEvent(e)
val keymapActions = activeKeymap.getActionIds(KeyShortcut(keyStroke))
for (action in terminalPanel.getTerminalActions()) {
if (action.test(keyStroke, e)) {
action.actionPerformed(e)
@@ -104,7 +106,9 @@ class TerminalPanelKeyAdapter(
}
// 如果命中了全局快捷键,那么不处理
if (keyStroke.modifiers != 0 && activeKeymap.getActionIds(KeyShortcut(keyStroke)).isNotEmpty()) {
val copyShortcutWithoutSelection =
keymapActions.contains(TerminalCopyAction.COPY) && terminal.getSelectionModel().hasSelection().not()
if (keyStroke.modifiers != 0 && keymapActions.isNotEmpty() && !copyShortcutWithoutSelection) {
return
}