Skip to content

Commit

Permalink
fix: add x-terminal:focus command to atom-workspace (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Oct 7, 2020
1 parent 5805a4e commit 4bac2f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 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
4 changes: 2 additions & 2 deletions src/x-terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ class XTerminalSingleton {
'x-terminal:close-all': () => this.exitAllTerminals(),
'x-terminal:insert-selected-text': () => this.insertSelection(),
'x-terminal:run-selected-text': () => this.runSelection(),
'x-terminal:focus': () => this.focus(),
}),
atom.commands.add('x-terminal', {
'x-terminal:close': () => this.close(),
'x-terminal:restart': () => this.restart(),
'x-terminal:copy': () => this.copy(),
'x-terminal:paste': () => this.paste(),
'x-terminal:unfocus': () => this.unfocus(),
'x-terminal:focus': () => this.focus(),
}),
)
}
Expand Down 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 4bac2f8

Please sign in to comment.