Skip to content

Commit 9bd1e02

Browse files
authored
Preserve focus when sending text to a terminal (#651)
* Fixes #60 * Fix tests to account for preserving of focus
1 parent 94cd778 commit 9bd1e02

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/client/common/terminal/service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ export class TerminalService implements ITerminalService, Disposable {
3636
public async sendCommand(command: string, args: string[]): Promise<void> {
3737
await this.ensureTerminal();
3838
const text = this.terminalHelper.buildCommandForTerminal(this.terminalShellType, command, args);
39-
this.terminal!.show();
39+
this.terminal!.show(true);
4040
this.terminal!.sendText(text, true);
4141
}
4242
public async sendText(text: string): Promise<void> {
4343
await this.ensureTerminal();
44-
this.terminal!.show();
44+
this.terminal!.show(true);
4545
this.terminal!.sendText(text);
4646
}
4747
public async show(): Promise<void> {
4848
await this.ensureTerminal();
49-
this.terminal!.show();
49+
this.terminal!.show(true);
5050
}
5151
private async ensureTerminal(): Promise<void> {
5252
if (this.terminal) {
@@ -70,7 +70,7 @@ export class TerminalService implements ITerminalService, Disposable {
7070
}
7171
}
7272

73-
this.terminal!.show();
73+
this.terminal!.show(true);
7474
}
7575
private terminalCloseHandler(terminal: Terminal) {
7676
if (terminal === this.terminal) {

src/test/common/terminals/service.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ suite('Terminal Service', () => {
6666
// Sending a command will cause the terminal to be created
6767
await service.sendCommand('', []);
6868

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

8585
await service.sendCommand(commandToSend, args);
8686

87-
terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
87+
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
8888
terminal.verify(t => t.sendText(TypeMoq.It.isValue(commandToExpect), TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(1));
8989
});
9090

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

9999
await service.sendText(textToSend);
100100

101-
terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
101+
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
102102
terminal.verify(t => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(1));
103103
});
104104

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

112112
await service.show();
113113

114-
terminal.verify(t => t.show(), TypeMoq.Times.exactly(2));
114+
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(2));
115115
});
116116

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

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

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

146-
terminal.verify(t => t.show(), TypeMoq.Times.exactly(5));
146+
terminal.verify(t => t.show(TypeMoq.It.isValue(true)), TypeMoq.Times.exactly(5));
147147
terminal.verify(t => t.sendText(TypeMoq.It.isValue('activation Command')), TypeMoq.Times.exactly(1));
148148
terminal.verify(t => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(4));
149149
});

0 commit comments

Comments
 (0)