@codingame/monaco-vscode-xterm-common 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/empty.js +1 -0
- package/package.json +45 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.d.ts +11 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.js +26 -0
- package/vscode/src/vs/platform/terminal/common/environmentVariable.d.ts +86 -0
- package/vscode/src/vs/platform/terminal/common/environmentVariable.js +10 -0
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.d.ts +17 -0
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.js +214 -0
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.d.ts +14 -0
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.js +75 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.js +125 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.d.ts +104 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.js +1554 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.js +45 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.js +82 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.d.ts +408 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.js +2338 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.d.ts +143 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.js +684 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.js +68 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.d.ts +57 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.js +135 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.d.ts +40 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.js +754 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.js +112 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.js +59 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.js +319 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.js +17 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.d.ts +58 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.js +69 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/media/stickyScroll.css +49 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.js +25 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollContribution.d.ts +35 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollContribution.js +117 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +428 -0
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { Disposable, dispose, toDisposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
6
|
+
import { OS, OperatingSystem, isWindows, isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
7
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
8
|
+
import { formatMessageForTerminal } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminalStrings';
|
|
9
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
12
|
+
import { getRemoteAuthority } from '@codingame/monaco-vscode-api/vscode/vs/platform/remote/common/remoteHosts';
|
|
13
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
14
|
+
import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
15
|
+
import { NaiveCwdDetectionCapability } from '../../../../platform/terminal/common/capabilities/naiveCwdDetectionCapability.js';
|
|
16
|
+
import { TerminalCapabilityStore } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
|
17
|
+
import { TerminalSettingId, ProcessPropertyType, FlowControlConstants } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
18
|
+
import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
|
|
19
|
+
import { TerminalRecorder } from '../../../../platform/terminal/common/terminalRecorder.js';
|
|
20
|
+
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
21
|
+
import { EnvironmentVariableInfoChangesActive, EnvironmentVariableInfoStale } from './environmentVariableInfo.js';
|
|
22
|
+
import { ITerminalConfigurationService, ITerminalInstanceService, ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
|
|
23
|
+
import { IEnvironmentVariableService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/environmentVariable.service';
|
|
24
|
+
import { MergedEnvironmentVariableCollection } from '../../../../platform/terminal/common/environmentVariableCollection.js';
|
|
25
|
+
import { serializeEnvironmentVariableCollections } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/environmentVariableShared';
|
|
26
|
+
import { ProcessState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal';
|
|
27
|
+
import { ITerminalProfileResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service';
|
|
28
|
+
import { getWorkspaceForTerminal, createVariableResolver, createTerminalEnvironment, getCwd } from '../common/terminalEnvironment.js';
|
|
29
|
+
import { IConfigurationResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service';
|
|
30
|
+
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
31
|
+
import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
|
|
32
|
+
import { IPathService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/path/common/pathService.service';
|
|
33
|
+
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
34
|
+
import { TaskSettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/tasks/common/tasks';
|
|
35
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
36
|
+
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
37
|
+
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
38
|
+
import { runWhenWindowIdle, getActiveWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
39
|
+
import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
|
|
40
|
+
import { shouldUseEnvironmentVariableCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminalEnvironment';
|
|
41
|
+
import { TerminalContribSettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/terminalContribExports';
|
|
42
|
+
import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
43
|
+
import { BugIndicatingError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
44
|
+
import { isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
45
|
+
|
|
46
|
+
var ProcessConstants;
|
|
47
|
+
(function (ProcessConstants) {
|
|
48
|
+
ProcessConstants[ProcessConstants["ErrorLaunchThresholdDuration"] = 500] = "ErrorLaunchThresholdDuration";
|
|
49
|
+
ProcessConstants[ProcessConstants["LatencyMeasuringInterval"] = 1000] = "LatencyMeasuringInterval";
|
|
50
|
+
})(ProcessConstants || (ProcessConstants = {}));
|
|
51
|
+
var ProcessType;
|
|
52
|
+
(function (ProcessType) {
|
|
53
|
+
ProcessType[ProcessType["Process"] = 0] = "Process";
|
|
54
|
+
ProcessType[ProcessType["PsuedoTerminal"] = 1] = "PsuedoTerminal";
|
|
55
|
+
})(ProcessType || (ProcessType = {}));
|
|
56
|
+
let TerminalProcessManager = class TerminalProcessManager extends Disposable {
|
|
57
|
+
get persistentProcessId() { return this._process?.id; }
|
|
58
|
+
get shouldPersist() { return !!this.reconnectionProperties || (this._process ? this._process.shouldPersist : false); }
|
|
59
|
+
get hasWrittenData() { return this._hasWrittenData; }
|
|
60
|
+
get hasChildProcesses() { return this._hasChildProcesses; }
|
|
61
|
+
get reconnectionProperties() { return this._shellLaunchConfig?.attachPersistentProcess?.reconnectionProperties || this._shellLaunchConfig?.reconnectionProperties || undefined; }
|
|
62
|
+
get extEnvironmentVariableCollection() { return this._extEnvironmentVariableCollection; }
|
|
63
|
+
get processTraits() { return this._processTraits; }
|
|
64
|
+
constructor(_instanceId, cwd, environmentVariableCollections, shellIntegrationNonce, _historyService, _instantiationService, _logService, _workspaceContextService, _configurationResolverService, _workbenchEnvironmentService, _productService, _remoteAgentService, _pathService, _environmentVariableService, _terminalConfigurationService, _terminalProfileResolverService, _configurationService, _terminalInstanceService, _telemetryService, _notificationService, _accessibilityService, _terminalService) {
|
|
65
|
+
super();
|
|
66
|
+
this._instanceId = _instanceId;
|
|
67
|
+
this._historyService = _historyService;
|
|
68
|
+
this._instantiationService = _instantiationService;
|
|
69
|
+
this._logService = _logService;
|
|
70
|
+
this._workspaceContextService = _workspaceContextService;
|
|
71
|
+
this._configurationResolverService = _configurationResolverService;
|
|
72
|
+
this._workbenchEnvironmentService = _workbenchEnvironmentService;
|
|
73
|
+
this._productService = _productService;
|
|
74
|
+
this._remoteAgentService = _remoteAgentService;
|
|
75
|
+
this._pathService = _pathService;
|
|
76
|
+
this._environmentVariableService = _environmentVariableService;
|
|
77
|
+
this._terminalConfigurationService = _terminalConfigurationService;
|
|
78
|
+
this._terminalProfileResolverService = _terminalProfileResolverService;
|
|
79
|
+
this._configurationService = _configurationService;
|
|
80
|
+
this._terminalInstanceService = _terminalInstanceService;
|
|
81
|
+
this._telemetryService = _telemetryService;
|
|
82
|
+
this._notificationService = _notificationService;
|
|
83
|
+
this._accessibilityService = _accessibilityService;
|
|
84
|
+
this._terminalService = _terminalService;
|
|
85
|
+
this.processState = ProcessState.Uninitialized;
|
|
86
|
+
this.capabilities = this._register(( new TerminalCapabilityStore()));
|
|
87
|
+
this.processReadyTimestamp = 0;
|
|
88
|
+
this._isDisposed = false;
|
|
89
|
+
this._process = null;
|
|
90
|
+
this._processType = ProcessType.Process;
|
|
91
|
+
this._preLaunchInputQueue = [];
|
|
92
|
+
this._hasWrittenData = false;
|
|
93
|
+
this._hasChildProcesses = false;
|
|
94
|
+
this._ptyListenersAttached = false;
|
|
95
|
+
this._isDisconnected = false;
|
|
96
|
+
this._dimensions = { cols: 0, rows: 0 };
|
|
97
|
+
this._onPtyDisconnect = this._register(( new Emitter()));
|
|
98
|
+
this.onPtyDisconnect = this._onPtyDisconnect.event;
|
|
99
|
+
this._onPtyReconnect = this._register(( new Emitter()));
|
|
100
|
+
this.onPtyReconnect = this._onPtyReconnect.event;
|
|
101
|
+
this._onProcessReady = this._register(( new Emitter()));
|
|
102
|
+
this.onProcessReady = this._onProcessReady.event;
|
|
103
|
+
this._onProcessStateChange = this._register(( new Emitter()));
|
|
104
|
+
this.onProcessStateChange = this._onProcessStateChange.event;
|
|
105
|
+
this._onBeforeProcessData = this._register(( new Emitter()));
|
|
106
|
+
this.onBeforeProcessData = this._onBeforeProcessData.event;
|
|
107
|
+
this._onProcessData = this._register(( new Emitter()));
|
|
108
|
+
this.onProcessData = this._onProcessData.event;
|
|
109
|
+
this._onProcessReplayComplete = this._register(( new Emitter()));
|
|
110
|
+
this.onProcessReplayComplete = this._onProcessReplayComplete.event;
|
|
111
|
+
this._onDidChangeProperty = this._register(( new Emitter()));
|
|
112
|
+
this.onDidChangeProperty = this._onDidChangeProperty.event;
|
|
113
|
+
this._onEnvironmentVariableInfoChange = this._register(( new Emitter()));
|
|
114
|
+
this.onEnvironmentVariableInfoChanged = this._onEnvironmentVariableInfoChange.event;
|
|
115
|
+
this._onProcessExit = this._register(( new Emitter()));
|
|
116
|
+
this.onProcessExit = this._onProcessExit.event;
|
|
117
|
+
this._onRestoreCommands = this._register(( new Emitter()));
|
|
118
|
+
this.onRestoreCommands = this._onRestoreCommands.event;
|
|
119
|
+
this._cwdWorkspaceFolder = getWorkspaceForTerminal(cwd, this._workspaceContextService, this._historyService);
|
|
120
|
+
this.ptyProcessReady = this._createPtyProcessReadyPromise();
|
|
121
|
+
this._ackDataBufferer = ( new AckDataBufferer(e => this._process?.acknowledgeDataEvent(e)));
|
|
122
|
+
this._dataFilter = this._register(this._instantiationService.createInstance(SeamlessRelaunchDataFilter));
|
|
123
|
+
this._register(this._dataFilter.onProcessData(ev => {
|
|
124
|
+
const data = (isString(ev) ? ev : ev.data);
|
|
125
|
+
const beforeProcessDataEvent = { data };
|
|
126
|
+
this._onBeforeProcessData.fire(beforeProcessDataEvent);
|
|
127
|
+
if (beforeProcessDataEvent.data && beforeProcessDataEvent.data.length > 0) {
|
|
128
|
+
if (!isString(ev)) {
|
|
129
|
+
ev.data = beforeProcessDataEvent.data;
|
|
130
|
+
}
|
|
131
|
+
this._onProcessData.fire(!isString(ev) ? ev : { data: beforeProcessDataEvent.data, trackCommit: false });
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
if (cwd && typeof cwd === 'object') {
|
|
135
|
+
this.remoteAuthority = getRemoteAuthority(cwd);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.remoteAuthority = this._workbenchEnvironmentService.remoteAuthority;
|
|
139
|
+
}
|
|
140
|
+
if (environmentVariableCollections) {
|
|
141
|
+
this._extEnvironmentVariableCollection = ( new MergedEnvironmentVariableCollection(environmentVariableCollections));
|
|
142
|
+
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
|
|
143
|
+
this.environmentVariableInfo = this._instantiationService.createInstance(EnvironmentVariableInfoChangesActive, this._extEnvironmentVariableCollection);
|
|
144
|
+
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
|
145
|
+
}
|
|
146
|
+
this.shellIntegrationNonce = shellIntegrationNonce ?? generateUuid();
|
|
147
|
+
}
|
|
148
|
+
async freePortKillProcess(port) {
|
|
149
|
+
try {
|
|
150
|
+
if (this._process?.freePortKillProcess) {
|
|
151
|
+
await this._process?.freePortKillProcess(port);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
this._notificationService.notify({ message: ( localize(
|
|
156
|
+
11603,
|
|
157
|
+
'Could not kill process listening on port {0}, command exited with error {1}',
|
|
158
|
+
port,
|
|
159
|
+
e
|
|
160
|
+
)), severity: Severity.Warning });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
dispose(immediate = false) {
|
|
164
|
+
this._isDisposed = true;
|
|
165
|
+
if (this._process) {
|
|
166
|
+
this._setProcessState(ProcessState.KilledByUser);
|
|
167
|
+
this._process.shutdown(immediate);
|
|
168
|
+
this._process = null;
|
|
169
|
+
}
|
|
170
|
+
if (this._processListeners) {
|
|
171
|
+
dispose(this._processListeners);
|
|
172
|
+
this._processListeners = undefined;
|
|
173
|
+
}
|
|
174
|
+
super.dispose();
|
|
175
|
+
}
|
|
176
|
+
_createPtyProcessReadyPromise() {
|
|
177
|
+
return ( new Promise(c => {
|
|
178
|
+
const listener = Event.once(this.onProcessReady)(() => {
|
|
179
|
+
this._logService.debug(`Terminal process ready (shellProcessId: ${this.shellProcessId})`);
|
|
180
|
+
this._store.delete(listener);
|
|
181
|
+
c(undefined);
|
|
182
|
+
});
|
|
183
|
+
this._store.add(listener);
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
async detachFromProcess(forcePersist) {
|
|
187
|
+
await this._process?.detach?.(forcePersist);
|
|
188
|
+
this._process = null;
|
|
189
|
+
}
|
|
190
|
+
async createProcess(shellLaunchConfig, cols, rows, reset = true) {
|
|
191
|
+
this._shellLaunchConfig = shellLaunchConfig;
|
|
192
|
+
this._dimensions.cols = cols;
|
|
193
|
+
this._dimensions.rows = rows;
|
|
194
|
+
let newProcess;
|
|
195
|
+
if (shellLaunchConfig.customPtyImplementation) {
|
|
196
|
+
this._processType = ProcessType.PsuedoTerminal;
|
|
197
|
+
newProcess = shellLaunchConfig.customPtyImplementation(this._instanceId, cols, rows);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const backend = await this._terminalInstanceService.getBackend(this.remoteAuthority);
|
|
201
|
+
if (!backend) {
|
|
202
|
+
throw ( new Error(
|
|
203
|
+
`No terminal backend registered for remote authority '${this.remoteAuthority}'`
|
|
204
|
+
));
|
|
205
|
+
}
|
|
206
|
+
this.backend = backend;
|
|
207
|
+
const variableResolver = createVariableResolver(this._cwdWorkspaceFolder, await this._terminalProfileResolverService.getEnvironment(this.remoteAuthority), this._configurationResolverService);
|
|
208
|
+
this.userHome = this._pathService.resolvedUserHome?.fsPath;
|
|
209
|
+
this.os = OS;
|
|
210
|
+
if (!!this.remoteAuthority) {
|
|
211
|
+
const userHomeUri = await this._pathService.userHome();
|
|
212
|
+
this.userHome = userHomeUri.path;
|
|
213
|
+
const remoteEnv = await this._remoteAgentService.getEnvironment();
|
|
214
|
+
if (!remoteEnv) {
|
|
215
|
+
throw ( new Error(
|
|
216
|
+
`Failed to get remote environment for remote authority "${this.remoteAuthority}"`
|
|
217
|
+
));
|
|
218
|
+
}
|
|
219
|
+
this.userHome = remoteEnv.userHome.path;
|
|
220
|
+
this.os = remoteEnv.os;
|
|
221
|
+
const env = await this._resolveEnvironment(backend, variableResolver, shellLaunchConfig);
|
|
222
|
+
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionProperties) || !shellLaunchConfig.isFeatureTerminal) && this._terminalConfigurationService.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
|
|
223
|
+
if (shellLaunchConfig.attachPersistentProcess) {
|
|
224
|
+
const result = await backend.attachToProcess(shellLaunchConfig.attachPersistentProcess.id);
|
|
225
|
+
if (result) {
|
|
226
|
+
newProcess = result;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
this._logService.warn(`Attach to process failed for terminal`, shellLaunchConfig.attachPersistentProcess);
|
|
230
|
+
shellLaunchConfig.attachPersistentProcess = undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!newProcess) {
|
|
234
|
+
await this._terminalProfileResolverService.resolveShellLaunchConfig(shellLaunchConfig, {
|
|
235
|
+
remoteAuthority: this.remoteAuthority,
|
|
236
|
+
os: this.os
|
|
237
|
+
});
|
|
238
|
+
const options = {
|
|
239
|
+
shellIntegration: {
|
|
240
|
+
enabled: this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled),
|
|
241
|
+
suggestEnabled: this._configurationService.getValue(TerminalContribSettingId.SuggestEnabled),
|
|
242
|
+
nonce: this.shellIntegrationNonce
|
|
243
|
+
},
|
|
244
|
+
windowsEnableConpty: this._terminalConfigurationService.config.windowsEnableConpty,
|
|
245
|
+
windowsUseConptyDll: this._terminalConfigurationService.config.windowsUseConptyDll ?? false,
|
|
246
|
+
environmentVariableCollections: this._extEnvironmentVariableCollection?.collections ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined,
|
|
247
|
+
workspaceFolder: this._cwdWorkspaceFolder,
|
|
248
|
+
isScreenReaderOptimized: this._accessibilityService.isScreenReaderOptimized()
|
|
249
|
+
};
|
|
250
|
+
try {
|
|
251
|
+
newProcess = await backend.createProcess(shellLaunchConfig, '',
|
|
252
|
+
cols, rows, this._terminalConfigurationService.config.unicodeVersion, env,
|
|
253
|
+
options, shouldPersist);
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
if (e?.message === 'Could not fetch remote environment') {
|
|
257
|
+
this._logService.trace(`Could not fetch remote environment, silently failing`);
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
throw e;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (!this._isDisposed) {
|
|
264
|
+
this._setupPtyHostListeners(backend);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
if (shellLaunchConfig.attachPersistentProcess) {
|
|
269
|
+
const result = shellLaunchConfig.attachPersistentProcess.findRevivedId ? await backend.attachToRevivedProcess(shellLaunchConfig.attachPersistentProcess.id) : await backend.attachToProcess(shellLaunchConfig.attachPersistentProcess.id);
|
|
270
|
+
if (result) {
|
|
271
|
+
newProcess = result;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
this._logService.warn(`Attach to process failed for terminal`, shellLaunchConfig.attachPersistentProcess);
|
|
275
|
+
shellLaunchConfig.attachPersistentProcess = undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!newProcess) {
|
|
279
|
+
newProcess = await this._launchLocalProcess(backend, shellLaunchConfig, cols, rows, this.userHome, variableResolver);
|
|
280
|
+
}
|
|
281
|
+
if (!this._isDisposed) {
|
|
282
|
+
this._setupPtyHostListeners(backend);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (this._isDisposed) {
|
|
287
|
+
newProcess.shutdown(false);
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
this._process = newProcess;
|
|
291
|
+
this._setProcessState(ProcessState.Launching);
|
|
292
|
+
if (this.os === OperatingSystem.Linux || this.os === OperatingSystem.Macintosh) {
|
|
293
|
+
this.capabilities.add(TerminalCapability.NaiveCwdDetection, ( new NaiveCwdDetectionCapability(this._process)));
|
|
294
|
+
}
|
|
295
|
+
this._dataFilter.newProcess(this._process, reset);
|
|
296
|
+
if (this._processListeners) {
|
|
297
|
+
dispose(this._processListeners);
|
|
298
|
+
}
|
|
299
|
+
this._processListeners = [
|
|
300
|
+
newProcess.onProcessReady((e) => {
|
|
301
|
+
this._processTraits = e;
|
|
302
|
+
this.shellProcessId = e.pid;
|
|
303
|
+
this._initialCwd = e.cwd;
|
|
304
|
+
this.processReadyTimestamp = Date.now();
|
|
305
|
+
this._onDidChangeProperty.fire({ type: ProcessPropertyType.InitialCwd, value: this._initialCwd });
|
|
306
|
+
this._onProcessReady.fire(e);
|
|
307
|
+
if (this._preLaunchInputQueue.length > 0 && this._process) {
|
|
308
|
+
newProcess.input(this._preLaunchInputQueue.join(''));
|
|
309
|
+
this._preLaunchInputQueue.length = 0;
|
|
310
|
+
}
|
|
311
|
+
}),
|
|
312
|
+
newProcess.onProcessExit(exitCode => this._onExit(exitCode)),
|
|
313
|
+
newProcess.onDidChangeProperty(({ type, value }) => {
|
|
314
|
+
switch (type) {
|
|
315
|
+
case ProcessPropertyType.HasChildProcesses:
|
|
316
|
+
this._hasChildProcesses = value;
|
|
317
|
+
break;
|
|
318
|
+
case ProcessPropertyType.FailedShellIntegrationActivation:
|
|
319
|
+
this._telemetryService?.publicLog2('terminal/shellIntegrationActivationFailureCustomArgs');
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
this._onDidChangeProperty.fire({ type, value });
|
|
323
|
+
})
|
|
324
|
+
];
|
|
325
|
+
if (newProcess.onProcessReplayComplete) {
|
|
326
|
+
this._processListeners.push(newProcess.onProcessReplayComplete(() => this._onProcessReplayComplete.fire()));
|
|
327
|
+
}
|
|
328
|
+
if (newProcess.onRestoreCommands) {
|
|
329
|
+
this._processListeners.push(newProcess.onRestoreCommands(e => this._onRestoreCommands.fire(e)));
|
|
330
|
+
}
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
if (this.processState === ProcessState.Launching) {
|
|
333
|
+
this._setProcessState(ProcessState.Running);
|
|
334
|
+
}
|
|
335
|
+
}, ProcessConstants.ErrorLaunchThresholdDuration);
|
|
336
|
+
const result = await newProcess.start();
|
|
337
|
+
if (result) {
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
runWhenWindowIdle(getActiveWindow(), () => {
|
|
341
|
+
this.backend?.getLatency().then(measurements => {
|
|
342
|
+
this._logService.info(`Latency measurements for ${this.remoteAuthority ?? 'local'} backend\n${( measurements.map(e => `${e.label}: ${e.latency.toFixed(2)}ms`)).join('\n')}`);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
async relaunch(shellLaunchConfig, cols, rows, reset) {
|
|
348
|
+
this.ptyProcessReady = this._createPtyProcessReadyPromise();
|
|
349
|
+
this._logService.trace(`Relaunching terminal instance ${this._instanceId}`);
|
|
350
|
+
if (this._isDisconnected) {
|
|
351
|
+
this._isDisconnected = false;
|
|
352
|
+
this._onPtyReconnect.fire();
|
|
353
|
+
}
|
|
354
|
+
this._hasWrittenData = false;
|
|
355
|
+
return this.createProcess(shellLaunchConfig, cols, rows, reset);
|
|
356
|
+
}
|
|
357
|
+
async _resolveEnvironment(backend, variableResolver, shellLaunchConfig) {
|
|
358
|
+
const workspaceFolder = getWorkspaceForTerminal(shellLaunchConfig.cwd, this._workspaceContextService, this._historyService);
|
|
359
|
+
const platformKey = isWindows ? 'windows' : (isMacintosh ? 'osx' : 'linux');
|
|
360
|
+
const envFromConfigValue = this._configurationService.getValue(`terminal.integrated.env.${platformKey}`);
|
|
361
|
+
let baseEnv;
|
|
362
|
+
if (shellLaunchConfig.useShellEnvironment) {
|
|
363
|
+
const shellEnv = await backend.getShellEnvironment();
|
|
364
|
+
if (!shellEnv) {
|
|
365
|
+
throw ( new BugIndicatingError('Cannot fetch shell environment to use'));
|
|
366
|
+
}
|
|
367
|
+
baseEnv = shellEnv;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
baseEnv = await this._terminalProfileResolverService.getEnvironment(this.remoteAuthority);
|
|
371
|
+
}
|
|
372
|
+
const env = await createTerminalEnvironment(shellLaunchConfig, envFromConfigValue, variableResolver, this._productService.version, this._terminalConfigurationService.config.detectLocale, baseEnv);
|
|
373
|
+
if (!this._isDisposed && shouldUseEnvironmentVariableCollection(shellLaunchConfig)) {
|
|
374
|
+
this._extEnvironmentVariableCollection = this._environmentVariableService.mergedCollection;
|
|
375
|
+
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
|
|
376
|
+
await this._extEnvironmentVariableCollection.applyToProcessEnvironment(env, { workspaceFolder }, variableResolver);
|
|
377
|
+
if (this._extEnvironmentVariableCollection.getVariableMap({ workspaceFolder }).size) {
|
|
378
|
+
this.environmentVariableInfo = this._instantiationService.createInstance(EnvironmentVariableInfoChangesActive, this._extEnvironmentVariableCollection);
|
|
379
|
+
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return env;
|
|
383
|
+
}
|
|
384
|
+
async _launchLocalProcess(backend, shellLaunchConfig, cols, rows, userHome, variableResolver) {
|
|
385
|
+
await this._terminalProfileResolverService.resolveShellLaunchConfig(shellLaunchConfig, {
|
|
386
|
+
remoteAuthority: undefined,
|
|
387
|
+
os: OS
|
|
388
|
+
});
|
|
389
|
+
const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
|
390
|
+
const initialCwd = await getCwd(shellLaunchConfig, userHome, variableResolver, activeWorkspaceRootUri, this._terminalConfigurationService.config.cwd, this._logService);
|
|
391
|
+
const env = await this._resolveEnvironment(backend, variableResolver, shellLaunchConfig);
|
|
392
|
+
const options = {
|
|
393
|
+
shellIntegration: {
|
|
394
|
+
enabled: this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled),
|
|
395
|
+
suggestEnabled: this._configurationService.getValue(TerminalContribSettingId.SuggestEnabled),
|
|
396
|
+
nonce: this.shellIntegrationNonce
|
|
397
|
+
},
|
|
398
|
+
windowsEnableConpty: this._terminalConfigurationService.config.windowsEnableConpty,
|
|
399
|
+
windowsUseConptyDll: this._terminalConfigurationService.config.windowsUseConptyDll ?? false,
|
|
400
|
+
environmentVariableCollections: this._extEnvironmentVariableCollection ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined,
|
|
401
|
+
workspaceFolder: this._cwdWorkspaceFolder,
|
|
402
|
+
isScreenReaderOptimized: this._accessibilityService.isScreenReaderOptimized()
|
|
403
|
+
};
|
|
404
|
+
const shouldPersist = ((this._configurationService.getValue(TaskSettingId.Reconnection) && shellLaunchConfig.reconnectionProperties) || !shellLaunchConfig.isFeatureTerminal) && this._terminalConfigurationService.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
|
|
405
|
+
return await backend.createProcess(shellLaunchConfig, initialCwd, cols, rows, this._terminalConfigurationService.config.unicodeVersion, env, options, shouldPersist);
|
|
406
|
+
}
|
|
407
|
+
_setupPtyHostListeners(backend) {
|
|
408
|
+
if (this._ptyListenersAttached) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
this._ptyListenersAttached = true;
|
|
412
|
+
this._register(backend.onPtyHostUnresponsive(() => {
|
|
413
|
+
this._isDisconnected = true;
|
|
414
|
+
this._onPtyDisconnect.fire();
|
|
415
|
+
}));
|
|
416
|
+
this._ptyResponsiveListener = backend.onPtyHostResponsive(() => {
|
|
417
|
+
this._isDisconnected = false;
|
|
418
|
+
this._onPtyReconnect.fire();
|
|
419
|
+
});
|
|
420
|
+
this._register(toDisposable(() => this._ptyResponsiveListener?.dispose()));
|
|
421
|
+
this._register(backend.onPtyHostRestart(async () => {
|
|
422
|
+
if (!this._isDisconnected) {
|
|
423
|
+
this._isDisconnected = true;
|
|
424
|
+
this._onPtyDisconnect.fire();
|
|
425
|
+
}
|
|
426
|
+
this._ptyResponsiveListener?.dispose();
|
|
427
|
+
this._ptyResponsiveListener = undefined;
|
|
428
|
+
if (this._shellLaunchConfig) {
|
|
429
|
+
if (this._shellLaunchConfig.isFeatureTerminal && !this.reconnectionProperties) {
|
|
430
|
+
this._onExit(-1);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
const message = ( localize(
|
|
434
|
+
11604,
|
|
435
|
+
"Restarting the terminal because the connection to the shell process was lost..."
|
|
436
|
+
));
|
|
437
|
+
this._onProcessData.fire({ data: formatMessageForTerminal(message, { loudFormatting: true }), trackCommit: false });
|
|
438
|
+
await this.relaunch(this._shellLaunchConfig, this._dimensions.cols, this._dimensions.rows, false);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}));
|
|
442
|
+
}
|
|
443
|
+
async getBackendOS() {
|
|
444
|
+
let os = OS;
|
|
445
|
+
if (!!this.remoteAuthority) {
|
|
446
|
+
const remoteEnv = await this._remoteAgentService.getEnvironment();
|
|
447
|
+
if (!remoteEnv) {
|
|
448
|
+
throw ( new Error(
|
|
449
|
+
`Failed to get remote environment for remote authority "${this.remoteAuthority}"`
|
|
450
|
+
));
|
|
451
|
+
}
|
|
452
|
+
os = remoteEnv.os;
|
|
453
|
+
}
|
|
454
|
+
return os;
|
|
455
|
+
}
|
|
456
|
+
setDimensions(cols, rows, sync) {
|
|
457
|
+
if (sync) {
|
|
458
|
+
this._resize(cols, rows);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
return this.ptyProcessReady.then(() => this._resize(cols, rows));
|
|
462
|
+
}
|
|
463
|
+
async setUnicodeVersion(version) {
|
|
464
|
+
return this._process?.setUnicodeVersion(version);
|
|
465
|
+
}
|
|
466
|
+
async setNextCommandId(commandLine, commandId) {
|
|
467
|
+
await this.ptyProcessReady;
|
|
468
|
+
const process = this._process;
|
|
469
|
+
if (!process?.id) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
await this._terminalService.setNextCommandId(process.id, commandLine, commandId);
|
|
473
|
+
}
|
|
474
|
+
_resize(cols, rows) {
|
|
475
|
+
if (!this._process) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
this._process.resize(cols, rows);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
if (error.code !== 'EPIPE' && error.code !== 'ERR_IPC_CHANNEL_CLOSED') {
|
|
483
|
+
throw (error);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
this._dimensions.cols = cols;
|
|
487
|
+
this._dimensions.rows = rows;
|
|
488
|
+
}
|
|
489
|
+
async write(data) {
|
|
490
|
+
await this.ptyProcessReady;
|
|
491
|
+
this._dataFilter.disableSeamlessRelaunch();
|
|
492
|
+
this._hasWrittenData = true;
|
|
493
|
+
if (this.shellProcessId || this._processType === ProcessType.PsuedoTerminal) {
|
|
494
|
+
if (this._process) {
|
|
495
|
+
this._process.input(data);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
this._preLaunchInputQueue.push(data);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
async sendSignal(signal) {
|
|
503
|
+
await this.ptyProcessReady;
|
|
504
|
+
if (this._process) {
|
|
505
|
+
this._process.sendSignal(signal);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
async processBinary(data) {
|
|
509
|
+
await this.ptyProcessReady;
|
|
510
|
+
this._dataFilter.disableSeamlessRelaunch();
|
|
511
|
+
this._hasWrittenData = true;
|
|
512
|
+
this._process?.processBinary(data);
|
|
513
|
+
}
|
|
514
|
+
get initialCwd() {
|
|
515
|
+
return this._initialCwd ?? '';
|
|
516
|
+
}
|
|
517
|
+
async refreshProperty(type) {
|
|
518
|
+
if (!this._process) {
|
|
519
|
+
throw ( new Error('Cannot refresh property when process is not set'));
|
|
520
|
+
}
|
|
521
|
+
return this._process.refreshProperty(type);
|
|
522
|
+
}
|
|
523
|
+
async updateProperty(type, value) {
|
|
524
|
+
return this._process?.updateProperty(type, value);
|
|
525
|
+
}
|
|
526
|
+
acknowledgeDataEvent(charCount) {
|
|
527
|
+
this._ackDataBufferer.ack(charCount);
|
|
528
|
+
}
|
|
529
|
+
_onExit(exitCode) {
|
|
530
|
+
this._process = null;
|
|
531
|
+
if (this.processState === ProcessState.Launching) {
|
|
532
|
+
this._setProcessState(ProcessState.KilledDuringLaunch);
|
|
533
|
+
}
|
|
534
|
+
if (this.processState === ProcessState.Running) {
|
|
535
|
+
this._setProcessState(ProcessState.KilledByProcess);
|
|
536
|
+
}
|
|
537
|
+
this._onProcessExit.fire(exitCode);
|
|
538
|
+
}
|
|
539
|
+
_setProcessState(state) {
|
|
540
|
+
this.processState = state;
|
|
541
|
+
this._onProcessStateChange.fire();
|
|
542
|
+
}
|
|
543
|
+
_onEnvironmentVariableCollectionChange(newCollection) {
|
|
544
|
+
const diff = this._extEnvironmentVariableCollection.diff(newCollection, { workspaceFolder: this._cwdWorkspaceFolder });
|
|
545
|
+
if (diff === undefined) {
|
|
546
|
+
if (this.environmentVariableInfo instanceof EnvironmentVariableInfoStale) {
|
|
547
|
+
this.environmentVariableInfo = this._instantiationService.createInstance(EnvironmentVariableInfoChangesActive, this._extEnvironmentVariableCollection);
|
|
548
|
+
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.environmentVariableInfo = this._instantiationService.createInstance(EnvironmentVariableInfoStale, diff, this._instanceId, newCollection);
|
|
553
|
+
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
|
554
|
+
}
|
|
555
|
+
async clearBuffer() {
|
|
556
|
+
this._process?.clearBuffer?.();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
TerminalProcessManager = ( __decorate([
|
|
560
|
+
( __param(4, IHistoryService)),
|
|
561
|
+
( __param(5, IInstantiationService)),
|
|
562
|
+
( __param(6, ITerminalLogService)),
|
|
563
|
+
( __param(7, IWorkspaceContextService)),
|
|
564
|
+
( __param(8, IConfigurationResolverService)),
|
|
565
|
+
( __param(9, IWorkbenchEnvironmentService)),
|
|
566
|
+
( __param(10, IProductService)),
|
|
567
|
+
( __param(11, IRemoteAgentService)),
|
|
568
|
+
( __param(12, IPathService)),
|
|
569
|
+
( __param(13, IEnvironmentVariableService)),
|
|
570
|
+
( __param(14, ITerminalConfigurationService)),
|
|
571
|
+
( __param(15, ITerminalProfileResolverService)),
|
|
572
|
+
( __param(16, IConfigurationService)),
|
|
573
|
+
( __param(17, ITerminalInstanceService)),
|
|
574
|
+
( __param(18, ITelemetryService)),
|
|
575
|
+
( __param(19, INotificationService)),
|
|
576
|
+
( __param(20, IAccessibilityService)),
|
|
577
|
+
( __param(21, ITerminalService))
|
|
578
|
+
], TerminalProcessManager));
|
|
579
|
+
class AckDataBufferer {
|
|
580
|
+
constructor(_callback) {
|
|
581
|
+
this._callback = _callback;
|
|
582
|
+
this._unsentCharCount = 0;
|
|
583
|
+
}
|
|
584
|
+
ack(charCount) {
|
|
585
|
+
this._unsentCharCount += charCount;
|
|
586
|
+
while (this._unsentCharCount > FlowControlConstants.CharCountAckSize) {
|
|
587
|
+
this._unsentCharCount -= FlowControlConstants.CharCountAckSize;
|
|
588
|
+
this._callback(FlowControlConstants.CharCountAckSize);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
var SeamlessRelaunchConstants;
|
|
593
|
+
(function (SeamlessRelaunchConstants) {
|
|
594
|
+
SeamlessRelaunchConstants[SeamlessRelaunchConstants["RecordTerminalDuration"] = 10000] = "RecordTerminalDuration";
|
|
595
|
+
SeamlessRelaunchConstants[SeamlessRelaunchConstants["SwapWaitMaximumDuration"] = 3000] = "SwapWaitMaximumDuration";
|
|
596
|
+
})(SeamlessRelaunchConstants || (SeamlessRelaunchConstants = {}));
|
|
597
|
+
let SeamlessRelaunchDataFilter = class SeamlessRelaunchDataFilter extends Disposable {
|
|
598
|
+
get onProcessData() { return this._onProcessData.event; }
|
|
599
|
+
constructor(_logService) {
|
|
600
|
+
super();
|
|
601
|
+
this._logService = _logService;
|
|
602
|
+
this._firstDisposable = this._register(( new MutableDisposable()));
|
|
603
|
+
this._secondDisposable = this._register(( new MutableDisposable()));
|
|
604
|
+
this._dataListener = this._register(( new MutableDisposable()));
|
|
605
|
+
this._disableSeamlessRelaunch = false;
|
|
606
|
+
this._onProcessData = this._register(( new Emitter()));
|
|
607
|
+
}
|
|
608
|
+
newProcess(process, reset) {
|
|
609
|
+
this._dataListener.clear();
|
|
610
|
+
this._activeProcess?.shutdown(false);
|
|
611
|
+
this._activeProcess = process;
|
|
612
|
+
if (!this._firstRecorder || !reset || this._disableSeamlessRelaunch) {
|
|
613
|
+
[this._firstRecorder, this._firstDisposable.value] = this._createRecorder(process);
|
|
614
|
+
if (this._disableSeamlessRelaunch && reset) {
|
|
615
|
+
this._onProcessData.fire('\x1bc');
|
|
616
|
+
}
|
|
617
|
+
this._dataListener.value = process.onProcessData(e => this._onProcessData.fire(e));
|
|
618
|
+
this._disableSeamlessRelaunch = false;
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (this._secondRecorder) {
|
|
622
|
+
this.triggerSwap();
|
|
623
|
+
}
|
|
624
|
+
this._swapTimeout = mainWindow.setTimeout(() => this.triggerSwap(), SeamlessRelaunchConstants.SwapWaitMaximumDuration);
|
|
625
|
+
this._dataListener.clear();
|
|
626
|
+
this._firstDisposable.clear();
|
|
627
|
+
const recorder = this._createRecorder(process);
|
|
628
|
+
[this._secondRecorder, this._secondDisposable.value] = recorder;
|
|
629
|
+
}
|
|
630
|
+
disableSeamlessRelaunch() {
|
|
631
|
+
this._disableSeamlessRelaunch = true;
|
|
632
|
+
this._stopRecording();
|
|
633
|
+
this.triggerSwap();
|
|
634
|
+
}
|
|
635
|
+
triggerSwap() {
|
|
636
|
+
if (this._swapTimeout) {
|
|
637
|
+
mainWindow.clearTimeout(this._swapTimeout);
|
|
638
|
+
this._swapTimeout = undefined;
|
|
639
|
+
}
|
|
640
|
+
if (!this._firstRecorder) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if (!this._secondRecorder) {
|
|
644
|
+
this._firstRecorder = undefined;
|
|
645
|
+
this._firstDisposable.clear();
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
const firstData = this._getDataFromRecorder(this._firstRecorder);
|
|
649
|
+
const secondData = this._getDataFromRecorder(this._secondRecorder);
|
|
650
|
+
if (firstData === secondData) {
|
|
651
|
+
this._logService.trace(`Seamless terminal relaunch - identical content`);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
this._logService.trace(`Seamless terminal relaunch - resetting content`);
|
|
655
|
+
this._onProcessData.fire({ data: `\x1bc${secondData}`, trackCommit: false });
|
|
656
|
+
}
|
|
657
|
+
this._dataListener.value = this._activeProcess.onProcessData(e => this._onProcessData.fire(e));
|
|
658
|
+
this._firstRecorder = this._secondRecorder;
|
|
659
|
+
this._firstDisposable.value = this._secondDisposable.value;
|
|
660
|
+
this._secondRecorder = undefined;
|
|
661
|
+
}
|
|
662
|
+
_stopRecording() {
|
|
663
|
+
if (this._swapTimeout) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
this._firstRecorder = undefined;
|
|
667
|
+
this._firstDisposable.clear();
|
|
668
|
+
this._secondRecorder = undefined;
|
|
669
|
+
this._secondDisposable.clear();
|
|
670
|
+
}
|
|
671
|
+
_createRecorder(process) {
|
|
672
|
+
const recorder = ( new TerminalRecorder(0, 0));
|
|
673
|
+
const disposable = process.onProcessData(e => recorder.handleData(isString(e) ? e : e.data));
|
|
674
|
+
return [recorder, disposable];
|
|
675
|
+
}
|
|
676
|
+
_getDataFromRecorder(recorder) {
|
|
677
|
+
return ( recorder.generateReplayEventSync().events.filter(e => !!e.data).map(e => e.data)).join('');
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
SeamlessRelaunchDataFilter = ( __decorate([
|
|
681
|
+
( __param(0, ITerminalLogService))
|
|
682
|
+
], SeamlessRelaunchDataFilter));
|
|
683
|
+
|
|
684
|
+
export { TerminalProcessManager };
|