Skip to content

Commit fdaebc1

Browse files
authored
Merge pull request #116373 from microsoft/tyriar/megan
Move local terminal processes to live under the new ptyHost process
2 parents eb50a52 + da00865 commit fdaebc1

38 files changed

+828
-335
lines changed

extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { window, Pseudoterminal, EventEmitter, TerminalDimensions, workspace, ConfigurationTarget, Disposable, UIKind, env, EnvironmentVariableMutatorType, EnvironmentVariableMutator, extensions, ExtensionContext, TerminalOptions, ExtensionTerminalOptions, Terminal } from 'vscode';
7-
import { doesNotThrow, equal, deepEqual, throws } from 'assert';
7+
import { doesNotThrow, equal, deepEqual, throws, strictEqual } from 'assert';
88
import { assertNoRpc } from '../utils';
99

1010
// Disable terminal tests:
@@ -19,8 +19,6 @@ import { assertNoRpc } from '../utils';
1919
extensionContext = (global as any).testExtensionContext;
2020

2121
const config = workspace.getConfiguration('terminal.integrated');
22-
// Disable conpty in integration tests because of https://github.com/microsoft/vscode/issues/76548
23-
await config.update('windowsEnableConpty', false, ConfigurationTarget.Global);
2422
// Disable exit alerts as tests may trigger then and we're not testing the notifications
2523
await config.update('showExitAlert', false, ConfigurationTarget.Global);
2624
// Canvas may cause problems when running in a container
@@ -57,49 +55,43 @@ import { assertNoRpc } from '../utils';
5755
});
5856
});
5957

60-
(process.platform === 'linux' ? test.skip : test)('echo works in the default shell', (done) => {
61-
disposables.push(window.onDidOpenTerminal(term => {
62-
try {
63-
equal(terminal, term);
64-
} catch (e) {
65-
done(e);
66-
return;
67-
}
68-
let data = '';
69-
const dataDisposable = window.onDidWriteTerminalData(e => {
70-
try {
71-
equal(terminal, e.terminal);
72-
} catch (e) {
73-
done(e);
74-
return;
75-
}
76-
data += e.data;
77-
if (data.indexOf(expected) !== 0) {
78-
dataDisposable.dispose();
79-
terminal.dispose();
80-
disposables.push(window.onDidCloseTerminal(() => {
81-
done();
82-
}));
83-
}
58+
test('echo works in the default shell', async () => {
59+
const terminal = await new Promise<Terminal>(r => {
60+
disposables.push(window.onDidOpenTerminal(t => {
61+
strictEqual(terminal, t);
62+
r(terminal);
63+
}));
64+
// Use a single character to avoid winpty/conpty issues with injected sequences
65+
const terminal = window.createTerminal({
66+
env: { TEST: '`' }
8467
});
85-
disposables.push(dataDisposable);
86-
}));
87-
// Use a single character to avoid winpty/conpty issues with injected sequences
88-
const expected = '`';
89-
const terminal = window.createTerminal({
90-
env: {
91-
TEST: '`'
92-
}
68+
terminal.show();
9369
});
94-
terminal.show();
95-
doesNotThrow(() => {
70+
71+
let data = '';
72+
await new Promise<void>(r => {
73+
disposables.push(window.onDidWriteTerminalData(e => {
74+
strictEqual(terminal, e.terminal);
75+
data += e.data;
76+
if (data.indexOf('`') !== 0) {
77+
r();
78+
}
79+
}));
9680
// Print an environment variable value so the echo statement doesn't get matched
9781
if (process.platform === 'win32') {
9882
terminal.sendText(`$env:TEST`);
9983
} else {
10084
terminal.sendText(`echo $TEST`);
10185
}
10286
});
87+
88+
await new Promise<void>(r => {
89+
terminal.dispose();
90+
disposables.push(window.onDidCloseTerminal(t => {
91+
strictEqual(terminal, t);
92+
r();
93+
}));
94+
});
10395
});
10496

10597
test('onDidCloseTerminal event fires when terminal is disposed', async () => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-oss-dev",
33
"version": "1.54.0",
4-
"distro": "918cb1526e6442d55ef2c4e617f77afe48f6a3fe",
4+
"distro": "bb7724655cd33d9e9fa31c98ca48a306147c276a",
55
"author": {
66
"name": "Microsoft Corporation"
77
},
@@ -222,4 +222,4 @@
222222
"elliptic": "^6.5.3",
223223
"nwmatcher": "^1.4.4"
224224
}
225-
}
225+
}

src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ import { DeprecatedExtensionsCleaner } from 'vs/code/electron-browser/sharedProc
8080
import { onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/errors';
8181
import { toErrorMessage } from 'vs/base/common/errorMessage';
8282
import { join } from 'vs/base/common/path';
83+
import { TerminalIpcChannels } from 'vs/platform/terminal/common/terminal';
84+
import { LocalPtyService } from 'vs/platform/terminal/electron-browser/localPtyService';
85+
import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal';
8386
import { UserDataSyncChannel } from 'vs/platform/userDataSync/common/userDataSyncServiceIpc';
8487

8588
class SharedProcessMain extends Disposable {
@@ -259,6 +262,10 @@ class SharedProcessMain extends Disposable {
259262
services.set(IUserDataSyncResourceEnablementService, new SyncDescriptor(UserDataSyncResourceEnablementService));
260263
services.set(IUserDataSyncService, new SyncDescriptor(UserDataSyncService));
261264

265+
// Terminal
266+
const localPtyService = this._register(new LocalPtyService(logService));
267+
services.set(ILocalPtyService, localPtyService);
268+
262269
return new InstantiationService(services);
263270
}
264271

@@ -296,6 +303,11 @@ class SharedProcessMain extends Disposable {
296303
const userDataAutoSync = this._register(accessor.get(IInstantiationService).createInstance(UserDataAutoSyncService));
297304
const userDataAutoSyncChannel = new UserDataAutoSyncChannel(userDataAutoSync);
298305
this.server.registerChannel('userDataAutoSync', userDataAutoSyncChannel);
306+
307+
// Terminal
308+
const localPtyService = accessor.get(ILocalPtyService);
309+
const localPtyChannel = ProxyChannel.fromService(localPtyService);
310+
this.server.registerChannel(TerminalIpcChannels.LocalPty, localPtyChannel);
299311
}
300312

301313
private registerErrorHandler(logService: ILogService): void {

0 commit comments

Comments
 (0)