[terminal] IDEA-344689 Remove Ctrl+C shortcut from copying block on Windows and Linux

It is expected that Ctrl+C will always interrupt the current command, instead of doing something else.
Also, return the focus to the prompt when command is interrupted if any block was selected. It is done by clearing the selection, so when prompt is shown, it will be the preferred focusable component.

GitOrigin-RevId: c364a10e678d8112ccf14e176fae811646ab6a4b
This commit is contained in:
Konstantin Hudyakov
2024-02-16 14:10:03 +02:00
committed by intellij-monorepo-bot
parent cb2462683e
commit c4eac01f74
3 changed files with 8 additions and 2 deletions

View File

@@ -189,6 +189,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{"meta 3", "ActivateFindToolWindow", "FileChooser.GotoModule"},
{"meta A", "$SelectAll", "Terminal.SelectAll"},
{"meta BACK_SPACE", "EditorDeleteLine", "$Delete"},
{"meta C", "$Copy", "JupyterNotebookCopyCellCommandModeAction", "Terminal.CopyBlock", "Terminal.CopySelectedText"},
{"meta DOWN", "EditSource", "Terminal.SelectPrompt"},
{"meta I", "DatabaseView.PropertiesAction", "org.intellij.plugins.markdown.ui.actions.styling.ToggleItalicAction"},
{"meta K", "CheckinProject", "Terminal.ClearBuffer"},
@@ -224,6 +225,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{"meta 2", "ActivateBookmarksToolWindow", "FileChooser.GotoProject", "DuplicatesForm.SendToRight"},
{"meta 3", "ActivateFindToolWindow", "FileChooser.GotoModule"},
{"meta A", "$SelectAll", "Terminal.SelectAll"},
{"meta C", "$Copy", "JupyterNotebookCopyCellCommandModeAction", "Terminal.CopyBlock", "Terminal.CopySelectedText"},
{"meta K", "CheckinProject", "Terminal.ClearBuffer"},
{"meta R", "WebInspector.Browser.Refresh", "Replace", "org.jetbrains.plugins.ruby.rails.console.ReloadSources"},
{"meta SLASH", "CommentByLineComment", "FileChooser.GoToRoot", "Graph.ActualSize"},

View File

@@ -118,8 +118,10 @@
<action id="Terminal.ExpandBlockSelectionBelow" class="org.jetbrains.plugins.terminal.exp.TerminalExpandBlockSelectionBelowAction"
use-shortcut-of="EditorDownWithSelection">
</action>
<action id="Terminal.CopyBlock" class="org.jetbrains.plugins.terminal.action.TerminalCopyBlockAction"
use-shortcut-of="$Copy" icon="AllIcons.Actions.Copy"/>
<action id="Terminal.CopyBlock" class="org.jetbrains.plugins.terminal.action.TerminalCopyBlockAction" icon="AllIcons.Actions.Copy">
<keyboard-shortcut first-keystroke="meta C" keymap="Mac OS X"/>
<keyboard-shortcut first-keystroke="meta C" keymap="Mac OS X 10.5+"/>
</action>
<action id="Terminal.CommandCompletion" class="org.jetbrains.plugins.terminal.action.TerminalCommandCompletionAction">
<keyboard-shortcut first-keystroke="TAB" keymap="$default"/>

View File

@@ -10,6 +10,7 @@ import org.jetbrains.plugins.terminal.TerminalBundle
import org.jetbrains.plugins.terminal.exp.TerminalDataContextUtils.editor
import org.jetbrains.plugins.terminal.exp.TerminalDataContextUtils.isAlternateBufferEditor
import org.jetbrains.plugins.terminal.exp.TerminalDataContextUtils.isOutputEditor
import org.jetbrains.plugins.terminal.exp.TerminalDataContextUtils.selectionController
import org.jetbrains.plugins.terminal.exp.TerminalDataContextUtils.terminalSession
import java.awt.event.InputEvent
import java.awt.event.KeyEvent
@@ -24,6 +25,7 @@ class TerminalInterruptCommandAction : DumbAwareAction(TerminalBundle.message("a
override fun actionPerformed(e: AnActionEvent) {
val session = e.terminalSession?.takeIf { it.model.isCommandRunning } ?: return
e.selectionController?.clearSelection()
session.terminalStarterFuture.thenAccept {
// Send Ctrl+C
it?.sendString("\u0003", false)