Skip to content

Commit

Permalink
fix: activate pane on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed May 3, 2021
1 parent c321c1a commit cee1511
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cee1511

Please sign in to comment.