Skip to content

Commit

Permalink
fix: double focus on terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Oct 7, 2020
1 parent 62fb0f0 commit 3b8f018
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,14 @@ class XTerminalElementImpl extends HTMLElement {
}
}

focusOnTerminal () {
focusOnTerminal (double) {
if (this.terminal) {
this.model.setActive()
this.terminal.focus()
if (double) {
// second focus will send command to pty
this.terminal.focus()
}
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ class XTerminalModel {
}
}

focusOnTerminal () {
this.element.focusOnTerminal()
const oldIsModified = this.modified
this.modified = false
if (oldIsModified !== this.modified) {
focusOnTerminal (double) {
this.element.focusOnTerminal(double)
if (this.modified) {
this.modified = false
this.emitter.emit('did-change-modified', this.modified)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/x-terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class XTerminalSingleton {
this.openTerminal()
} else {
const activeTerminal = [...this.terminals_set].find(t => t.activeIndex === 0)
activeTerminal.focusOnTerminal()
activeTerminal.focusOnTerminal(true)
}
}

Expand Down

0 comments on commit 3b8f018

Please sign in to comment.