Skip to content

Commit 4891adb

Browse files
committed
Ensure process os is set before xterm link handler is registered
Fixes microsoft#62586
1 parent 692c89b commit 4891adb

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,23 @@ export class TerminalInstance implements ITerminalInstance {
426426
this._xterm.on('key', (key, ev) => this._onKey(key, ev));
427427

428428
if (this._processManager) {
429-
if (this._processManager.os === platform.OperatingSystem.Windows) {
430-
this._xterm.winptyCompatInit();
431-
}
432429
this._processManager.onProcessData(data => this._onProcessData(data));
433430
this._xterm.on('data', data => this._processManager!.write(data));
434431
// TODO: How does the cwd work on detached processes?
435-
this._linkHandler = this._instantiationService.createInstance(TerminalLinkHandler, this._xterm, platform.platform, this._processManager);
436432
this.processReady.then(async () => {
437433
this._linkHandler.processCwd = await this._processManager!.getInitialCwd();
438434
});
435+
// Init winpty compat and link handler after process creation as they rely on the
436+
// underlying process OS
437+
this._processManager.onProcessReady(() => {
438+
if (!this._processManager) {
439+
return;
440+
}
441+
if (this._processManager.os === platform.OperatingSystem.Windows) {
442+
this._xterm.winptyCompatInit();
443+
}
444+
this._linkHandler = this._instantiationService.createInstance(TerminalLinkHandler, this._xterm, platform.platform, this._processManager);
445+
});
439446
}
440447
this._xterm.on('focus', () => this._onFocus.fire(this));
441448

@@ -579,7 +586,7 @@ export class TerminalInstance implements ITerminalInstance {
579586

580587
if (this._processManager) {
581588
this._widgetManager = new TerminalWidgetManager(this._wrapperElement);
582-
this._linkHandler.setWidgetManager(this._widgetManager);
589+
this._processManager.onProcessReady(() => this._linkHandler.setWidgetManager(this._widgetManager));
583590
}
584591

585592
const computedStyle = window.getComputedStyle(this._container);

0 commit comments

Comments
 (0)