Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/components/terminal/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,22 @@ export default class TerminalComponent {
setupCopyPasteHandlers() {
// Add keyboard event listener to terminal element
this.terminal.attachCustomKeyEventHandler((event) => {
// xterm.js invokes this handler for both "keydown" and "keyup", so
// any side-effecting action must only run once, on keydown, or it
// fires twice per keypress (e.g. paste happening twice).
const isKeyDown = event.type === "keydown";

// Check for Ctrl+Shift+C (copy)
if (event.ctrlKey && event.shiftKey && event.key === "C") {
event.preventDefault();
this.copySelection();
if (isKeyDown) this.copySelection();
return false;
}

// Check for Ctrl+Shift+V (paste)
if (event.ctrlKey && event.shiftKey && event.key === "V") {
event.preventDefault();
this.pasteFromClipboard();
if (isKeyDown) this.pasteFromClipboard();
return false;
}

Expand All @@ -462,7 +467,7 @@ export default class TerminalComponent {
(event.key === "+" || event.key === "=")
) {
event.preventDefault();
this.increaseFontSize();
if (isKeyDown) this.increaseFontSize();
return false;
}

Expand All @@ -474,7 +479,7 @@ export default class TerminalComponent {
event.key === "-"
) {
event.preventDefault();
this.decreaseFontSize();
if (isKeyDown) this.decreaseFontSize();
return false;
}

Expand All @@ -494,8 +499,13 @@ export default class TerminalComponent {
binding.key === eventKey,
);

if (binding && executeCommand(binding.name)) {
return false;
if (binding) {
if (isKeyDown) {
this._lastAppKeybindingHandled = executeCommand(binding.name);
}
if (this._lastAppKeybindingHandled) {
return false;
}
}
}

Expand Down