Skip to content

Commit

Permalink
Preserve focus when sending text to a terminal (#651)
Browse files Browse the repository at this point in the history
* Fixes #60
* Fix tests to account for preserving of focus
  • Loading branch information
DonJayamanne authored Jan 29, 2018
1 parent 94cd778 commit 9bd1e02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ export class TerminalService implements ITerminalService, Disposable {
public async sendCommand(command: string, args: string[]): Promise<void> {
await this.ensureTerminal();
const text = this.terminalHelper.buildCommandForTerminal(this.terminalShellType, command, args);
this.terminal!.show();
this.terminal!.show(true);
this.terminal!.sendText(text, true);
}
public async sendText(text: string): Promise<void> {
await this.ensureTerminal();
this.terminal!.show();
this.terminal!.show(true);
this.terminal!.sendText(text);
}
public async show(): Promise<void> {
await this.ensureTerminal();
this.terminal!.show();
this.terminal!.show(true);
}
private async ensureTerminal(): Promise<void> {
if (this.terminal) {
Expand All @@ -70,7 +70,7 @@ export class TerminalService implements ITerminalService, Disposable {
}
}

this.terminal!.show();
this.terminal!.show(true);
}
private terminalCloseHandler(terminal: Terminal) {
if (terminal === this.terminal) {
Expand Down
12 changes: 6 additions & 6 deletions src/test/common/terminals/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ suite('Terminal Service', () => {
// Sending a command will cause the terminal to be created
await service.sendCommand('', []);

terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
service.dispose();
terminal.verify(t => t.dispose(), TypeMoq.Times.exactly(1));
});
Expand All @@ -84,7 +84,7 @@ suite('Terminal Service', () => {

await service.sendCommand(commandToSend, args);

terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
terminal.verify(t => t.sendText(TypeMoq.It.isValue(commandToExpect), TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(1));
});

Expand All @@ -98,7 +98,7 @@ suite('Terminal Service', () => {

await service.sendText(textToSend);

terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
terminal.verify(t => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(1));
});

Expand All @@ -111,7 +111,7 @@ suite('Terminal Service', () => {

await service.show();

terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
});

test('Ensure terminal is activated once after creation', async () => {
Expand All @@ -126,7 +126,7 @@ suite('Terminal Service', () => {
await service.show();
await service.show();

terminal.verify(t => t.show(), TypeMoq.Times.exactly(5));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(5));
terminal.verify(t => t.sendText(TypeMoq.It.isValue('activation Command')), TypeMoq.Times.exactly(1));
});

Expand All @@ -143,7 +143,7 @@ suite('Terminal Service', () => {
await service.sendText(textToSend);
await service.sendText(textToSend);

terminal.verify(t => t.show(), TypeMoq.Times.exactly(5));
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(5));
terminal.verify(t => t.sendText(TypeMoq.It.isValue('activation Command')), TypeMoq.Times.exactly(1));
terminal.verify(t => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(4));
});
Expand Down

0 comments on commit 9bd1e02

Please sign in to comment.