diff --git a/src/element.ts b/src/element.ts index cabb8c1..fc47de8 100644 --- a/src/element.ts +++ b/src/element.ts @@ -346,10 +346,14 @@ export class AtomTerminal extends HTMLElement { } } - focusOnTerminal() { + focusOnTerminal(double = false) { if (this.terminal && this.model) { this.model.setActive() this.terminal.focus() + if (double) { + // second focus will send command to pty + this.terminal.focus() + } } } diff --git a/src/model.ts b/src/model.ts index c85c28a..fbe908b 100644 --- a/src/model.ts +++ b/src/model.ts @@ -185,9 +185,12 @@ export class TerminalModel { } } - focusOnTerminal() { + focusOnTerminal(double = false) { if (this.element) { - this.element.focusOnTerminal() + if (this.pane) { + this.pane.activateItem(this); + } + this.element.focusOnTerminal(double) const oldIsModified = this.modified this.modified = false if (oldIsModified !== this.modified) { diff --git a/src/terminal.ts b/src/terminal.ts index 9089a64..292a6b7 100644 --- a/src/terminal.ts +++ b/src/terminal.ts @@ -423,7 +423,7 @@ class Terminal { async focus() { const terminal = [...this.terminalsSet].find((t) => t.activeIndex === 0) if (terminal) { - terminal.focusOnTerminal() + terminal.focusOnTerminal(true) } else { const options = this.addDefaultPosition() await this.open(this.generateNewUri(), options)