Skip to content

Commit

Permalink
🐛 Fix copy/paste shortcuts on Windows/Linux 🎉 (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuss committed Jan 18, 2017
1 parent d54fa38 commit b4943a0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/hterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,29 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
e.preventDefault();
}

// hterm shouldn't consume a hyper accelerator
if (e.altKey || e.metaKey || isAccelerator(e)) {
// hterm shouldn't consume a hyper accelerator
// // Was the hyperCaret removed for selectAll
if (e.key === 'v' && !this.terminal.cursorNode_.contains(this.hyperCaret)) {
// If the `hyperCaret` was removed on `selectAll`, we need to insert it back
if (e.key === 'v' && this.terminal.hyperCaret.parentNode !== this.terminal.cursorNode_) {
this.terminal.focusHyperCaret();
}
return;
}

// Test for valid keys in order to accept clear status
if (e.code !== 'Control' && e.key !== 'Shift' && e.code !== 'CapsLock' && e.key !== 'Dead') {
const clearBlacklist = [
'control',
'shift',
'capslock',
'dead'
];
if (!clearBlacklist.includes(e.code.toLowerCase()) &&
!clearBlacklist.includes(e.key.toLowerCase())) {
selection.clear(this.terminal);
}

// Was the hyperCaret removed for selectAll
if (!this.terminal.cursorNode_.contains(this.hyperCaret)) {
// If the `hyperCaret` was removed on `selectAll`, we need to insert it back
if (this.terminal.hyperCaret.parentNode !== this.terminal.cursorNode_) {
this.terminal.focusHyperCaret();
}
return oldKeyDown.call(this, e);
Expand Down

0 comments on commit b4943a0

Please sign in to comment.