@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,2338 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { isFirefox } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/browser';
|
|
4
|
+
import { BrowserFeatures } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/canIUse';
|
|
5
|
+
import { DataTransfers } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dnd';
|
|
6
|
+
import { isAncestorOfActiveElement, createElement, getWindow, Dimension, addDisposableListener, DragAndDropObserver, getActiveWindow, disposableWindowInterval, isHTMLElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
7
|
+
import { StandardKeyboardEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/keyboardEvent';
|
|
8
|
+
import { Orientation } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/sash/sash';
|
|
9
|
+
import { DomScrollableElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
|
|
10
|
+
import { AutoOpenBarrier, Promises, disposableTimeout, timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
11
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
12
|
+
import { debounce } from '@codingame/monaco-vscode-api/vscode/vs/base/common/decorators';
|
|
13
|
+
import { onUnexpectedError, BugIndicatingError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
14
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
15
|
+
import { KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
16
|
+
import { template } from '@codingame/monaco-vscode-api/vscode/vs/base/common/labels';
|
|
17
|
+
import { Disposable, MutableDisposable, ImmortalReference, DisposableMap, toDisposable, DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
18
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
19
|
+
import { win32, basename, resolve } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
|
|
20
|
+
import { OS, isMacintosh, isWindows, OperatingSystem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
21
|
+
import { ScrollbarVisibility } from '@codingame/monaco-vscode-api/vscode/vs/base/common/scrollable';
|
|
22
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
23
|
+
import { TabFocus } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/config/tabFocus';
|
|
24
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
25
|
+
import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
26
|
+
import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
27
|
+
import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
28
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
29
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
30
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
31
|
+
import { containsDragType, CodeDataTransfers, getPathForFile } from '@codingame/monaco-vscode-api/vscode/vs/platform/dnd/browser/dnd';
|
|
32
|
+
import { FileSystemProviderCapabilities } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
33
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
34
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
35
|
+
import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
36
|
+
import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
37
|
+
import { ResultKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingResolver';
|
|
38
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
39
|
+
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
40
|
+
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
41
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
42
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
43
|
+
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
44
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
45
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
46
|
+
import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
47
|
+
import { TerminalCapabilityStoreMultiplexer } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
|
48
|
+
import { deserializeEnvironmentVariableCollections } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/environmentVariableShared';
|
|
49
|
+
import { PosixShellType, GeneralShellType, TitleEventSource, TerminalSettingId, ShellIntegrationStatus, TerminalExitReason, ProcessPropertyType, TerminalLocation, WindowsShellType } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
50
|
+
import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
|
|
51
|
+
import { formatMessageForTerminal } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminalStrings';
|
|
52
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
|
|
53
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
|
|
54
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
55
|
+
import { editorBackground } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
|
|
56
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
|
|
57
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
|
|
58
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
|
|
59
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
60
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
|
|
61
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
62
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
|
|
63
|
+
import { getIconRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/iconRegistry';
|
|
64
|
+
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
65
|
+
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
66
|
+
import { IWorkspaceTrustRequestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
|
|
67
|
+
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
|
|
68
|
+
import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views';
|
|
69
|
+
import { IViewDescriptorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views.service';
|
|
70
|
+
import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
|
|
71
|
+
import { AccessibilityVerbositySettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
|
|
72
|
+
import { TerminalDataTransfers } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal';
|
|
73
|
+
import { ITerminalConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
|
|
74
|
+
import { TerminalLaunchHelpAction } from './terminalActions.js';
|
|
75
|
+
import { TerminalEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalEditorInput';
|
|
76
|
+
import { TerminalExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalExtensions';
|
|
77
|
+
import { getStandardColors, createColorStyleElement, getColorClass } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalIcon';
|
|
78
|
+
import { TerminalProcessManager } from './terminalProcessManager.js';
|
|
79
|
+
import { TerminalStatusList, TerminalStatus } from './terminalStatusList.js';
|
|
80
|
+
import { getTerminalUri, getTerminalResourcesFromDragEvent } from '@codingame/monaco-vscode-xterm-addons-common/vscode/vs/workbench/contrib/terminal/browser/terminalUri';
|
|
81
|
+
import { TerminalWidgetManager } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/widgets/widgetManager';
|
|
82
|
+
import { LineDataEventAddon } from './xterm/lineDataEventAddon.js';
|
|
83
|
+
import { getXtermScaledDimensions, XtermTerminal } from '@codingame/monaco-vscode-xterm-addons-common/vscode/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal';
|
|
84
|
+
import { ProcessState, TERMINAL_VIEW_ID, TERMINAL_CREATION_COMMANDS, TerminalCommandId, DEFAULT_COMMANDS_TO_SKIP_SHELL } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal';
|
|
85
|
+
import { ITerminalProfileResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service';
|
|
86
|
+
import { TERMINAL_BACKGROUND_COLOR } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
|
87
|
+
import { TerminalContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalContextKey';
|
|
88
|
+
import { getShellIntegrationTimeout, preparePathForShell, getUriLabelForShell, getWorkspaceForTerminal } from '../common/terminalEnvironment.js';
|
|
89
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
90
|
+
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
91
|
+
import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
|
|
92
|
+
import { isHorizontal } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
93
|
+
import { IWorkbenchLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
94
|
+
import { IPathService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/path/common/pathService.service';
|
|
95
|
+
import { IPreferencesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/preferences/common/preferences.service';
|
|
96
|
+
import { AccessibilityCommandId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/common/accessibilityCommands';
|
|
97
|
+
import { terminalStrings } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalStrings';
|
|
98
|
+
import { TerminalIconPicker } from './terminalIconPicker.js';
|
|
99
|
+
import { TerminalResizeDebouncer } from './terminalResizeDebouncer.js';
|
|
100
|
+
import { openContextMenu } from './terminalContextMenu.js';
|
|
101
|
+
import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
|
|
102
|
+
import { TerminalContribCommandId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/terminalContribExports';
|
|
103
|
+
import { refreshShellIntegrationInfoStatus } from './terminalTooltip.js';
|
|
104
|
+
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
105
|
+
import { PromptInputState } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel';
|
|
106
|
+
import { isString, hasKey, isNumber } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
107
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
108
|
+
|
|
109
|
+
var TerminalInstance_1;
|
|
110
|
+
var Constants;
|
|
111
|
+
(function (Constants) {
|
|
112
|
+
Constants[Constants["WaitForContainerThreshold"] = 100] = "WaitForContainerThreshold";
|
|
113
|
+
Constants[Constants["DefaultCols"] = 80] = "DefaultCols";
|
|
114
|
+
Constants[Constants["DefaultRows"] = 30] = "DefaultRows";
|
|
115
|
+
Constants[Constants["MaxCanvasWidth"] = 4096] = "MaxCanvasWidth";
|
|
116
|
+
})(Constants || (Constants = {}));
|
|
117
|
+
let xtermConstructor;
|
|
118
|
+
const shellIntegrationSupportedShellTypes = [
|
|
119
|
+
PosixShellType.Bash,
|
|
120
|
+
PosixShellType.Zsh,
|
|
121
|
+
GeneralShellType.PowerShell,
|
|
122
|
+
GeneralShellType.Python,
|
|
123
|
+
];
|
|
124
|
+
let TerminalInstance = class TerminalInstance extends Disposable {
|
|
125
|
+
static { TerminalInstance_1 = this; }
|
|
126
|
+
static { this._instanceIdCounter = 1; }
|
|
127
|
+
get xtermReadyPromise() { return this._xtermReadyPromise; }
|
|
128
|
+
get domElement() { return this._wrapperElement; }
|
|
129
|
+
get usedShellIntegrationInjection() { return this._usedShellIntegrationInjection; }
|
|
130
|
+
get shellIntegrationInjectionFailureReason() { return this._shellIntegrationInjectionInfo; }
|
|
131
|
+
get store() {
|
|
132
|
+
return this._store;
|
|
133
|
+
}
|
|
134
|
+
get extEnvironmentVariableCollection() { return this._processManager.extEnvironmentVariableCollection; }
|
|
135
|
+
get waitOnExit() { return this._shellLaunchConfig.attachPersistentProcess?.waitOnExit || this._shellLaunchConfig.waitOnExit; }
|
|
136
|
+
set waitOnExit(value) {
|
|
137
|
+
this._shellLaunchConfig.waitOnExit = value;
|
|
138
|
+
}
|
|
139
|
+
get targetRef() { return this._targetRef; }
|
|
140
|
+
get target() { return this._targetRef.object; }
|
|
141
|
+
set target(value) {
|
|
142
|
+
this._targetRef.object = value;
|
|
143
|
+
this._onDidChangeTarget.fire(value);
|
|
144
|
+
}
|
|
145
|
+
get instanceId() { return this._instanceId; }
|
|
146
|
+
get resource() { return this._resource; }
|
|
147
|
+
get cols() {
|
|
148
|
+
if (this._fixedCols !== undefined) {
|
|
149
|
+
return this._fixedCols;
|
|
150
|
+
}
|
|
151
|
+
if (this._dimensionsOverride && this._dimensionsOverride.cols) {
|
|
152
|
+
if (this._dimensionsOverride.forceExactSize) {
|
|
153
|
+
return this._dimensionsOverride.cols;
|
|
154
|
+
}
|
|
155
|
+
return Math.min(Math.max(this._dimensionsOverride.cols, 2), this._cols);
|
|
156
|
+
}
|
|
157
|
+
return this._cols;
|
|
158
|
+
}
|
|
159
|
+
get rows() {
|
|
160
|
+
if (this._fixedRows !== undefined) {
|
|
161
|
+
return this._fixedRows;
|
|
162
|
+
}
|
|
163
|
+
if (this._dimensionsOverride && this._dimensionsOverride.rows) {
|
|
164
|
+
if (this._dimensionsOverride.forceExactSize) {
|
|
165
|
+
return this._dimensionsOverride.rows;
|
|
166
|
+
}
|
|
167
|
+
return Math.min(Math.max(this._dimensionsOverride.rows, 2), this._rows);
|
|
168
|
+
}
|
|
169
|
+
return this._rows;
|
|
170
|
+
}
|
|
171
|
+
get isDisposed() { return this._store.isDisposed; }
|
|
172
|
+
get fixedCols() { return this._fixedCols; }
|
|
173
|
+
get fixedRows() { return this._fixedRows; }
|
|
174
|
+
get maxCols() { return this._cols; }
|
|
175
|
+
get maxRows() { return this._rows; }
|
|
176
|
+
get processId() { return this._processManager.shellProcessId; }
|
|
177
|
+
get processReady() { return this._processManager.ptyProcessReady; }
|
|
178
|
+
get hasChildProcesses() { return this.shellLaunchConfig.attachPersistentProcess?.hasChildProcesses || this._processManager.hasChildProcesses; }
|
|
179
|
+
get reconnectionProperties() { return this.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties || this.shellLaunchConfig.reconnectionProperties; }
|
|
180
|
+
get areLinksReady() { return this._areLinksReady; }
|
|
181
|
+
get initialDataEvents() { return this._initialDataEvents; }
|
|
182
|
+
get exitCode() { return this._exitCode; }
|
|
183
|
+
get exitReason() { return this._exitReason; }
|
|
184
|
+
get hadFocusOnExit() { return this._hadFocusOnExit; }
|
|
185
|
+
get isTitleSetByProcess() { return !!this._messageTitleDisposable.value; }
|
|
186
|
+
get shellLaunchConfig() { return this._shellLaunchConfig; }
|
|
187
|
+
get shellType() { return this._shellType; }
|
|
188
|
+
get os() { return this._processManager.os; }
|
|
189
|
+
get hasRemoteAuthority() { return this._processManager.remoteAuthority !== undefined; }
|
|
190
|
+
get remoteAuthority() { return this._processManager.remoteAuthority; }
|
|
191
|
+
get hasFocus() { return isAncestorOfActiveElement(this._wrapperElement); }
|
|
192
|
+
get title() { return this._title; }
|
|
193
|
+
get titleSource() { return this._titleSource; }
|
|
194
|
+
get icon() { return this._getIcon(); }
|
|
195
|
+
get color() { return this._getColor(); }
|
|
196
|
+
get processName() { return this._processName; }
|
|
197
|
+
get sequence() { return this._sequence; }
|
|
198
|
+
get staticTitle() { return this._staticTitle; }
|
|
199
|
+
get progressState() { return this.xterm?.progressState; }
|
|
200
|
+
get workspaceFolder() { return this._workspaceFolder; }
|
|
201
|
+
get cwd() { return this._cwd; }
|
|
202
|
+
get initialCwd() { return this._initialCwd; }
|
|
203
|
+
get description() {
|
|
204
|
+
if (this._description) {
|
|
205
|
+
return this._description;
|
|
206
|
+
}
|
|
207
|
+
const type = this.shellLaunchConfig.attachPersistentProcess?.type || this.shellLaunchConfig.type;
|
|
208
|
+
switch (type) {
|
|
209
|
+
case 'Task': return terminalStrings.typeTask;
|
|
210
|
+
case 'Local': return terminalStrings.typeLocal;
|
|
211
|
+
default: return undefined;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
get userHome() { return this._userHome; }
|
|
215
|
+
get shellIntegrationNonce() { return this._processManager.shellIntegrationNonce; }
|
|
216
|
+
get injectedArgs() { return this._injectedArgs; }
|
|
217
|
+
constructor(_terminalShellTypeContextKey, _shellLaunchConfig, _contextKeyService, _contextMenuService, instantiationService, _terminalConfigurationService, _terminalProfileResolverService, _pathService, _fileService, _keybindingService, _notificationService, _preferencesService, _viewsService, _themeService, _configurationService, _logService, _storageService, _accessibilityService, _productService, _quickInputService, _workbenchEnvironmentService, _workspaceContextService, _editorService, _workspaceTrustRequestService, _historyService, _telemetryService, _openerService, _commandService, _accessibilitySignalService, _viewDescriptorService) {
|
|
218
|
+
super();
|
|
219
|
+
this._terminalShellTypeContextKey = _terminalShellTypeContextKey;
|
|
220
|
+
this._shellLaunchConfig = _shellLaunchConfig;
|
|
221
|
+
this._contextKeyService = _contextKeyService;
|
|
222
|
+
this._contextMenuService = _contextMenuService;
|
|
223
|
+
this._terminalConfigurationService = _terminalConfigurationService;
|
|
224
|
+
this._terminalProfileResolverService = _terminalProfileResolverService;
|
|
225
|
+
this._pathService = _pathService;
|
|
226
|
+
this._fileService = _fileService;
|
|
227
|
+
this._keybindingService = _keybindingService;
|
|
228
|
+
this._notificationService = _notificationService;
|
|
229
|
+
this._preferencesService = _preferencesService;
|
|
230
|
+
this._viewsService = _viewsService;
|
|
231
|
+
this._themeService = _themeService;
|
|
232
|
+
this._configurationService = _configurationService;
|
|
233
|
+
this._logService = _logService;
|
|
234
|
+
this._storageService = _storageService;
|
|
235
|
+
this._accessibilityService = _accessibilityService;
|
|
236
|
+
this._productService = _productService;
|
|
237
|
+
this._quickInputService = _quickInputService;
|
|
238
|
+
this._workbenchEnvironmentService = _workbenchEnvironmentService;
|
|
239
|
+
this._workspaceContextService = _workspaceContextService;
|
|
240
|
+
this._editorService = _editorService;
|
|
241
|
+
this._workspaceTrustRequestService = _workspaceTrustRequestService;
|
|
242
|
+
this._historyService = _historyService;
|
|
243
|
+
this._telemetryService = _telemetryService;
|
|
244
|
+
this._openerService = _openerService;
|
|
245
|
+
this._commandService = _commandService;
|
|
246
|
+
this._accessibilitySignalService = _accessibilitySignalService;
|
|
247
|
+
this._viewDescriptorService = _viewDescriptorService;
|
|
248
|
+
this._contributions = ( new Map());
|
|
249
|
+
this._latestXtermWriteData = 0;
|
|
250
|
+
this._latestXtermParseData = 0;
|
|
251
|
+
this._title = '';
|
|
252
|
+
this._titleSource = TitleEventSource.Process;
|
|
253
|
+
this._cols = 0;
|
|
254
|
+
this._rows = 0;
|
|
255
|
+
this._cwd = undefined;
|
|
256
|
+
this._initialCwd = undefined;
|
|
257
|
+
this._injectedArgs = undefined;
|
|
258
|
+
this._layoutSettingsChanged = true;
|
|
259
|
+
this._areLinksReady = false;
|
|
260
|
+
this._initialDataEventsListener = this._register(( new MutableDisposable()));
|
|
261
|
+
this._initialDataEvents = [];
|
|
262
|
+
this._messageTitleDisposable = this._register(( new MutableDisposable()));
|
|
263
|
+
this._dndObserver = this._register(( new MutableDisposable()));
|
|
264
|
+
this._processName = '';
|
|
265
|
+
this._usedShellIntegrationInjection = false;
|
|
266
|
+
this.capabilities = this._register(( new TerminalCapabilityStoreMultiplexer()));
|
|
267
|
+
this.disableLayout = false;
|
|
268
|
+
this._targetRef = ( new ImmortalReference(undefined));
|
|
269
|
+
this._onExit = ( new Emitter());
|
|
270
|
+
this.onExit = this._onExit.event;
|
|
271
|
+
this._onDisposed = this._register(( new Emitter()));
|
|
272
|
+
this.onDisposed = this._onDisposed.event;
|
|
273
|
+
this._onProcessIdReady = this._register(( new Emitter()));
|
|
274
|
+
this.onProcessIdReady = this._onProcessIdReady.event;
|
|
275
|
+
this._onProcessReplayComplete = this._register(( new Emitter()));
|
|
276
|
+
this.onProcessReplayComplete = this._onProcessReplayComplete.event;
|
|
277
|
+
this._onTitleChanged = this._register(( new Emitter()));
|
|
278
|
+
this.onTitleChanged = this._onTitleChanged.event;
|
|
279
|
+
this._onIconChanged = this._register(( new Emitter()));
|
|
280
|
+
this.onIconChanged = this._onIconChanged.event;
|
|
281
|
+
this._onWillData = this._register(( new Emitter()));
|
|
282
|
+
this.onWillData = this._onWillData.event;
|
|
283
|
+
this._onData = this._register(( new Emitter()));
|
|
284
|
+
this.onData = this._onData.event;
|
|
285
|
+
this._onBinary = this._register(( new Emitter()));
|
|
286
|
+
this.onBinary = this._onBinary.event;
|
|
287
|
+
this._onRequestExtHostProcess = this._register(( new Emitter()));
|
|
288
|
+
this.onRequestExtHostProcess = this._onRequestExtHostProcess.event;
|
|
289
|
+
this._onDimensionsChanged = this._register(( new Emitter()));
|
|
290
|
+
this.onDimensionsChanged = this._onDimensionsChanged.event;
|
|
291
|
+
this._onMaximumDimensionsChanged = this._register(( new Emitter()));
|
|
292
|
+
this.onMaximumDimensionsChanged = this._onMaximumDimensionsChanged.event;
|
|
293
|
+
this._onDidFocus = this._register(( new Emitter()));
|
|
294
|
+
this.onDidFocus = this._onDidFocus.event;
|
|
295
|
+
this._onDidRequestFocus = this._register(( new Emitter()));
|
|
296
|
+
this.onDidRequestFocus = this._onDidRequestFocus.event;
|
|
297
|
+
this._onDidBlur = this._register(( new Emitter()));
|
|
298
|
+
this.onDidBlur = this._onDidBlur.event;
|
|
299
|
+
this._onDidInputData = this._register(( new Emitter()));
|
|
300
|
+
this.onDidInputData = this._onDidInputData.event;
|
|
301
|
+
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
302
|
+
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
303
|
+
this._onRequestAddInstanceToGroup = this._register(( new Emitter()));
|
|
304
|
+
this.onRequestAddInstanceToGroup = this._onRequestAddInstanceToGroup.event;
|
|
305
|
+
this._onDidChangeHasChildProcesses = this._register(( new Emitter()));
|
|
306
|
+
this.onDidChangeHasChildProcesses = this._onDidChangeHasChildProcesses.event;
|
|
307
|
+
this._onDidExecuteText = this._register(( new Emitter()));
|
|
308
|
+
this.onDidExecuteText = this._onDidExecuteText.event;
|
|
309
|
+
this._onDidChangeTarget = this._register(( new Emitter()));
|
|
310
|
+
this.onDidChangeTarget = this._onDidChangeTarget.event;
|
|
311
|
+
this._onDidSendText = this._register(( new Emitter()));
|
|
312
|
+
this.onDidSendText = this._onDidSendText.event;
|
|
313
|
+
this._onDidChangeShellType = this._register(( new Emitter()));
|
|
314
|
+
this.onDidChangeShellType = this._onDidChangeShellType.event;
|
|
315
|
+
this._onDidChangeVisibility = this._register(( new Emitter()));
|
|
316
|
+
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
317
|
+
this._onLineData = this._register(( new Emitter({
|
|
318
|
+
onDidAddFirstListener: async () => (this.xterm ?? (await this._xtermReadyPromise))?.raw.loadAddon(this._lineDataEventAddon)
|
|
319
|
+
})));
|
|
320
|
+
this.onLineData = this._onLineData.event;
|
|
321
|
+
this.sessionId = generateUuid();
|
|
322
|
+
this._wrapperElement = createElement('div');
|
|
323
|
+
this._wrapperElement.classList.add('terminal-wrapper');
|
|
324
|
+
this._widgetManager = this._register(instantiationService.createInstance(TerminalWidgetManager));
|
|
325
|
+
this._skipTerminalCommands = [];
|
|
326
|
+
this._isExiting = false;
|
|
327
|
+
this._hadFocusOnExit = false;
|
|
328
|
+
this._isVisible = false;
|
|
329
|
+
this._instanceId = TerminalInstance_1._instanceIdCounter++;
|
|
330
|
+
this._hasHadInput = false;
|
|
331
|
+
this._fixedRows = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.rows;
|
|
332
|
+
this._fixedCols = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.cols;
|
|
333
|
+
this._shellLaunchConfig.shellIntegrationEnvironmentReporting = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnvironmentReporting);
|
|
334
|
+
this._resource = getTerminalUri(this._workspaceContextService.getWorkspace().id, this.instanceId, this.title);
|
|
335
|
+
if (this._shellLaunchConfig.attachPersistentProcess?.hideFromUser) {
|
|
336
|
+
this._shellLaunchConfig.hideFromUser = this._shellLaunchConfig.attachPersistentProcess.hideFromUser;
|
|
337
|
+
}
|
|
338
|
+
if (this._shellLaunchConfig.attachPersistentProcess?.isFeatureTerminal) {
|
|
339
|
+
this._shellLaunchConfig.isFeatureTerminal = this._shellLaunchConfig.attachPersistentProcess.isFeatureTerminal;
|
|
340
|
+
}
|
|
341
|
+
if (this._shellLaunchConfig.attachPersistentProcess?.type) {
|
|
342
|
+
this._shellLaunchConfig.type = this._shellLaunchConfig.attachPersistentProcess.type;
|
|
343
|
+
}
|
|
344
|
+
if (this._shellLaunchConfig.attachPersistentProcess?.tabActions) {
|
|
345
|
+
this._shellLaunchConfig.tabActions = this._shellLaunchConfig.attachPersistentProcess.tabActions;
|
|
346
|
+
}
|
|
347
|
+
if (this.shellLaunchConfig.cwd) {
|
|
348
|
+
const cwdUri = isString(this._shellLaunchConfig.cwd) ? ( URI.from({
|
|
349
|
+
scheme: Schemas.file,
|
|
350
|
+
path: this._shellLaunchConfig.cwd
|
|
351
|
+
})) : this._shellLaunchConfig.cwd;
|
|
352
|
+
if (cwdUri) {
|
|
353
|
+
this._workspaceFolder = this._workspaceContextService.getWorkspaceFolder(cwdUri) ?? undefined;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (!this._workspaceFolder) {
|
|
357
|
+
const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
|
|
358
|
+
this._workspaceFolder = activeWorkspaceRootUri ? this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
|
|
359
|
+
}
|
|
360
|
+
const scopedContextKeyService = this._register(_contextKeyService.createScoped(this._wrapperElement));
|
|
361
|
+
this._scopedContextKeyService = scopedContextKeyService;
|
|
362
|
+
this._scopedInstantiationService = this._register(instantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService]))));
|
|
363
|
+
this._terminalFocusContextKey = TerminalContextKeys.focus.bindTo(scopedContextKeyService);
|
|
364
|
+
this._terminalHasFixedWidth = TerminalContextKeys.terminalHasFixedWidth.bindTo(scopedContextKeyService);
|
|
365
|
+
this._terminalHasTextContextKey = TerminalContextKeys.textSelected.bindTo(this._contextKeyService);
|
|
366
|
+
this._terminalAltBufferActiveContextKey = TerminalContextKeys.altBufferActive.bindTo(scopedContextKeyService);
|
|
367
|
+
this._terminalShellIntegrationEnabledContextKey = TerminalContextKeys.terminalShellIntegrationEnabled.bindTo(scopedContextKeyService);
|
|
368
|
+
this._logService.trace(`terminalInstance#ctor (instanceId: ${this.instanceId})`, this._shellLaunchConfig);
|
|
369
|
+
this._register(this.capabilities.onDidAddCapability(e => this._logService.debug('terminalInstance added capability', e.id)));
|
|
370
|
+
this._register(this.capabilities.onDidRemoveCapability(e => this._logService.debug('terminalInstance removed capability', e.id)));
|
|
371
|
+
const capabilityListeners = this._register(( new DisposableMap()));
|
|
372
|
+
this._register(this.capabilities.onDidAddCapability(e => {
|
|
373
|
+
capabilityListeners.get(e.id)?.dispose();
|
|
374
|
+
const refreshInfo = () => {
|
|
375
|
+
this._labelComputer?.refreshLabel(this);
|
|
376
|
+
refreshShellIntegrationInfoStatus(this);
|
|
377
|
+
};
|
|
378
|
+
switch (e.id) {
|
|
379
|
+
case TerminalCapability.CwdDetection: {
|
|
380
|
+
capabilityListeners.set(e.id, e.capability.onDidChangeCwd(e => {
|
|
381
|
+
this._cwd = e;
|
|
382
|
+
this._setTitle(this.title, TitleEventSource.Config);
|
|
383
|
+
}));
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
case TerminalCapability.CommandDetection: {
|
|
387
|
+
e.capability.promptInputModel.setShellType(this.shellType);
|
|
388
|
+
capabilityListeners.set(e.id, Event.any(e.capability.promptInputModel.onDidStartInput, e.capability.promptInputModel.onDidChangeInput, e.capability.promptInputModel.onDidFinishInput)(refreshInfo));
|
|
389
|
+
this._register(e.capability.onCommandExecuted(async (command) => {
|
|
390
|
+
if (!command.id && command.command) {
|
|
391
|
+
const commandId = generateUuid();
|
|
392
|
+
this.xterm?.shellIntegration.setNextCommandId(command.command, commandId);
|
|
393
|
+
await this._processManager.setNextCommandId(command.command, commandId);
|
|
394
|
+
}
|
|
395
|
+
}));
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
case TerminalCapability.PromptTypeDetection: {
|
|
399
|
+
capabilityListeners.set(e.id, e.capability.onPromptTypeChanged(refreshInfo));
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}));
|
|
404
|
+
this._register(this.onDidChangeShellType(() => refreshShellIntegrationInfoStatus(this)));
|
|
405
|
+
this._register(this.capabilities.onDidRemoveCapability(e => {
|
|
406
|
+
capabilityListeners.get(e.id)?.dispose();
|
|
407
|
+
}));
|
|
408
|
+
if (!this.shellLaunchConfig.executable && !this._workbenchEnvironmentService.remoteAuthority) {
|
|
409
|
+
this._terminalProfileResolverService.resolveIcon(this._shellLaunchConfig, OS);
|
|
410
|
+
}
|
|
411
|
+
this._icon = _shellLaunchConfig.attachPersistentProcess?.icon || _shellLaunchConfig.icon;
|
|
412
|
+
if (this.shellLaunchConfig.customPtyImplementation) {
|
|
413
|
+
this._setTitle(this._shellLaunchConfig.name, TitleEventSource.Api);
|
|
414
|
+
}
|
|
415
|
+
this.statusList = this._register(this._scopedInstantiationService.createInstance(TerminalStatusList));
|
|
416
|
+
this._initDimensions();
|
|
417
|
+
this._processManager = this._createProcessManager();
|
|
418
|
+
this._containerReadyBarrier = ( new AutoOpenBarrier(Constants.WaitForContainerThreshold));
|
|
419
|
+
this._attachBarrier = ( new AutoOpenBarrier(1000));
|
|
420
|
+
this._xtermReadyPromise = this._createXterm();
|
|
421
|
+
this._xtermReadyPromise.then(async () => {
|
|
422
|
+
await this._containerReadyBarrier.wait();
|
|
423
|
+
let os;
|
|
424
|
+
if (!this.shellLaunchConfig.customPtyImplementation && this._terminalConfigurationService.config.shellIntegration?.enabled && !this.shellLaunchConfig.executable) {
|
|
425
|
+
os = await this._processManager.getBackendOS();
|
|
426
|
+
const defaultProfile = (await this._terminalProfileResolverService.getDefaultProfile({ remoteAuthority: this.remoteAuthority, os }));
|
|
427
|
+
this.shellLaunchConfig.executable = defaultProfile.path;
|
|
428
|
+
this.shellLaunchConfig.args = defaultProfile.args;
|
|
429
|
+
this.shellLaunchConfig.icon ??= defaultProfile.icon;
|
|
430
|
+
this.shellLaunchConfig.color ??= defaultProfile.color;
|
|
431
|
+
this.shellLaunchConfig.env ??= defaultProfile.env;
|
|
432
|
+
}
|
|
433
|
+
if (os && this.shellLaunchConfig.executable) {
|
|
434
|
+
this.setShellType(guessShellTypeFromExecutable(os, this.shellLaunchConfig.executable));
|
|
435
|
+
}
|
|
436
|
+
await this._createProcess();
|
|
437
|
+
if (this.shellLaunchConfig.attachPersistentProcess) {
|
|
438
|
+
this._cwd = this.shellLaunchConfig.attachPersistentProcess.cwd;
|
|
439
|
+
this._setTitle(this.shellLaunchConfig.attachPersistentProcess.title, this.shellLaunchConfig.attachPersistentProcess.titleSource);
|
|
440
|
+
this.setShellType(this.shellType);
|
|
441
|
+
}
|
|
442
|
+
if (this._fixedCols) {
|
|
443
|
+
await this._addScrollbar();
|
|
444
|
+
}
|
|
445
|
+
}).catch((err) => {
|
|
446
|
+
if (!this.isDisposed) {
|
|
447
|
+
throw err;
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
this._register(this._configurationService.onDidChangeConfiguration(async (e) => {
|
|
451
|
+
if (e.affectsConfiguration(AccessibilityVerbositySettingId.Terminal)) {
|
|
452
|
+
this._setAriaLabel(this.xterm?.raw, this._instanceId, this.title);
|
|
453
|
+
}
|
|
454
|
+
if (e.affectsConfiguration('terminal.integrated')) {
|
|
455
|
+
this.updateConfig();
|
|
456
|
+
this.setVisible(this._isVisible);
|
|
457
|
+
}
|
|
458
|
+
const layoutSettings = [
|
|
459
|
+
TerminalSettingId.FontSize,
|
|
460
|
+
TerminalSettingId.FontFamily,
|
|
461
|
+
TerminalSettingId.FontWeight,
|
|
462
|
+
TerminalSettingId.FontWeightBold,
|
|
463
|
+
TerminalSettingId.LetterSpacing,
|
|
464
|
+
TerminalSettingId.LineHeight,
|
|
465
|
+
'editor.fontFamily'
|
|
466
|
+
];
|
|
467
|
+
if (( layoutSettings.some(id => e.affectsConfiguration(id)))) {
|
|
468
|
+
this._layoutSettingsChanged = true;
|
|
469
|
+
await this._resize();
|
|
470
|
+
}
|
|
471
|
+
if (e.affectsConfiguration(TerminalSettingId.UnicodeVersion)) {
|
|
472
|
+
this._updateUnicodeVersion();
|
|
473
|
+
}
|
|
474
|
+
if (e.affectsConfiguration('editor.accessibilitySupport')) {
|
|
475
|
+
this.updateAccessibilitySupport();
|
|
476
|
+
}
|
|
477
|
+
if (e.affectsConfiguration(TerminalSettingId.TerminalTitle) ||
|
|
478
|
+
e.affectsConfiguration(TerminalSettingId.TerminalTitleSeparator) ||
|
|
479
|
+
e.affectsConfiguration(TerminalSettingId.TerminalDescription)) {
|
|
480
|
+
this._labelComputer?.refreshLabel(this);
|
|
481
|
+
}
|
|
482
|
+
}));
|
|
483
|
+
this._register(this._workspaceContextService.onDidChangeWorkspaceFolders(() => this._labelComputer?.refreshLabel(this)));
|
|
484
|
+
let initialDataEventsTimeout = getWindow(this._container).setTimeout(() => {
|
|
485
|
+
initialDataEventsTimeout = undefined;
|
|
486
|
+
this._initialDataEvents = undefined;
|
|
487
|
+
this._initialDataEventsListener.clear();
|
|
488
|
+
}, 10000);
|
|
489
|
+
this._register(toDisposable(() => {
|
|
490
|
+
if (initialDataEventsTimeout) {
|
|
491
|
+
getWindow(this._container).clearTimeout(initialDataEventsTimeout);
|
|
492
|
+
}
|
|
493
|
+
}));
|
|
494
|
+
const contributionDescs = TerminalExtensionsRegistry.getTerminalContributions();
|
|
495
|
+
for (const desc of contributionDescs) {
|
|
496
|
+
if (( this._contributions.has(desc.id))) {
|
|
497
|
+
onUnexpectedError(( new Error(`Cannot have two terminal contributions with the same id ${desc.id}`)));
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
let contribution;
|
|
501
|
+
try {
|
|
502
|
+
contribution = this._register(this._scopedInstantiationService.createInstance(desc.ctor, {
|
|
503
|
+
instance: this,
|
|
504
|
+
processManager: this._processManager,
|
|
505
|
+
widgetManager: this._widgetManager
|
|
506
|
+
}));
|
|
507
|
+
this._contributions.set(desc.id, contribution);
|
|
508
|
+
}
|
|
509
|
+
catch (err) {
|
|
510
|
+
onUnexpectedError(err);
|
|
511
|
+
}
|
|
512
|
+
this._xtermReadyPromise.then(xterm => {
|
|
513
|
+
if (xterm) {
|
|
514
|
+
contribution.xtermReady?.(xterm);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
this._register(this.onDisposed(() => {
|
|
518
|
+
contribution.dispose();
|
|
519
|
+
this._contributions.delete(desc.id);
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
getContribution(id) {
|
|
524
|
+
return this._contributions.get(id);
|
|
525
|
+
}
|
|
526
|
+
async _handleOnData(data) {
|
|
527
|
+
await this._processManager.write(data);
|
|
528
|
+
this._onDidInputData.fire(data);
|
|
529
|
+
}
|
|
530
|
+
_getIcon() {
|
|
531
|
+
if (!this._icon) {
|
|
532
|
+
this._icon = this._processManager.processState >= ProcessState.Launching
|
|
533
|
+
? getIconRegistry().getIcon(this._configurationService.getValue(TerminalSettingId.TabsDefaultIcon))
|
|
534
|
+
: undefined;
|
|
535
|
+
}
|
|
536
|
+
return this._icon;
|
|
537
|
+
}
|
|
538
|
+
_getColor() {
|
|
539
|
+
if (this.shellLaunchConfig.color) {
|
|
540
|
+
return this.shellLaunchConfig.color;
|
|
541
|
+
}
|
|
542
|
+
if (this.shellLaunchConfig?.attachPersistentProcess?.color) {
|
|
543
|
+
return this.shellLaunchConfig.attachPersistentProcess.color;
|
|
544
|
+
}
|
|
545
|
+
if (this._processManager.processState >= ProcessState.Launching) {
|
|
546
|
+
return undefined;
|
|
547
|
+
}
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
550
|
+
_initDimensions() {
|
|
551
|
+
if (!this._container) {
|
|
552
|
+
this._cols = Constants.DefaultCols;
|
|
553
|
+
this._rows = Constants.DefaultRows;
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const computedStyle = getWindow(this._container).getComputedStyle(this._container);
|
|
557
|
+
const width = parseInt(computedStyle.width);
|
|
558
|
+
const height = parseInt(computedStyle.height);
|
|
559
|
+
this._evaluateColsAndRows(width, height);
|
|
560
|
+
}
|
|
561
|
+
_evaluateColsAndRows(width, height) {
|
|
562
|
+
if (!width || !height) {
|
|
563
|
+
this._setLastKnownColsAndRows();
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
const dimension = this._getDimension(width, height);
|
|
567
|
+
if (!dimension) {
|
|
568
|
+
this._setLastKnownColsAndRows();
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
const font = this.xterm ? this.xterm.getFont() : this._terminalConfigurationService.getFont(getWindow(this.domElement));
|
|
572
|
+
const newRC = getXtermScaledDimensions(getWindow(this.domElement), font, dimension.width, dimension.height);
|
|
573
|
+
if (!newRC) {
|
|
574
|
+
this._setLastKnownColsAndRows();
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
if (this._cols !== newRC.cols || this._rows !== newRC.rows) {
|
|
578
|
+
this._cols = newRC.cols;
|
|
579
|
+
this._rows = newRC.rows;
|
|
580
|
+
this._fireMaximumDimensionsChanged();
|
|
581
|
+
}
|
|
582
|
+
return dimension.width;
|
|
583
|
+
}
|
|
584
|
+
_setLastKnownColsAndRows() {
|
|
585
|
+
if (TerminalInstance_1._lastKnownGridDimensions) {
|
|
586
|
+
this._cols = TerminalInstance_1._lastKnownGridDimensions.cols;
|
|
587
|
+
this._rows = TerminalInstance_1._lastKnownGridDimensions.rows;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
_fireMaximumDimensionsChanged() {
|
|
591
|
+
this._onMaximumDimensionsChanged.fire();
|
|
592
|
+
}
|
|
593
|
+
_getDimension(width, height) {
|
|
594
|
+
const font = this.xterm ? this.xterm.getFont() : this._terminalConfigurationService.getFont(getWindow(this.domElement));
|
|
595
|
+
if (!font || !font.charWidth || !font.charHeight) {
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
if (!this.xterm?.raw.element) {
|
|
599
|
+
return undefined;
|
|
600
|
+
}
|
|
601
|
+
const computedStyle = getWindow(this.xterm.raw.element).getComputedStyle(this.xterm.raw.element);
|
|
602
|
+
const horizontalPadding = parseInt(computedStyle.paddingLeft) + parseInt(computedStyle.paddingRight) + 14 ;
|
|
603
|
+
const verticalPadding = parseInt(computedStyle.paddingTop) + parseInt(computedStyle.paddingBottom);
|
|
604
|
+
TerminalInstance_1._lastKnownCanvasDimensions = new Dimension(Math.min(Constants.MaxCanvasWidth, width - horizontalPadding), height - verticalPadding + (this._hasScrollBar && this._horizontalScrollbar ? -5 : 0));
|
|
605
|
+
return TerminalInstance_1._lastKnownCanvasDimensions;
|
|
606
|
+
}
|
|
607
|
+
get persistentProcessId() { return this._processManager.persistentProcessId; }
|
|
608
|
+
get shouldPersist() { return this._processManager.shouldPersist && !this.shellLaunchConfig.isTransient && (!this.reconnectionProperties || this._configurationService.getValue('task.reconnection') === true); }
|
|
609
|
+
static getXtermConstructor(keybindingService, contextKeyService) {
|
|
610
|
+
const keybinding = keybindingService.lookupKeybinding(TerminalContribCommandId.A11yFocusAccessibleBuffer, contextKeyService);
|
|
611
|
+
if (xtermConstructor) {
|
|
612
|
+
return xtermConstructor;
|
|
613
|
+
}
|
|
614
|
+
xtermConstructor = Promises.withAsyncBody(async (resolve) => {
|
|
615
|
+
const Terminal = (await import('@xterm/xterm').then(module => module.default ?? module)).Terminal;
|
|
616
|
+
Terminal.strings.promptLabel = ( localize(11547, 'Terminal input'));
|
|
617
|
+
Terminal.strings.tooMuchOutput = keybinding ? ( localize(
|
|
618
|
+
11548,
|
|
619
|
+
'Use the accessible buffer {0} to manually review output',
|
|
620
|
+
keybinding.getLabel()
|
|
621
|
+
)) : ( localize(
|
|
622
|
+
11549,
|
|
623
|
+
'Use the Terminal: Focus Accessible Buffer command to manually review output'
|
|
624
|
+
));
|
|
625
|
+
resolve(Terminal);
|
|
626
|
+
});
|
|
627
|
+
return xtermConstructor;
|
|
628
|
+
}
|
|
629
|
+
async _createXterm() {
|
|
630
|
+
const Terminal = await TerminalInstance_1.getXtermConstructor(this._keybindingService, this._contextKeyService);
|
|
631
|
+
if (this.isDisposed) {
|
|
632
|
+
return undefined;
|
|
633
|
+
}
|
|
634
|
+
const disableShellIntegrationReporting = (this.shellLaunchConfig.executable === undefined || this.shellType === undefined) || !shellIntegrationSupportedShellTypes.includes(this.shellType);
|
|
635
|
+
const xterm = this._scopedInstantiationService.createInstance(XtermTerminal, this._resource, Terminal, {
|
|
636
|
+
cols: this._cols,
|
|
637
|
+
rows: this._rows,
|
|
638
|
+
xtermColorProvider: this._scopedInstantiationService.createInstance(TerminalInstanceColorProvider, this._targetRef),
|
|
639
|
+
capabilities: this.capabilities,
|
|
640
|
+
shellIntegrationNonce: this._processManager.shellIntegrationNonce,
|
|
641
|
+
disableShellIntegrationReporting,
|
|
642
|
+
}, this.onDidExecuteText);
|
|
643
|
+
this.xterm = xterm;
|
|
644
|
+
this._resizeDebouncer = this._register(( new TerminalResizeDebouncer(() => this._isVisible, () => xterm, async (cols, rows) => {
|
|
645
|
+
xterm.resize(cols, rows);
|
|
646
|
+
await this._updatePtyDimensions(xterm.raw);
|
|
647
|
+
}, async (cols) => {
|
|
648
|
+
xterm.resize(cols, xterm.raw.rows);
|
|
649
|
+
await this._updatePtyDimensions(xterm.raw);
|
|
650
|
+
}, async (rows) => {
|
|
651
|
+
xterm.resize(xterm.raw.cols, rows);
|
|
652
|
+
await this._updatePtyDimensions(xterm.raw);
|
|
653
|
+
})));
|
|
654
|
+
this._register(toDisposable(() => this._resizeDebouncer = undefined));
|
|
655
|
+
this.updateAccessibilitySupport();
|
|
656
|
+
this._register(this.xterm.onDidRequestRunCommand(e => {
|
|
657
|
+
this.sendText(e.command.command, e.noNewLine ? false : true);
|
|
658
|
+
}));
|
|
659
|
+
this._register(this.xterm.onDidRequestRefreshDimensions(() => {
|
|
660
|
+
if (this._lastLayoutDimensions) {
|
|
661
|
+
this.layout(this._lastLayoutDimensions);
|
|
662
|
+
}
|
|
663
|
+
}));
|
|
664
|
+
const initialTextWrittenPromise = this._shellLaunchConfig.initialText ? ( new Promise(r => this._writeInitialText(xterm, r))) : undefined;
|
|
665
|
+
const lineDataEventAddon = this._register(( new LineDataEventAddon(initialTextWrittenPromise)));
|
|
666
|
+
this._register(lineDataEventAddon.onLineData(e => this._onLineData.fire(e)));
|
|
667
|
+
this._lineDataEventAddon = lineDataEventAddon;
|
|
668
|
+
disposableTimeout(() => {
|
|
669
|
+
this._register(xterm.raw.onBell(() => {
|
|
670
|
+
if (this._configurationService.getValue(TerminalSettingId.EnableBell) || this._configurationService.getValue(TerminalSettingId.EnableVisualBell)) {
|
|
671
|
+
this.statusList.add({
|
|
672
|
+
id: TerminalStatus.Bell,
|
|
673
|
+
severity: Severity.Warning,
|
|
674
|
+
icon: Codicon.bell,
|
|
675
|
+
tooltip: ( localize(11550, "Bell"))
|
|
676
|
+
}, this._terminalConfigurationService.config.bellDuration);
|
|
677
|
+
}
|
|
678
|
+
this._accessibilitySignalService.playSignal(AccessibilitySignal.terminalBell);
|
|
679
|
+
}));
|
|
680
|
+
}, 1000, this._store);
|
|
681
|
+
this._register(xterm.raw.onSelectionChange(() => this._onDidChangeSelection.fire(this)));
|
|
682
|
+
this._register(xterm.raw.buffer.onBufferChange(() => this._refreshAltBufferContextKey()));
|
|
683
|
+
this._register(this._processManager.onProcessData(e => this._onProcessData(e)));
|
|
684
|
+
this._register(xterm.raw.onData(async (data) => {
|
|
685
|
+
await this._handleOnData(data);
|
|
686
|
+
}));
|
|
687
|
+
this._register(xterm.raw.onBinary(data => this._processManager.processBinary(data)));
|
|
688
|
+
this._register(this._processManager.onProcessReady(async (processTraits) => {
|
|
689
|
+
if (processTraits?.windowsPty?.backend === 'conpty') {
|
|
690
|
+
this._register(xterm.raw.parser.registerCsiHandler({ final: 'c' }, params => {
|
|
691
|
+
if (params.length === 0 || params.length === 1 && params[0] === 0) {
|
|
692
|
+
this._handleOnData('\x1b[?61;4c');
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
return false;
|
|
696
|
+
}));
|
|
697
|
+
}
|
|
698
|
+
if (this._processManager.os) {
|
|
699
|
+
lineDataEventAddon.setOperatingSystem(this._processManager.os);
|
|
700
|
+
}
|
|
701
|
+
xterm.raw.options.windowsPty = processTraits.windowsPty;
|
|
702
|
+
}));
|
|
703
|
+
this._register(this._processManager.onRestoreCommands(e => this.xterm?.shellIntegration.deserialize(e)));
|
|
704
|
+
this._register(this._viewDescriptorService.onDidChangeLocation(({ views }) => {
|
|
705
|
+
if (( views.some(v => v.id === TERMINAL_VIEW_ID))) {
|
|
706
|
+
xterm.refresh();
|
|
707
|
+
}
|
|
708
|
+
}));
|
|
709
|
+
this._register(xterm.onDidChangeProgress(() => this._labelComputer?.refreshLabel(this)));
|
|
710
|
+
this._register(Event.runAndSubscribe(xterm.shellIntegration.onDidChangeSeenSequences, () => {
|
|
711
|
+
if (xterm.shellIntegration.seenSequences.size > 0) {
|
|
712
|
+
refreshShellIntegrationInfoStatus(this);
|
|
713
|
+
}
|
|
714
|
+
}));
|
|
715
|
+
if (!( this.capabilities.has(TerminalCapability.CwdDetection))) {
|
|
716
|
+
let onKeyListener = xterm.raw.onKey(e => {
|
|
717
|
+
const event = ( new StandardKeyboardEvent(e.domEvent));
|
|
718
|
+
if (event.equals(KeyCode.Enter)) {
|
|
719
|
+
this._updateProcessCwd();
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
this._register(this.capabilities.onDidAddCwdDetectionCapability(() => {
|
|
723
|
+
onKeyListener?.dispose();
|
|
724
|
+
onKeyListener = undefined;
|
|
725
|
+
}));
|
|
726
|
+
}
|
|
727
|
+
if (this.xterm?.shellIntegration) {
|
|
728
|
+
this.capabilities.add(this.xterm.shellIntegration.capabilities);
|
|
729
|
+
}
|
|
730
|
+
this._pathService.userHome().then(userHome => {
|
|
731
|
+
this._userHome = userHome.fsPath;
|
|
732
|
+
});
|
|
733
|
+
if (this._isVisible) {
|
|
734
|
+
this._open();
|
|
735
|
+
}
|
|
736
|
+
return xterm;
|
|
737
|
+
}
|
|
738
|
+
async runCommand(commandLine, shouldExecute, commandId) {
|
|
739
|
+
let commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
|
|
740
|
+
const siInjectionEnabled = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled) === true;
|
|
741
|
+
const timeoutMs = getShellIntegrationTimeout(this._configurationService, siInjectionEnabled, this.hasRemoteAuthority, this._processManager.processReadyTimestamp);
|
|
742
|
+
if (!commandDetection || commandDetection.promptInputModel.state !== PromptInputState.Input) {
|
|
743
|
+
const store = ( new DisposableStore());
|
|
744
|
+
await Promise.race([
|
|
745
|
+
( new Promise(r => {
|
|
746
|
+
store.add(this.capabilities.onDidAddCommandDetectionCapability(e => {
|
|
747
|
+
commandDetection = e;
|
|
748
|
+
if (commandDetection.promptInputModel.state === PromptInputState.Input) {
|
|
749
|
+
r();
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
store.add(commandDetection.promptInputModel.onDidStartInput(() => {
|
|
753
|
+
r();
|
|
754
|
+
}));
|
|
755
|
+
}
|
|
756
|
+
}));
|
|
757
|
+
})),
|
|
758
|
+
timeout(timeoutMs)
|
|
759
|
+
]);
|
|
760
|
+
store.dispose();
|
|
761
|
+
}
|
|
762
|
+
if (commandId && commandDetection) {
|
|
763
|
+
this.xterm?.shellIntegration.setNextCommandId(commandLine, commandId);
|
|
764
|
+
await this._processManager.setNextCommandId(commandLine, commandId);
|
|
765
|
+
}
|
|
766
|
+
if (!commandDetection || commandDetection.promptInputModel.value.length > 0) {
|
|
767
|
+
await this.sendText('\x03', false);
|
|
768
|
+
await timeout(100);
|
|
769
|
+
}
|
|
770
|
+
await this.sendText(commandLine, shouldExecute, !shouldExecute);
|
|
771
|
+
}
|
|
772
|
+
detachFromElement() {
|
|
773
|
+
this._wrapperElement.remove();
|
|
774
|
+
this._container = undefined;
|
|
775
|
+
}
|
|
776
|
+
attachToElement(container) {
|
|
777
|
+
if (this._container === container) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if (!this._attachBarrier.isOpen()) {
|
|
781
|
+
this._attachBarrier.open();
|
|
782
|
+
}
|
|
783
|
+
this._container = container;
|
|
784
|
+
this._container.appendChild(this._wrapperElement);
|
|
785
|
+
if (this.xterm?.raw.element) {
|
|
786
|
+
this.xterm.raw.open(this.xterm.raw.element);
|
|
787
|
+
}
|
|
788
|
+
this.xterm?.refresh();
|
|
789
|
+
setTimeout(() => {
|
|
790
|
+
if (this._store.isDisposed) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
this._initDragAndDrop(container);
|
|
794
|
+
}, 0);
|
|
795
|
+
}
|
|
796
|
+
_open() {
|
|
797
|
+
if (!this.xterm || this.xterm.raw.element) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
if (!this._container || !this._container.isConnected) {
|
|
801
|
+
throw ( new Error(
|
|
802
|
+
'A container element needs to be set with `attachToElement` and be part of the DOM before calling `_open`'
|
|
803
|
+
));
|
|
804
|
+
}
|
|
805
|
+
const xtermElement = createElement('div');
|
|
806
|
+
this._wrapperElement.appendChild(xtermElement);
|
|
807
|
+
this._container.appendChild(this._wrapperElement);
|
|
808
|
+
const xterm = this.xterm;
|
|
809
|
+
this._wrapperElement.xterm = xterm.raw;
|
|
810
|
+
const screenElement = xterm.attachToElement(xtermElement);
|
|
811
|
+
for (const contribution of ( this._contributions.values())) {
|
|
812
|
+
if (!this.xterm) {
|
|
813
|
+
this._xtermReadyPromise.then(xterm => {
|
|
814
|
+
if (xterm) {
|
|
815
|
+
contribution.xtermOpen?.(xterm);
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
contribution.xtermOpen?.(this.xterm);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
this._register(xterm.shellIntegration.onDidChangeStatus(() => {
|
|
824
|
+
if (this.hasFocus) {
|
|
825
|
+
this._setShellIntegrationContextKey();
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
this._terminalShellIntegrationEnabledContextKey.reset();
|
|
829
|
+
}
|
|
830
|
+
}));
|
|
831
|
+
if (!xterm.raw.element || !xterm.raw.textarea) {
|
|
832
|
+
throw ( new Error('xterm elements not set after open'));
|
|
833
|
+
}
|
|
834
|
+
this._setAriaLabel(xterm.raw, this._instanceId, this._title);
|
|
835
|
+
xterm.raw.attachCustomKeyEventHandler((event) => {
|
|
836
|
+
if (this._isExiting) {
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
const standardKeyboardEvent = ( new StandardKeyboardEvent(event));
|
|
840
|
+
const resolveResult = this._keybindingService.softDispatch(standardKeyboardEvent, standardKeyboardEvent.target);
|
|
841
|
+
const isValidChord = resolveResult.kind === ResultKind.MoreChordsNeeded && this._terminalConfigurationService.config.allowChords && event.key !== 'Escape';
|
|
842
|
+
if (this._keybindingService.inChordMode || isValidChord) {
|
|
843
|
+
event.preventDefault();
|
|
844
|
+
return false;
|
|
845
|
+
}
|
|
846
|
+
const SHOW_TERMINAL_CONFIG_PROMPT_KEY = 'terminal.integrated.showTerminalConfigPrompt';
|
|
847
|
+
const EXCLUDED_KEYS = ['RightArrow', 'LeftArrow', 'UpArrow', 'DownArrow', 'Space', 'Meta', 'Control', 'Shift', 'Alt', '', 'Delete', 'Backspace', 'Tab'];
|
|
848
|
+
if (this._storageService.getBoolean(SHOW_TERMINAL_CONFIG_PROMPT_KEY, StorageScope.APPLICATION, true) &&
|
|
849
|
+
!EXCLUDED_KEYS.includes(event.key) &&
|
|
850
|
+
!event.ctrlKey &&
|
|
851
|
+
!event.shiftKey &&
|
|
852
|
+
!event.altKey) {
|
|
853
|
+
this._hasHadInput = true;
|
|
854
|
+
}
|
|
855
|
+
if (resolveResult.kind === ResultKind.KbFound && resolveResult.commandId && ( this._skipTerminalCommands.some(k => k === resolveResult.commandId)) && !this._terminalConfigurationService.config.sendKeybindingsToShell) {
|
|
856
|
+
if (this._storageService.getBoolean(SHOW_TERMINAL_CONFIG_PROMPT_KEY, StorageScope.APPLICATION, true) &&
|
|
857
|
+
this._hasHadInput &&
|
|
858
|
+
!TERMINAL_CREATION_COMMANDS.includes(resolveResult.commandId)) {
|
|
859
|
+
this._notificationService.prompt(Severity.Info, ( localize(
|
|
860
|
+
11551,
|
|
861
|
+
"Some keybindings don't go to the terminal by default and are handled by {0} instead.",
|
|
862
|
+
this._productService.nameLong
|
|
863
|
+
)), [
|
|
864
|
+
{
|
|
865
|
+
label: ( localize(11552, "Configure Terminal Settings")),
|
|
866
|
+
run: () => {
|
|
867
|
+
this._preferencesService.openSettings({ jsonEditor: false, query: `@id:${TerminalSettingId.CommandsToSkipShell},${TerminalSettingId.SendKeybindingsToShell},${TerminalSettingId.AllowChords}` });
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
]);
|
|
871
|
+
this._storageService.store(SHOW_TERMINAL_CONFIG_PROMPT_KEY, false, StorageScope.APPLICATION, StorageTarget.USER);
|
|
872
|
+
}
|
|
873
|
+
event.preventDefault();
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
if (this._terminalConfigurationService.config.allowMnemonics && !isMacintosh && event.altKey) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
if (TabFocus.getTabFocusMode() && event.key === 'Tab') {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
883
|
+
event.preventDefault();
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
if (isWindows && event.altKey && event.key === 'F4' && !event.ctrlKey) {
|
|
887
|
+
return false;
|
|
888
|
+
}
|
|
889
|
+
if (!BrowserFeatures.clipboard.readText && event.key === 'v' && event.ctrlKey) {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
return true;
|
|
893
|
+
});
|
|
894
|
+
this._register(addDisposableListener(xterm.raw.element, 'mousedown', () => {
|
|
895
|
+
const listener = addDisposableListener(xterm.raw.element.ownerDocument, 'mouseup', () => {
|
|
896
|
+
setTimeout(() => this._refreshSelectionContextKey(), 0);
|
|
897
|
+
listener.dispose();
|
|
898
|
+
});
|
|
899
|
+
}));
|
|
900
|
+
this._register(addDisposableListener(xterm.raw.element, 'touchstart', () => {
|
|
901
|
+
xterm.raw.focus();
|
|
902
|
+
}));
|
|
903
|
+
this._register(addDisposableListener(xterm.raw.element, 'keyup', () => {
|
|
904
|
+
setTimeout(() => this._refreshSelectionContextKey(), 0);
|
|
905
|
+
}));
|
|
906
|
+
this._register(addDisposableListener(xterm.raw.textarea, 'focus', () => this._setFocus(true)));
|
|
907
|
+
this._register(addDisposableListener(xterm.raw.textarea, 'blur', () => this._setFocus(false)));
|
|
908
|
+
this._register(addDisposableListener(xterm.raw.textarea, 'focusout', () => this._setFocus(false)));
|
|
909
|
+
this._initDragAndDrop(this._container);
|
|
910
|
+
this._widgetManager.attachToElement(screenElement);
|
|
911
|
+
if (this._lastLayoutDimensions) {
|
|
912
|
+
this.layout(this._lastLayoutDimensions);
|
|
913
|
+
}
|
|
914
|
+
this.updateConfig();
|
|
915
|
+
if (xterm.raw.options.disableStdin) {
|
|
916
|
+
this._attachPressAnyKeyToCloseListener(xterm.raw);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
_setFocus(focused) {
|
|
920
|
+
if (focused) {
|
|
921
|
+
this._terminalFocusContextKey.set(true);
|
|
922
|
+
this._setShellIntegrationContextKey();
|
|
923
|
+
this._onDidFocus.fire(this);
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
this.resetFocusContextKey();
|
|
927
|
+
this._onDidBlur.fire(this);
|
|
928
|
+
this._refreshSelectionContextKey();
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
_setShellIntegrationContextKey() {
|
|
932
|
+
if (this.xterm) {
|
|
933
|
+
this._terminalShellIntegrationEnabledContextKey.set(this.xterm.shellIntegration.status === ShellIntegrationStatus.VSCode);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
resetFocusContextKey() {
|
|
937
|
+
this._terminalFocusContextKey.reset();
|
|
938
|
+
this._terminalShellIntegrationEnabledContextKey.reset();
|
|
939
|
+
}
|
|
940
|
+
_initDragAndDrop(container) {
|
|
941
|
+
const store = ( new DisposableStore());
|
|
942
|
+
const dndController = store.add(this._scopedInstantiationService.createInstance(TerminalInstanceDragAndDropController, container));
|
|
943
|
+
store.add(dndController.onDropTerminal(e => this._onRequestAddInstanceToGroup.fire(e)));
|
|
944
|
+
store.add(dndController.onDropFile(async (path) => {
|
|
945
|
+
this.focus();
|
|
946
|
+
await this.sendPath(path, false);
|
|
947
|
+
}));
|
|
948
|
+
store.add(new DragAndDropObserver(container, dndController));
|
|
949
|
+
this._dndObserver.value = store;
|
|
950
|
+
}
|
|
951
|
+
hasSelection() {
|
|
952
|
+
return this.xterm ? this.xterm.raw.hasSelection() : false;
|
|
953
|
+
}
|
|
954
|
+
get selection() {
|
|
955
|
+
return this.xterm && this.hasSelection() ? this.xterm.raw.getSelection() : undefined;
|
|
956
|
+
}
|
|
957
|
+
clearSelection() {
|
|
958
|
+
this.xterm?.raw.clearSelection();
|
|
959
|
+
}
|
|
960
|
+
_refreshAltBufferContextKey() {
|
|
961
|
+
this._terminalAltBufferActiveContextKey.set(!!(this.xterm && this.xterm.raw.buffer.active === this.xterm.raw.buffer.alternate));
|
|
962
|
+
}
|
|
963
|
+
dispose(reason) {
|
|
964
|
+
if (this.shellLaunchConfig.type === 'Task' && reason === TerminalExitReason.Process && this._exitCode !== 0 && !this.shellLaunchConfig.waitOnExit) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (this.isDisposed) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
this._logService.trace(`terminalInstance#dispose (instanceId: ${this.instanceId})`);
|
|
971
|
+
dispose(this._widgetManager);
|
|
972
|
+
if (this.xterm?.raw.element) {
|
|
973
|
+
this._hadFocusOnExit = this.hasFocus;
|
|
974
|
+
}
|
|
975
|
+
if (this._wrapperElement.xterm) {
|
|
976
|
+
this._wrapperElement.xterm = undefined;
|
|
977
|
+
}
|
|
978
|
+
if (this._horizontalScrollbar) {
|
|
979
|
+
this._horizontalScrollbar.dispose();
|
|
980
|
+
this._horizontalScrollbar = undefined;
|
|
981
|
+
}
|
|
982
|
+
try {
|
|
983
|
+
this.xterm?.dispose();
|
|
984
|
+
}
|
|
985
|
+
catch (err) {
|
|
986
|
+
this._logService.error('Exception occurred during xterm disposal', err);
|
|
987
|
+
}
|
|
988
|
+
if (isFirefox) {
|
|
989
|
+
this.resetFocusContextKey();
|
|
990
|
+
this._terminalHasTextContextKey.reset();
|
|
991
|
+
this._onDidBlur.fire(this);
|
|
992
|
+
}
|
|
993
|
+
if (this._pressAnyKeyToCloseListener) {
|
|
994
|
+
this._pressAnyKeyToCloseListener.dispose();
|
|
995
|
+
this._pressAnyKeyToCloseListener = undefined;
|
|
996
|
+
}
|
|
997
|
+
if (this._exitReason === undefined) {
|
|
998
|
+
this._exitReason = reason ?? TerminalExitReason.Unknown;
|
|
999
|
+
}
|
|
1000
|
+
this._processManager.dispose();
|
|
1001
|
+
this._onProcessExit(undefined);
|
|
1002
|
+
this._onDisposed.fire(this);
|
|
1003
|
+
super.dispose();
|
|
1004
|
+
}
|
|
1005
|
+
async detachProcessAndDispose(reason) {
|
|
1006
|
+
await this._processManager.detachFromProcess(reason === TerminalExitReason.User);
|
|
1007
|
+
this.dispose(reason);
|
|
1008
|
+
}
|
|
1009
|
+
focus(force) {
|
|
1010
|
+
this._refreshAltBufferContextKey();
|
|
1011
|
+
if (!this.xterm) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (force || !getActiveWindow().getSelection()?.toString()) {
|
|
1015
|
+
this.xterm.raw.focus();
|
|
1016
|
+
this._onDidRequestFocus.fire();
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
async focusWhenReady(force) {
|
|
1020
|
+
await this._xtermReadyPromise;
|
|
1021
|
+
await this._attachBarrier.wait();
|
|
1022
|
+
this.focus(force);
|
|
1023
|
+
}
|
|
1024
|
+
async sendText(text, shouldExecute, bracketedPasteMode) {
|
|
1025
|
+
if (bracketedPasteMode && this.xterm?.raw.modes.bracketedPasteMode) {
|
|
1026
|
+
text = `\x1b[200~${text}\x1b[201~`;
|
|
1027
|
+
}
|
|
1028
|
+
text = text.replace(/\r?\n/g, '\r');
|
|
1029
|
+
if (shouldExecute && !text.endsWith('\r')) {
|
|
1030
|
+
text += '\r';
|
|
1031
|
+
}
|
|
1032
|
+
this._logService.debug('sending data (vscode)', text);
|
|
1033
|
+
await this._processManager.write(text);
|
|
1034
|
+
this._onDidInputData.fire(text);
|
|
1035
|
+
this._onDidSendText.fire(text);
|
|
1036
|
+
this.xterm?.scrollToBottom();
|
|
1037
|
+
if (shouldExecute) {
|
|
1038
|
+
this._onDidExecuteText.fire();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
async sendSignal(signal) {
|
|
1042
|
+
this._logService.debug('sending signal (vscode)', signal);
|
|
1043
|
+
await this._processManager.sendSignal(signal);
|
|
1044
|
+
}
|
|
1045
|
+
async sendPath(originalPath, shouldExecute) {
|
|
1046
|
+
return this.sendText(await this.preparePathForShell(originalPath), shouldExecute);
|
|
1047
|
+
}
|
|
1048
|
+
async preparePathForShell(originalPath) {
|
|
1049
|
+
await this.processReady;
|
|
1050
|
+
return preparePathForShell(originalPath, this.shellLaunchConfig.executable, this.title, this.shellType, this._processManager.backend, this._processManager.os);
|
|
1051
|
+
}
|
|
1052
|
+
async getUriLabelForShell(uri) {
|
|
1053
|
+
await this.processReady;
|
|
1054
|
+
return getUriLabelForShell(uri, this._processManager.backend, this.shellType, this.os);
|
|
1055
|
+
}
|
|
1056
|
+
setVisible(visible) {
|
|
1057
|
+
const didChange = this._isVisible !== visible;
|
|
1058
|
+
this._isVisible = visible;
|
|
1059
|
+
this._wrapperElement.classList.toggle('active', visible);
|
|
1060
|
+
if (visible && this.xterm) {
|
|
1061
|
+
this._open();
|
|
1062
|
+
this._resizeDebouncer?.flush();
|
|
1063
|
+
this._resize();
|
|
1064
|
+
}
|
|
1065
|
+
if (didChange) {
|
|
1066
|
+
this._onDidChangeVisibility.fire(visible);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
scrollDownLine() {
|
|
1070
|
+
this.xterm?.scrollDownLine();
|
|
1071
|
+
}
|
|
1072
|
+
scrollDownPage() {
|
|
1073
|
+
this.xterm?.scrollDownPage();
|
|
1074
|
+
}
|
|
1075
|
+
scrollToBottom() {
|
|
1076
|
+
this.xterm?.scrollToBottom();
|
|
1077
|
+
}
|
|
1078
|
+
scrollUpLine() {
|
|
1079
|
+
this.xterm?.scrollUpLine();
|
|
1080
|
+
}
|
|
1081
|
+
scrollUpPage() {
|
|
1082
|
+
this.xterm?.scrollUpPage();
|
|
1083
|
+
}
|
|
1084
|
+
scrollToTop() {
|
|
1085
|
+
this.xterm?.scrollToTop();
|
|
1086
|
+
}
|
|
1087
|
+
clearBuffer() {
|
|
1088
|
+
this._processManager.clearBuffer();
|
|
1089
|
+
this.xterm?.clearBuffer();
|
|
1090
|
+
}
|
|
1091
|
+
_refreshSelectionContextKey() {
|
|
1092
|
+
const isActive = !!this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID);
|
|
1093
|
+
let isEditorActive = false;
|
|
1094
|
+
const editor = this._editorService.activeEditor;
|
|
1095
|
+
if (editor) {
|
|
1096
|
+
isEditorActive = editor instanceof TerminalEditorInput;
|
|
1097
|
+
}
|
|
1098
|
+
this._terminalHasTextContextKey.set((isActive || isEditorActive) && this.hasSelection());
|
|
1099
|
+
}
|
|
1100
|
+
_createProcessManager() {
|
|
1101
|
+
let deserializedCollections;
|
|
1102
|
+
if (this.shellLaunchConfig.attachPersistentProcess?.environmentVariableCollections) {
|
|
1103
|
+
deserializedCollections = deserializeEnvironmentVariableCollections(this.shellLaunchConfig.attachPersistentProcess.environmentVariableCollections);
|
|
1104
|
+
}
|
|
1105
|
+
const processManager = this._scopedInstantiationService.createInstance(TerminalProcessManager, this._instanceId, this.shellLaunchConfig?.cwd, deserializedCollections, this.shellLaunchConfig.shellIntegrationNonce ?? this.shellLaunchConfig.attachPersistentProcess?.shellIntegrationNonce);
|
|
1106
|
+
this.capabilities.add(processManager.capabilities);
|
|
1107
|
+
this._register(processManager.onProcessReady(async (e) => {
|
|
1108
|
+
this._onProcessIdReady.fire(this);
|
|
1109
|
+
this._initialCwd = await this.getInitialCwd();
|
|
1110
|
+
if (!this._labelComputer) {
|
|
1111
|
+
this._labelComputer = this._register(this._scopedInstantiationService.createInstance(TerminalLabelComputer));
|
|
1112
|
+
this._register(this._labelComputer.onDidChangeLabel(e => {
|
|
1113
|
+
const wasChanged = this._title !== e.title || this._description !== e.description;
|
|
1114
|
+
if (wasChanged) {
|
|
1115
|
+
this._title = e.title;
|
|
1116
|
+
this._description = e.description;
|
|
1117
|
+
this._onTitleChanged.fire(this);
|
|
1118
|
+
}
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
if (this._shellLaunchConfig.name) {
|
|
1122
|
+
this._setTitle(this._shellLaunchConfig.name, TitleEventSource.Api);
|
|
1123
|
+
}
|
|
1124
|
+
else {
|
|
1125
|
+
setTimeout(() => {
|
|
1126
|
+
this._xtermReadyPromise.then(xterm => {
|
|
1127
|
+
if (xterm) {
|
|
1128
|
+
this._messageTitleDisposable.value = xterm.raw.onTitleChange(e => this._onTitleChange(e));
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
});
|
|
1132
|
+
this._setTitle(this._shellLaunchConfig.executable, TitleEventSource.Process);
|
|
1133
|
+
}
|
|
1134
|
+
}));
|
|
1135
|
+
this._register(processManager.onProcessExit(exitCode => this._onProcessExit(exitCode)));
|
|
1136
|
+
this._register(processManager.onDidChangeProperty(({ type, value }) => {
|
|
1137
|
+
switch (type) {
|
|
1138
|
+
case ProcessPropertyType.Cwd:
|
|
1139
|
+
this._cwd = value;
|
|
1140
|
+
this._labelComputer?.refreshLabel(this);
|
|
1141
|
+
break;
|
|
1142
|
+
case ProcessPropertyType.InitialCwd:
|
|
1143
|
+
this._initialCwd = value;
|
|
1144
|
+
this._cwd = this._initialCwd;
|
|
1145
|
+
this._setTitle(this.title, TitleEventSource.Config);
|
|
1146
|
+
this._icon = this._shellLaunchConfig.attachPersistentProcess?.icon || this._shellLaunchConfig.icon;
|
|
1147
|
+
this._onIconChanged.fire({ instance: this, userInitiated: false });
|
|
1148
|
+
break;
|
|
1149
|
+
case ProcessPropertyType.Title:
|
|
1150
|
+
this._setTitle(value ?? '', TitleEventSource.Process);
|
|
1151
|
+
break;
|
|
1152
|
+
case ProcessPropertyType.OverrideDimensions:
|
|
1153
|
+
this.setOverrideDimensions(value, true);
|
|
1154
|
+
break;
|
|
1155
|
+
case ProcessPropertyType.ResolvedShellLaunchConfig:
|
|
1156
|
+
this._setResolvedShellLaunchConfig(value);
|
|
1157
|
+
break;
|
|
1158
|
+
case ProcessPropertyType.ShellType:
|
|
1159
|
+
this.setShellType(value);
|
|
1160
|
+
break;
|
|
1161
|
+
case ProcessPropertyType.HasChildProcesses:
|
|
1162
|
+
this._onDidChangeHasChildProcesses.fire(value);
|
|
1163
|
+
break;
|
|
1164
|
+
case ProcessPropertyType.UsedShellIntegrationInjection:
|
|
1165
|
+
this._usedShellIntegrationInjection = true;
|
|
1166
|
+
break;
|
|
1167
|
+
case ProcessPropertyType.ShellIntegrationInjectionFailureReason:
|
|
1168
|
+
this._shellIntegrationInjectionInfo = value;
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
}));
|
|
1172
|
+
this._initialDataEventsListener.value = processManager.onProcessData(ev => this._initialDataEvents?.push(ev.data));
|
|
1173
|
+
this._register(processManager.onProcessReplayComplete(() => this._onProcessReplayComplete.fire()));
|
|
1174
|
+
this._register(processManager.onEnvironmentVariableInfoChanged(e => this._onEnvironmentVariableInfoChanged(e)));
|
|
1175
|
+
this._register(processManager.onPtyDisconnect(() => {
|
|
1176
|
+
if (this.xterm) {
|
|
1177
|
+
this.xterm.raw.options.disableStdin = true;
|
|
1178
|
+
}
|
|
1179
|
+
this.statusList.add({
|
|
1180
|
+
id: TerminalStatus.Disconnected,
|
|
1181
|
+
severity: Severity.Error,
|
|
1182
|
+
icon: Codicon.debugDisconnect,
|
|
1183
|
+
tooltip: ( localize(11553, "Lost connection to process"))
|
|
1184
|
+
});
|
|
1185
|
+
}));
|
|
1186
|
+
this._register(processManager.onPtyReconnect(() => {
|
|
1187
|
+
if (this.xterm) {
|
|
1188
|
+
this.xterm.raw.options.disableStdin = false;
|
|
1189
|
+
}
|
|
1190
|
+
this.statusList.remove(TerminalStatus.Disconnected);
|
|
1191
|
+
}));
|
|
1192
|
+
return processManager;
|
|
1193
|
+
}
|
|
1194
|
+
async _createProcess() {
|
|
1195
|
+
if (this.isDisposed) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
const trusted = await this._trust();
|
|
1199
|
+
if (!trusted && !this.remoteAuthority && !this._workbenchEnvironmentService.remoteAuthority) {
|
|
1200
|
+
this._onProcessExit({ message: ( localize(11554, "Cannot launch a terminal process in an untrusted workspace")) });
|
|
1201
|
+
}
|
|
1202
|
+
else if (this._workspaceContextService.getWorkspace().folders.length === 0 && this._cwd && this._userHome && this._cwd !== this._userHome) {
|
|
1203
|
+
this._onProcessExit({
|
|
1204
|
+
message: ( localize(
|
|
1205
|
+
11555,
|
|
1206
|
+
"Cannot launch a terminal process in an untrusted workspace with cwd {0} and userHome {1}",
|
|
1207
|
+
this._cwd,
|
|
1208
|
+
this._userHome
|
|
1209
|
+
))
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
if (this._container && this._cols === 0 && this._rows === 0) {
|
|
1213
|
+
this._initDimensions();
|
|
1214
|
+
this.xterm?.resize(this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows);
|
|
1215
|
+
}
|
|
1216
|
+
const originalIcon = this.shellLaunchConfig.icon;
|
|
1217
|
+
await this._processManager.createProcess(this._shellLaunchConfig, this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows).then(result => {
|
|
1218
|
+
if (result) {
|
|
1219
|
+
if (hasKey(result, { message: true })) {
|
|
1220
|
+
this._onProcessExit(result);
|
|
1221
|
+
}
|
|
1222
|
+
else if (hasKey(result, { injectedArgs: true })) {
|
|
1223
|
+
this._injectedArgs = result.injectedArgs;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
if (this.isDisposed) {
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
if (originalIcon !== this.shellLaunchConfig.icon || this.shellLaunchConfig.color) {
|
|
1231
|
+
this._icon = this._shellLaunchConfig.attachPersistentProcess?.icon || this._shellLaunchConfig.icon;
|
|
1232
|
+
this._onIconChanged.fire({ instance: this, userInitiated: false });
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
registerMarker(offset) {
|
|
1236
|
+
return this.xterm?.raw.registerMarker(offset);
|
|
1237
|
+
}
|
|
1238
|
+
addBufferMarker(properties) {
|
|
1239
|
+
this.capabilities.get(TerminalCapability.BufferMarkDetection)?.addMark(properties);
|
|
1240
|
+
}
|
|
1241
|
+
scrollToMark(startMarkId, endMarkId, highlight) {
|
|
1242
|
+
this.xterm?.markTracker.scrollToClosestMarker(startMarkId, endMarkId, highlight);
|
|
1243
|
+
}
|
|
1244
|
+
async freePortKillProcess(port, command) {
|
|
1245
|
+
await this._processManager?.freePortKillProcess(port);
|
|
1246
|
+
this.runCommand(command, false);
|
|
1247
|
+
}
|
|
1248
|
+
_onProcessData(ev) {
|
|
1249
|
+
const leadingSegmentedData = [];
|
|
1250
|
+
const matches = ev.data.matchAll(/(?<seq>\x1b\][16]33;(?:C|D(?:;\d+)?)\x07)/g);
|
|
1251
|
+
let i = 0;
|
|
1252
|
+
for (const match of matches) {
|
|
1253
|
+
if (match.groups?.seq === undefined) {
|
|
1254
|
+
throw ( new BugIndicatingError('seq must be defined'));
|
|
1255
|
+
}
|
|
1256
|
+
leadingSegmentedData.push(ev.data.substring(i, match.index));
|
|
1257
|
+
leadingSegmentedData.push(match.groups?.seq ?? '');
|
|
1258
|
+
i = match.index + match[0].length;
|
|
1259
|
+
}
|
|
1260
|
+
const lastData = ev.data.substring(i);
|
|
1261
|
+
for (let i = 0; i < leadingSegmentedData.length; i++) {
|
|
1262
|
+
this._writeProcessData(leadingSegmentedData[i]);
|
|
1263
|
+
}
|
|
1264
|
+
if (ev.trackCommit) {
|
|
1265
|
+
ev.writePromise = ( new Promise(r => this._writeProcessData(lastData, r)));
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
this._writeProcessData(lastData);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
_writeProcessData(data, cb) {
|
|
1272
|
+
this._onWillData.fire(data);
|
|
1273
|
+
const messageId = ++this._latestXtermWriteData;
|
|
1274
|
+
this.xterm?.raw.write(data, () => {
|
|
1275
|
+
this._latestXtermParseData = messageId;
|
|
1276
|
+
this._processManager.acknowledgeDataEvent(data.length);
|
|
1277
|
+
cb?.();
|
|
1278
|
+
this._onData.fire(data);
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
async _onProcessExit(exitCodeOrError) {
|
|
1282
|
+
if (this._isExiting) {
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
const parsedExitResult = parseExitResult(exitCodeOrError, this.shellLaunchConfig, this._processManager.processState, this._initialCwd);
|
|
1286
|
+
if (this._usedShellIntegrationInjection && this._processManager.processState === ProcessState.KilledDuringLaunch && parsedExitResult?.code !== 0) {
|
|
1287
|
+
this._relaunchWithShellIntegrationDisabled(parsedExitResult?.message);
|
|
1288
|
+
this._onExit.fire(exitCodeOrError);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
this._isExiting = true;
|
|
1292
|
+
await this._flushXtermData();
|
|
1293
|
+
this._exitCode = parsedExitResult?.code;
|
|
1294
|
+
const exitMessage = parsedExitResult?.message;
|
|
1295
|
+
this._logService.debug('Terminal process exit', 'instanceId', this.instanceId, 'code', this._exitCode, 'processState', this._processManager.processState);
|
|
1296
|
+
const waitOnExit = this.waitOnExit;
|
|
1297
|
+
if (waitOnExit && this._processManager.processState !== ProcessState.KilledByUser) {
|
|
1298
|
+
this._xtermReadyPromise.then(xterm => {
|
|
1299
|
+
if (!xterm) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (exitMessage) {
|
|
1303
|
+
xterm.raw.write(formatMessageForTerminal(exitMessage));
|
|
1304
|
+
}
|
|
1305
|
+
switch (typeof waitOnExit) {
|
|
1306
|
+
case 'string':
|
|
1307
|
+
xterm.raw.write(formatMessageForTerminal(waitOnExit, { excludeLeadingNewLine: true }));
|
|
1308
|
+
break;
|
|
1309
|
+
case 'function':
|
|
1310
|
+
if (this.exitCode !== undefined) {
|
|
1311
|
+
xterm.raw.write(formatMessageForTerminal(waitOnExit(this.exitCode), { excludeLeadingNewLine: true }));
|
|
1312
|
+
}
|
|
1313
|
+
break;
|
|
1314
|
+
}
|
|
1315
|
+
xterm.raw.options.disableStdin = true;
|
|
1316
|
+
if (xterm.raw.textarea) {
|
|
1317
|
+
this._attachPressAnyKeyToCloseListener(xterm.raw);
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
else {
|
|
1322
|
+
if (exitMessage) {
|
|
1323
|
+
const failedDuringLaunch = this._processManager.processState === ProcessState.KilledDuringLaunch;
|
|
1324
|
+
if (failedDuringLaunch || (this._terminalConfigurationService.config.showExitAlert && this.xterm?.lastInputEvent !== '\x04')) {
|
|
1325
|
+
this._notificationService.notify({
|
|
1326
|
+
message: exitMessage,
|
|
1327
|
+
severity: Severity.Error,
|
|
1328
|
+
actions: { primary: [this._scopedInstantiationService.createInstance(TerminalLaunchHelpAction)] }
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
this._logService.warn(exitMessage);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
this.dispose(TerminalExitReason.Process);
|
|
1336
|
+
}
|
|
1337
|
+
this._onExit.fire(exitCodeOrError);
|
|
1338
|
+
if (this.isDisposed) {
|
|
1339
|
+
this._onExit.dispose();
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
_relaunchWithShellIntegrationDisabled(exitMessage) {
|
|
1343
|
+
this._shellLaunchConfig.ignoreShellIntegration = true;
|
|
1344
|
+
this.relaunch();
|
|
1345
|
+
this.statusList.add({
|
|
1346
|
+
id: TerminalStatus.ShellIntegrationAttentionNeeded,
|
|
1347
|
+
severity: Severity.Warning,
|
|
1348
|
+
icon: Codicon.warning,
|
|
1349
|
+
tooltip: `${exitMessage} ` + ( localize(11556, 'Disabling shell integration in user settings might help.')),
|
|
1350
|
+
hoverActions: [{
|
|
1351
|
+
commandId: TerminalCommandId.ShellIntegrationLearnMore,
|
|
1352
|
+
label: ( localize(11557, "Learn more about shell integration")),
|
|
1353
|
+
run: () => {
|
|
1354
|
+
this._openerService.open('https://code.visualstudio.com/docs/editor/integrated-terminal#_shell-integration');
|
|
1355
|
+
}
|
|
1356
|
+
}, {
|
|
1357
|
+
commandId: 'workbench.action.openSettings',
|
|
1358
|
+
label: ( localize(11558, "Open user settings")),
|
|
1359
|
+
run: () => {
|
|
1360
|
+
this._commandService.executeCommand('workbench.action.openSettings', 'terminal.integrated.shellIntegration.enabled');
|
|
1361
|
+
}
|
|
1362
|
+
}]
|
|
1363
|
+
});
|
|
1364
|
+
this._telemetryService.publicLog2('terminal/shellIntegrationFailureProcessExit');
|
|
1365
|
+
}
|
|
1366
|
+
_flushXtermData() {
|
|
1367
|
+
if (this._latestXtermWriteData === this._latestXtermParseData) {
|
|
1368
|
+
return Promise.resolve();
|
|
1369
|
+
}
|
|
1370
|
+
let retries = 0;
|
|
1371
|
+
return ( new Promise(r => {
|
|
1372
|
+
const interval = disposableWindowInterval(getActiveWindow().window, () => {
|
|
1373
|
+
if (this._latestXtermWriteData === this._latestXtermParseData || ++retries === 5) {
|
|
1374
|
+
interval.dispose();
|
|
1375
|
+
r();
|
|
1376
|
+
}
|
|
1377
|
+
}, 20);
|
|
1378
|
+
}));
|
|
1379
|
+
}
|
|
1380
|
+
_attachPressAnyKeyToCloseListener(xterm) {
|
|
1381
|
+
if (xterm.textarea && !this._pressAnyKeyToCloseListener) {
|
|
1382
|
+
this._pressAnyKeyToCloseListener = addDisposableListener(xterm.textarea, 'keypress', (event) => {
|
|
1383
|
+
if (this._pressAnyKeyToCloseListener) {
|
|
1384
|
+
this._pressAnyKeyToCloseListener.dispose();
|
|
1385
|
+
this._pressAnyKeyToCloseListener = undefined;
|
|
1386
|
+
this.dispose(TerminalExitReason.Process);
|
|
1387
|
+
event.preventDefault();
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
_writeInitialText(xterm, callback) {
|
|
1393
|
+
if (!this._shellLaunchConfig.initialText) {
|
|
1394
|
+
callback?.();
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const text = isString(this._shellLaunchConfig.initialText)
|
|
1398
|
+
? this._shellLaunchConfig.initialText
|
|
1399
|
+
: this._shellLaunchConfig.initialText?.text;
|
|
1400
|
+
if (isString(this._shellLaunchConfig.initialText)) {
|
|
1401
|
+
xterm.raw.writeln(text, callback);
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
if (this._shellLaunchConfig.initialText.trailingNewLine) {
|
|
1405
|
+
xterm.raw.writeln(text, callback);
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
xterm.raw.write(text, callback);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
async reuseTerminal(shell, reset = false) {
|
|
1413
|
+
this._pressAnyKeyToCloseListener?.dispose();
|
|
1414
|
+
this._pressAnyKeyToCloseListener = undefined;
|
|
1415
|
+
const xterm = this.xterm;
|
|
1416
|
+
if (xterm) {
|
|
1417
|
+
if (!reset) {
|
|
1418
|
+
await ( new Promise(r => xterm.raw.write('\n\x1b[G', r)));
|
|
1419
|
+
}
|
|
1420
|
+
if (shell.initialText) {
|
|
1421
|
+
this._shellLaunchConfig.initialText = shell.initialText;
|
|
1422
|
+
await ( new Promise(r => this._writeInitialText(xterm, r)));
|
|
1423
|
+
}
|
|
1424
|
+
if (this._isExiting && this._shellLaunchConfig.waitOnExit) {
|
|
1425
|
+
xterm.raw.options.disableStdin = false;
|
|
1426
|
+
this._isExiting = false;
|
|
1427
|
+
}
|
|
1428
|
+
if (reset) {
|
|
1429
|
+
xterm.clearDecorations();
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
this.statusList.remove(TerminalStatus.RelaunchNeeded);
|
|
1433
|
+
if (!reset) {
|
|
1434
|
+
shell.initialText = ' ';
|
|
1435
|
+
}
|
|
1436
|
+
this._shellLaunchConfig = shell;
|
|
1437
|
+
await this._processManager.relaunch(this._shellLaunchConfig, this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows, reset).then(result => {
|
|
1438
|
+
if (result) {
|
|
1439
|
+
if (hasKey(result, { message: true })) {
|
|
1440
|
+
this._onProcessExit(result);
|
|
1441
|
+
}
|
|
1442
|
+
else if (hasKey(result, { injectedArgs: true })) {
|
|
1443
|
+
this._injectedArgs = result.injectedArgs;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
relaunch() {
|
|
1449
|
+
const shellLaunchConfig = { ...this._shellLaunchConfig };
|
|
1450
|
+
delete shellLaunchConfig.attachPersistentProcess;
|
|
1451
|
+
this.reuseTerminal(shellLaunchConfig, true);
|
|
1452
|
+
}
|
|
1453
|
+
_onTitleChange(title) {
|
|
1454
|
+
if (this.isTitleSetByProcess) {
|
|
1455
|
+
this._setTitle(title, TitleEventSource.Sequence);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
async _trust() {
|
|
1459
|
+
return (await this._workspaceTrustRequestService.requestWorkspaceTrust({
|
|
1460
|
+
message: ( localize(11559, "Creating a terminal process requires executing code"))
|
|
1461
|
+
})) === true;
|
|
1462
|
+
}
|
|
1463
|
+
async _updateProcessCwd() {
|
|
1464
|
+
if (this.isDisposed || this.shellLaunchConfig.customPtyImplementation) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
try {
|
|
1468
|
+
const cwd = await this._refreshProperty(ProcessPropertyType.Cwd);
|
|
1469
|
+
if (!isString(cwd)) {
|
|
1470
|
+
throw ( new Error(`cwd is not a string ${cwd}`));
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
catch (e) {
|
|
1474
|
+
if (e instanceof Error && e.message === 'Cannot refresh property when process is not set') {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
throw e;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
updateConfig() {
|
|
1481
|
+
this._setCommandsToSkipShell(this._terminalConfigurationService.config.commandsToSkipShell);
|
|
1482
|
+
this._refreshEnvironmentVariableInfoWidgetState(this._processManager.environmentVariableInfo);
|
|
1483
|
+
}
|
|
1484
|
+
async _updateUnicodeVersion() {
|
|
1485
|
+
this._processManager.setUnicodeVersion(this._terminalConfigurationService.config.unicodeVersion);
|
|
1486
|
+
}
|
|
1487
|
+
updateAccessibilitySupport() {
|
|
1488
|
+
this.xterm.raw.options.screenReaderMode = this._accessibilityService.isScreenReaderOptimized();
|
|
1489
|
+
}
|
|
1490
|
+
_setCommandsToSkipShell(commands) {
|
|
1491
|
+
const excludeCommands = ( commands.filter(command => command[0] === '-').map(command => command.slice(1)));
|
|
1492
|
+
this._skipTerminalCommands = DEFAULT_COMMANDS_TO_SKIP_SHELL.filter(defaultCommand => {
|
|
1493
|
+
return !excludeCommands.includes(defaultCommand);
|
|
1494
|
+
}).concat(commands);
|
|
1495
|
+
}
|
|
1496
|
+
layout(dimension) {
|
|
1497
|
+
this._lastLayoutDimensions = dimension;
|
|
1498
|
+
if (this.disableLayout) {
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
if (dimension.width <= 0 || dimension.height <= 0) {
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
const terminalWidth = this._evaluateColsAndRows(dimension.width, dimension.height);
|
|
1505
|
+
if (!terminalWidth) {
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
this._resize();
|
|
1509
|
+
if (!this._containerReadyBarrier.isOpen()) {
|
|
1510
|
+
this._containerReadyBarrier.open();
|
|
1511
|
+
}
|
|
1512
|
+
for (const contribution of ( this._contributions.values())) {
|
|
1513
|
+
if (!this.xterm) {
|
|
1514
|
+
this._xtermReadyPromise.then(xterm => {
|
|
1515
|
+
if (xterm) {
|
|
1516
|
+
contribution.layout?.(xterm, dimension);
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
contribution.layout?.(this.xterm, dimension);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
async _resize(immediate) {
|
|
1526
|
+
if (!this.xterm) {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
let cols = this.cols;
|
|
1530
|
+
let rows = this.rows;
|
|
1531
|
+
if (this._isVisible && this._layoutSettingsChanged) {
|
|
1532
|
+
const font = this.xterm.getFont();
|
|
1533
|
+
const config = this._terminalConfigurationService.config;
|
|
1534
|
+
this.xterm.raw.options.letterSpacing = font.letterSpacing;
|
|
1535
|
+
this.xterm.raw.options.lineHeight = font.lineHeight;
|
|
1536
|
+
this.xterm.raw.options.fontSize = font.fontSize;
|
|
1537
|
+
this.xterm.raw.options.fontFamily = font.fontFamily;
|
|
1538
|
+
this.xterm.raw.options.fontWeight = config.fontWeight;
|
|
1539
|
+
this.xterm.raw.options.fontWeightBold = config.fontWeightBold;
|
|
1540
|
+
this._initDimensions();
|
|
1541
|
+
cols = this.cols;
|
|
1542
|
+
rows = this.rows;
|
|
1543
|
+
this._layoutSettingsChanged = false;
|
|
1544
|
+
}
|
|
1545
|
+
if (isNaN(cols) || isNaN(rows)) {
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
if (cols !== this.xterm.raw.cols || rows !== this.xterm.raw.rows) {
|
|
1549
|
+
if (this._fixedRows || this._fixedCols) {
|
|
1550
|
+
await this._updateProperty(ProcessPropertyType.FixedDimensions, { cols: this._fixedCols, rows: this._fixedRows });
|
|
1551
|
+
}
|
|
1552
|
+
this._onDimensionsChanged.fire();
|
|
1553
|
+
}
|
|
1554
|
+
TerminalInstance_1._lastKnownGridDimensions = { cols, rows };
|
|
1555
|
+
this._resizeDebouncer.resize(cols, rows, immediate ?? false);
|
|
1556
|
+
}
|
|
1557
|
+
async _updatePtyDimensions(rawXterm) {
|
|
1558
|
+
await this._processManager.setDimensions(rawXterm.cols, rawXterm.rows);
|
|
1559
|
+
}
|
|
1560
|
+
setShellType(shellType) {
|
|
1561
|
+
if (this._shellType === shellType) {
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
this._shellType = shellType;
|
|
1565
|
+
if (shellType === undefined) {
|
|
1566
|
+
this._terminalShellTypeContextKey.reset();
|
|
1567
|
+
}
|
|
1568
|
+
else {
|
|
1569
|
+
this._terminalShellTypeContextKey.set(shellType?.toString());
|
|
1570
|
+
}
|
|
1571
|
+
this._onDidChangeShellType.fire(shellType);
|
|
1572
|
+
}
|
|
1573
|
+
_setAriaLabel(xterm, terminalId, title) {
|
|
1574
|
+
const labelParts = [];
|
|
1575
|
+
if (xterm && xterm.textarea) {
|
|
1576
|
+
if (title && title.length > 0) {
|
|
1577
|
+
labelParts.push(( localize(11560, "Terminal {0}, {1}", terminalId, title)));
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
labelParts.push(( localize(11561, "Terminal {0}", terminalId)));
|
|
1581
|
+
}
|
|
1582
|
+
const screenReaderOptimized = this._accessibilityService.isScreenReaderOptimized();
|
|
1583
|
+
if (!screenReaderOptimized) {
|
|
1584
|
+
labelParts.push(( localize(
|
|
1585
|
+
11562,
|
|
1586
|
+
"Run the command: Toggle Screen Reader Accessibility Mode for an optimized screen reader experience"
|
|
1587
|
+
)));
|
|
1588
|
+
}
|
|
1589
|
+
const accessibilityHelpKeybinding = this._keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
|
|
1590
|
+
if (this._configurationService.getValue(AccessibilityVerbositySettingId.Terminal) && accessibilityHelpKeybinding) {
|
|
1591
|
+
labelParts.push(( localize(
|
|
1592
|
+
11563,
|
|
1593
|
+
"Use {0} for terminal accessibility help",
|
|
1594
|
+
accessibilityHelpKeybinding
|
|
1595
|
+
)));
|
|
1596
|
+
}
|
|
1597
|
+
xterm.textarea.setAttribute('aria-label', labelParts.join('\n'));
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
_updateTitleProperties(title, eventSource) {
|
|
1601
|
+
if (!title) {
|
|
1602
|
+
return this._processName;
|
|
1603
|
+
}
|
|
1604
|
+
switch (eventSource) {
|
|
1605
|
+
case TitleEventSource.Process:
|
|
1606
|
+
if (this._processManager.os === OperatingSystem.Windows) {
|
|
1607
|
+
title = win32.parse(title).name;
|
|
1608
|
+
}
|
|
1609
|
+
else {
|
|
1610
|
+
const firstSpaceIndex = title.indexOf(' ');
|
|
1611
|
+
if (title.startsWith('/')) {
|
|
1612
|
+
title = basename(title);
|
|
1613
|
+
}
|
|
1614
|
+
else if (firstSpaceIndex > -1) {
|
|
1615
|
+
title = title.substring(0, firstSpaceIndex);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
this._processName = title;
|
|
1619
|
+
break;
|
|
1620
|
+
case TitleEventSource.Api:
|
|
1621
|
+
this._staticTitle = title;
|
|
1622
|
+
this._messageTitleDisposable.value = undefined;
|
|
1623
|
+
break;
|
|
1624
|
+
case TitleEventSource.Sequence:
|
|
1625
|
+
this._sequence = title;
|
|
1626
|
+
if (this._processManager.os === OperatingSystem.Windows &&
|
|
1627
|
+
title.match(/^[a-zA-Z]:\\.+\.[a-zA-Z]{1,3}/)) {
|
|
1628
|
+
this._sequence = win32.parse(title).name;
|
|
1629
|
+
}
|
|
1630
|
+
break;
|
|
1631
|
+
}
|
|
1632
|
+
this._titleSource = eventSource;
|
|
1633
|
+
return title;
|
|
1634
|
+
}
|
|
1635
|
+
setOverrideDimensions(dimensions, immediate = false) {
|
|
1636
|
+
if (this._dimensionsOverride && this._dimensionsOverride.forceExactSize && !dimensions && this._rows === 0 && this._cols === 0) {
|
|
1637
|
+
this._cols = this._dimensionsOverride.cols;
|
|
1638
|
+
this._rows = this._dimensionsOverride.rows;
|
|
1639
|
+
}
|
|
1640
|
+
this._dimensionsOverride = dimensions;
|
|
1641
|
+
if (immediate) {
|
|
1642
|
+
this._resize(true);
|
|
1643
|
+
}
|
|
1644
|
+
else {
|
|
1645
|
+
this._resize();
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
async setFixedDimensions() {
|
|
1649
|
+
const cols = await this._quickInputService.input({
|
|
1650
|
+
title: ( localize(11564, "Set Fixed Dimensions: Column")),
|
|
1651
|
+
placeHolder: 'Enter a number of columns or leave empty for automatic width',
|
|
1652
|
+
validateInput: async (text) => text.length > 0 && !text.match(/^\d+$/) ? { content: 'Enter a number or leave empty size automatically', severity: Severity.Error } : undefined
|
|
1653
|
+
});
|
|
1654
|
+
if (cols === undefined) {
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
this._fixedCols = this._parseFixedDimension(cols);
|
|
1658
|
+
this._labelComputer?.refreshLabel(this);
|
|
1659
|
+
this._terminalHasFixedWidth.set(!!this._fixedCols);
|
|
1660
|
+
const rows = await this._quickInputService.input({
|
|
1661
|
+
title: ( localize(11565, "Set Fixed Dimensions: Row")),
|
|
1662
|
+
placeHolder: 'Enter a number of rows or leave empty for automatic height',
|
|
1663
|
+
validateInput: async (text) => text.length > 0 && !text.match(/^\d+$/) ? { content: 'Enter a number or leave empty size automatically', severity: Severity.Error } : undefined
|
|
1664
|
+
});
|
|
1665
|
+
if (rows === undefined) {
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
this._fixedRows = this._parseFixedDimension(rows);
|
|
1669
|
+
this._labelComputer?.refreshLabel(this);
|
|
1670
|
+
await this._refreshScrollbar();
|
|
1671
|
+
this._resize();
|
|
1672
|
+
this.focus();
|
|
1673
|
+
}
|
|
1674
|
+
_parseFixedDimension(value) {
|
|
1675
|
+
if (value === '') {
|
|
1676
|
+
return undefined;
|
|
1677
|
+
}
|
|
1678
|
+
const parsed = parseInt(value);
|
|
1679
|
+
if (parsed <= 0) {
|
|
1680
|
+
throw ( new Error(`Could not parse dimension "${value}"`));
|
|
1681
|
+
}
|
|
1682
|
+
return parsed;
|
|
1683
|
+
}
|
|
1684
|
+
async toggleSizeToContentWidth() {
|
|
1685
|
+
if (!this.xterm?.raw.buffer.active) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (this._hasScrollBar) {
|
|
1689
|
+
this._terminalHasFixedWidth.set(false);
|
|
1690
|
+
this._fixedCols = undefined;
|
|
1691
|
+
this._fixedRows = undefined;
|
|
1692
|
+
this._hasScrollBar = false;
|
|
1693
|
+
this._initDimensions();
|
|
1694
|
+
await this._resize();
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
const font = this.xterm ? this.xterm.getFont() : this._terminalConfigurationService.getFont(getWindow(this.domElement));
|
|
1698
|
+
const maxColsForTexture = Math.floor(Constants.MaxCanvasWidth / (font.charWidth ?? 20));
|
|
1699
|
+
const proposedCols = Math.max(this.maxCols, Math.min(this.xterm.getLongestViewportWrappedLineLength(), maxColsForTexture));
|
|
1700
|
+
if (proposedCols > this.xterm.raw.cols) {
|
|
1701
|
+
this._fixedCols = proposedCols;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
await this._refreshScrollbar();
|
|
1705
|
+
this._labelComputer?.refreshLabel(this);
|
|
1706
|
+
this.focus();
|
|
1707
|
+
}
|
|
1708
|
+
_refreshScrollbar() {
|
|
1709
|
+
if (this._fixedCols || this._fixedRows) {
|
|
1710
|
+
return this._addScrollbar();
|
|
1711
|
+
}
|
|
1712
|
+
return this._removeScrollbar();
|
|
1713
|
+
}
|
|
1714
|
+
async _addScrollbar() {
|
|
1715
|
+
const charWidth = (this.xterm ? this.xterm.getFont() : this._terminalConfigurationService.getFont(getWindow(this.domElement))).charWidth;
|
|
1716
|
+
if (!this.xterm?.raw.element || !this._container || !charWidth || !this._fixedCols) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
this._wrapperElement.classList.add('fixed-dims');
|
|
1720
|
+
this._hasScrollBar = true;
|
|
1721
|
+
this._initDimensions();
|
|
1722
|
+
await this._resize();
|
|
1723
|
+
this._terminalHasFixedWidth.set(true);
|
|
1724
|
+
if (!this._horizontalScrollbar) {
|
|
1725
|
+
this._horizontalScrollbar = this._register(( new DomScrollableElement(this._wrapperElement, {
|
|
1726
|
+
vertical: ScrollbarVisibility.Hidden,
|
|
1727
|
+
horizontal: ScrollbarVisibility.Auto,
|
|
1728
|
+
useShadows: false,
|
|
1729
|
+
scrollYToX: false,
|
|
1730
|
+
consumeMouseWheelIfScrollbarIsNeeded: false
|
|
1731
|
+
})));
|
|
1732
|
+
this._container.appendChild(this._horizontalScrollbar.getDomNode());
|
|
1733
|
+
}
|
|
1734
|
+
this._horizontalScrollbar.setScrollDimensions({
|
|
1735
|
+
width: this.xterm.raw.element.clientWidth,
|
|
1736
|
+
scrollWidth: this._fixedCols * charWidth + 40
|
|
1737
|
+
});
|
|
1738
|
+
this._horizontalScrollbar.getDomNode().style.paddingBottom = '16px';
|
|
1739
|
+
if (isWindows) {
|
|
1740
|
+
for (let i = this.xterm.raw.buffer.active.viewportY; i < this.xterm.raw.buffer.active.length; i++) {
|
|
1741
|
+
const line = this.xterm.raw.buffer.active.getLine(i);
|
|
1742
|
+
line._line.isWrapped = false;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
async _removeScrollbar() {
|
|
1747
|
+
if (!this._container || !this._horizontalScrollbar) {
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
this._horizontalScrollbar.getDomNode().remove();
|
|
1751
|
+
this._horizontalScrollbar.dispose();
|
|
1752
|
+
this._horizontalScrollbar = undefined;
|
|
1753
|
+
this._wrapperElement.remove();
|
|
1754
|
+
this._wrapperElement.classList.remove('fixed-dims');
|
|
1755
|
+
this._container.appendChild(this._wrapperElement);
|
|
1756
|
+
}
|
|
1757
|
+
_setResolvedShellLaunchConfig(shellLaunchConfig) {
|
|
1758
|
+
this._shellLaunchConfig.args = shellLaunchConfig.args;
|
|
1759
|
+
this._shellLaunchConfig.cwd = shellLaunchConfig.cwd;
|
|
1760
|
+
this._shellLaunchConfig.executable = shellLaunchConfig.executable;
|
|
1761
|
+
this._shellLaunchConfig.env = shellLaunchConfig.env;
|
|
1762
|
+
}
|
|
1763
|
+
_onEnvironmentVariableInfoChanged(info) {
|
|
1764
|
+
if (info.requiresAction) {
|
|
1765
|
+
this.xterm?.raw.textarea?.setAttribute('aria-label', ( localize(
|
|
1766
|
+
11566,
|
|
1767
|
+
"Terminal {0} environment is stale, run the 'Show Environment Information' command for more information",
|
|
1768
|
+
this._instanceId
|
|
1769
|
+
)));
|
|
1770
|
+
}
|
|
1771
|
+
this._refreshEnvironmentVariableInfoWidgetState(info);
|
|
1772
|
+
}
|
|
1773
|
+
async _refreshEnvironmentVariableInfoWidgetState(info) {
|
|
1774
|
+
if (!info) {
|
|
1775
|
+
this.statusList.remove(TerminalStatus.RelaunchNeeded);
|
|
1776
|
+
this.statusList.remove(TerminalStatus.EnvironmentVariableInfoChangesActive);
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
if (
|
|
1780
|
+
info.requiresAction &&
|
|
1781
|
+
this._terminalConfigurationService.config.environmentChangesRelaunch &&
|
|
1782
|
+
!this._processManager.hasWrittenData &&
|
|
1783
|
+
(!this._shellLaunchConfig.isFeatureTerminal || (this.reconnectionProperties && this._configurationService.getValue('task.reconnection') === true)) &&
|
|
1784
|
+
!this._shellLaunchConfig.customPtyImplementation &&
|
|
1785
|
+
!this._shellLaunchConfig.isExtensionOwnedTerminal &&
|
|
1786
|
+
!this._shellLaunchConfig.attachPersistentProcess &&
|
|
1787
|
+
!(this._processManager.remoteAuthority && this._terminalConfigurationService.config.windowsEnableConpty && (await this._processManager.getBackendOS()) === OperatingSystem.Windows)) {
|
|
1788
|
+
this.relaunch();
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
const workspaceFolder = getWorkspaceForTerminal(this.shellLaunchConfig.cwd, this._workspaceContextService, this._historyService);
|
|
1792
|
+
this.statusList.add(info.getStatus({ workspaceFolder }));
|
|
1793
|
+
}
|
|
1794
|
+
async getInitialCwd() {
|
|
1795
|
+
if (!this._initialCwd) {
|
|
1796
|
+
this._initialCwd = this._processManager.initialCwd;
|
|
1797
|
+
}
|
|
1798
|
+
return this._initialCwd;
|
|
1799
|
+
}
|
|
1800
|
+
async getSpeculativeCwd() {
|
|
1801
|
+
if (( this.capabilities.has(TerminalCapability.CwdDetection))) {
|
|
1802
|
+
return this.capabilities.get(TerminalCapability.CwdDetection).getCwd();
|
|
1803
|
+
}
|
|
1804
|
+
else if (( this.capabilities.has(TerminalCapability.NaiveCwdDetection))) {
|
|
1805
|
+
return this.capabilities.get(TerminalCapability.NaiveCwdDetection).getCwd();
|
|
1806
|
+
}
|
|
1807
|
+
return this._processManager.initialCwd;
|
|
1808
|
+
}
|
|
1809
|
+
async getCwdResource() {
|
|
1810
|
+
const cwd = this.capabilities.get(TerminalCapability.CwdDetection)?.getCwd();
|
|
1811
|
+
if (!cwd) {
|
|
1812
|
+
return undefined;
|
|
1813
|
+
}
|
|
1814
|
+
let resource;
|
|
1815
|
+
if (this.remoteAuthority) {
|
|
1816
|
+
resource = await this._pathService.fileURI(cwd);
|
|
1817
|
+
}
|
|
1818
|
+
else {
|
|
1819
|
+
resource = URI.file(cwd);
|
|
1820
|
+
}
|
|
1821
|
+
if (await this._fileService.exists(resource)) {
|
|
1822
|
+
return resource;
|
|
1823
|
+
}
|
|
1824
|
+
return undefined;
|
|
1825
|
+
}
|
|
1826
|
+
async _refreshProperty(type) {
|
|
1827
|
+
await this.processReady;
|
|
1828
|
+
return this._processManager.refreshProperty(type);
|
|
1829
|
+
}
|
|
1830
|
+
async _updateProperty(type, value) {
|
|
1831
|
+
return this._processManager.updateProperty(type, value);
|
|
1832
|
+
}
|
|
1833
|
+
async rename(title, source) {
|
|
1834
|
+
this._setTitle(title, source ?? TitleEventSource.Api);
|
|
1835
|
+
}
|
|
1836
|
+
_setTitle(title, eventSource) {
|
|
1837
|
+
if ((this._shellLaunchConfig?.type === 'Task' || this._titleSource === TitleEventSource.Api) && eventSource === TitleEventSource.Process) {
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
const reset = !title;
|
|
1841
|
+
title = this._updateTitleProperties(title, eventSource);
|
|
1842
|
+
const titleChanged = title !== this._title;
|
|
1843
|
+
this._title = title;
|
|
1844
|
+
this._labelComputer?.refreshLabel(this, reset);
|
|
1845
|
+
this._setAriaLabel(this.xterm?.raw, this._instanceId, this._title);
|
|
1846
|
+
if (titleChanged) {
|
|
1847
|
+
this._onTitleChanged.fire(this);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
async changeIcon(icon) {
|
|
1851
|
+
if (icon) {
|
|
1852
|
+
this._icon = icon;
|
|
1853
|
+
this._onIconChanged.fire({ instance: this, userInitiated: true });
|
|
1854
|
+
return icon;
|
|
1855
|
+
}
|
|
1856
|
+
const iconPicker = this._scopedInstantiationService.createInstance(TerminalIconPicker);
|
|
1857
|
+
const pickedIcon = await iconPicker.pickIcons();
|
|
1858
|
+
iconPicker.dispose();
|
|
1859
|
+
if (!pickedIcon) {
|
|
1860
|
+
return undefined;
|
|
1861
|
+
}
|
|
1862
|
+
this._icon = pickedIcon;
|
|
1863
|
+
this._onIconChanged.fire({ instance: this, userInitiated: true });
|
|
1864
|
+
return pickedIcon;
|
|
1865
|
+
}
|
|
1866
|
+
async changeColor(color, skipQuickPick) {
|
|
1867
|
+
if (color) {
|
|
1868
|
+
this.shellLaunchConfig.color = color;
|
|
1869
|
+
this._onIconChanged.fire({ instance: this, userInitiated: true });
|
|
1870
|
+
return color;
|
|
1871
|
+
}
|
|
1872
|
+
else if (skipQuickPick) {
|
|
1873
|
+
this.shellLaunchConfig.color = '';
|
|
1874
|
+
this._onIconChanged.fire({ instance: this, userInitiated: true });
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
const icon = this._getIcon();
|
|
1878
|
+
if (!icon) {
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
const colorTheme = this._themeService.getColorTheme();
|
|
1882
|
+
const standardColors = getStandardColors(colorTheme);
|
|
1883
|
+
const colorStyleDisposable = createColorStyleElement(colorTheme);
|
|
1884
|
+
const items = [];
|
|
1885
|
+
for (const colorKey of standardColors) {
|
|
1886
|
+
const colorClass = getColorClass(colorKey);
|
|
1887
|
+
items.push({
|
|
1888
|
+
label: `$(${Codicon.circleFilled.id}) ${colorKey.replace('terminal.ansi', '')}`, id: colorKey, description: colorKey, iconClasses: [colorClass]
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
items.push({ type: 'separator' });
|
|
1892
|
+
const showAllColorsItem = { label: 'Reset to default' };
|
|
1893
|
+
items.push(showAllColorsItem);
|
|
1894
|
+
const disposables = [];
|
|
1895
|
+
const quickPick = this._quickInputService.createQuickPick({ useSeparators: true });
|
|
1896
|
+
disposables.push(quickPick);
|
|
1897
|
+
quickPick.items = items;
|
|
1898
|
+
quickPick.matchOnDescription = true;
|
|
1899
|
+
quickPick.placeholder = ( localize(11567, 'Select a color for the terminal'));
|
|
1900
|
+
quickPick.show();
|
|
1901
|
+
const result = await ( new Promise(r => {
|
|
1902
|
+
disposables.push(quickPick.onDidHide(() => r(undefined)));
|
|
1903
|
+
disposables.push(quickPick.onDidAccept(() => r(quickPick.selectedItems[0])));
|
|
1904
|
+
}));
|
|
1905
|
+
dispose(disposables);
|
|
1906
|
+
if (result) {
|
|
1907
|
+
this.shellLaunchConfig.color = result.id;
|
|
1908
|
+
this._onIconChanged.fire({ instance: this, userInitiated: true });
|
|
1909
|
+
}
|
|
1910
|
+
quickPick.hide();
|
|
1911
|
+
colorStyleDisposable.dispose();
|
|
1912
|
+
return result?.id;
|
|
1913
|
+
}
|
|
1914
|
+
forceScrollbarVisibility() {
|
|
1915
|
+
this._wrapperElement.classList.add('force-scrollbar');
|
|
1916
|
+
}
|
|
1917
|
+
resetScrollbarVisibility() {
|
|
1918
|
+
this._wrapperElement.classList.remove('force-scrollbar');
|
|
1919
|
+
}
|
|
1920
|
+
setParentContextKeyService(parentContextKeyService) {
|
|
1921
|
+
this._scopedContextKeyService.updateParent(parentContextKeyService);
|
|
1922
|
+
}
|
|
1923
|
+
async handleMouseEvent(event, contextMenu) {
|
|
1924
|
+
if (isHTMLElement(event.target) && (event.target.classList.contains('scrollbar') || event.target.classList.contains('slider'))) {
|
|
1925
|
+
return { cancelContextMenu: true };
|
|
1926
|
+
}
|
|
1927
|
+
for (const contrib of ( this._contributions.values())) {
|
|
1928
|
+
const result = await contrib.handleMouseEvent?.(event);
|
|
1929
|
+
if (result?.handled) {
|
|
1930
|
+
return { cancelContextMenu: true };
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
if (event.which === 2) {
|
|
1934
|
+
switch (this._terminalConfigurationService.config.middleClickBehavior) {
|
|
1935
|
+
case 'default':
|
|
1936
|
+
default:
|
|
1937
|
+
this.focus();
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
if (event.which === 3) {
|
|
1943
|
+
if (event.shiftKey) {
|
|
1944
|
+
openContextMenu(getActiveWindow(), event, this, contextMenu, this._contextMenuService);
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
|
1948
|
+
if (rightClickBehavior === 'nothing') {
|
|
1949
|
+
if (!event.shiftKey) {
|
|
1950
|
+
return { cancelContextMenu: true };
|
|
1951
|
+
}
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
TerminalInstance.__decorator = ( __decorate([
|
|
1958
|
+
debounce(50)
|
|
1959
|
+
], TerminalInstance.prototype, "_fireMaximumDimensionsChanged", null));
|
|
1960
|
+
TerminalInstance.__decorator = ( __decorate([
|
|
1961
|
+
debounce(1000)
|
|
1962
|
+
], TerminalInstance.prototype, "relaunch", null));
|
|
1963
|
+
TerminalInstance.__decorator = ( __decorate([
|
|
1964
|
+
debounce(2000)
|
|
1965
|
+
], TerminalInstance.prototype, "_updateProcessCwd", null));
|
|
1966
|
+
TerminalInstance = TerminalInstance_1 = ( __decorate([
|
|
1967
|
+
( __param(2, IContextKeyService)),
|
|
1968
|
+
( __param(3, IContextMenuService)),
|
|
1969
|
+
( __param(4, IInstantiationService)),
|
|
1970
|
+
( __param(5, ITerminalConfigurationService)),
|
|
1971
|
+
( __param(6, ITerminalProfileResolverService)),
|
|
1972
|
+
( __param(7, IPathService)),
|
|
1973
|
+
( __param(8, IFileService)),
|
|
1974
|
+
( __param(9, IKeybindingService)),
|
|
1975
|
+
( __param(10, INotificationService)),
|
|
1976
|
+
( __param(11, IPreferencesService)),
|
|
1977
|
+
( __param(12, IViewsService)),
|
|
1978
|
+
( __param(13, IThemeService)),
|
|
1979
|
+
( __param(14, IConfigurationService)),
|
|
1980
|
+
( __param(15, ITerminalLogService)),
|
|
1981
|
+
( __param(16, IStorageService)),
|
|
1982
|
+
( __param(17, IAccessibilityService)),
|
|
1983
|
+
( __param(18, IProductService)),
|
|
1984
|
+
( __param(19, IQuickInputService)),
|
|
1985
|
+
( __param(20, IWorkbenchEnvironmentService)),
|
|
1986
|
+
( __param(21, IWorkspaceContextService)),
|
|
1987
|
+
( __param(22, IEditorService)),
|
|
1988
|
+
( __param(23, IWorkspaceTrustRequestService)),
|
|
1989
|
+
( __param(24, IHistoryService)),
|
|
1990
|
+
( __param(25, ITelemetryService)),
|
|
1991
|
+
( __param(26, IOpenerService)),
|
|
1992
|
+
( __param(27, ICommandService)),
|
|
1993
|
+
( __param(28, IAccessibilitySignalService)),
|
|
1994
|
+
( __param(29, IViewDescriptorService))
|
|
1995
|
+
], TerminalInstance));
|
|
1996
|
+
let TerminalInstanceDragAndDropController = class TerminalInstanceDragAndDropController extends Disposable {
|
|
1997
|
+
get onDropFile() { return this._onDropFile.event; }
|
|
1998
|
+
get onDropTerminal() { return this._onDropTerminal.event; }
|
|
1999
|
+
constructor(_container, _layoutService, _viewDescriptorService) {
|
|
2000
|
+
super();
|
|
2001
|
+
this._container = _container;
|
|
2002
|
+
this._layoutService = _layoutService;
|
|
2003
|
+
this._viewDescriptorService = _viewDescriptorService;
|
|
2004
|
+
this._onDropFile = this._register(( new Emitter()));
|
|
2005
|
+
this._onDropTerminal = this._register(( new Emitter()));
|
|
2006
|
+
this._register(toDisposable(() => this._clearDropOverlay()));
|
|
2007
|
+
}
|
|
2008
|
+
_clearDropOverlay() {
|
|
2009
|
+
this._dropOverlay?.remove();
|
|
2010
|
+
this._dropOverlay = undefined;
|
|
2011
|
+
}
|
|
2012
|
+
onDragEnter(e) {
|
|
2013
|
+
if (!containsDragType(e, DataTransfers.FILES, DataTransfers.RESOURCES, TerminalDataTransfers.Terminals, CodeDataTransfers.FILES)) {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
if (!this._dropOverlay) {
|
|
2017
|
+
this._dropOverlay = createElement('div');
|
|
2018
|
+
this._dropOverlay.classList.add('terminal-drop-overlay');
|
|
2019
|
+
}
|
|
2020
|
+
if (containsDragType(e, TerminalDataTransfers.Terminals)) {
|
|
2021
|
+
const side = this._getDropSide(e);
|
|
2022
|
+
this._dropOverlay.classList.toggle('drop-before', side === 'before');
|
|
2023
|
+
this._dropOverlay.classList.toggle('drop-after', side === 'after');
|
|
2024
|
+
}
|
|
2025
|
+
if (!this._dropOverlay.parentElement) {
|
|
2026
|
+
this._container.appendChild(this._dropOverlay);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
onDragLeave(e) {
|
|
2030
|
+
this._clearDropOverlay();
|
|
2031
|
+
}
|
|
2032
|
+
onDragEnd(e) {
|
|
2033
|
+
this._clearDropOverlay();
|
|
2034
|
+
}
|
|
2035
|
+
onDragOver(e) {
|
|
2036
|
+
if (!e.dataTransfer || !this._dropOverlay) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
if (containsDragType(e, TerminalDataTransfers.Terminals)) {
|
|
2040
|
+
const side = this._getDropSide(e);
|
|
2041
|
+
this._dropOverlay.classList.toggle('drop-before', side === 'before');
|
|
2042
|
+
this._dropOverlay.classList.toggle('drop-after', side === 'after');
|
|
2043
|
+
}
|
|
2044
|
+
this._dropOverlay.style.opacity = '1';
|
|
2045
|
+
}
|
|
2046
|
+
async onDrop(e) {
|
|
2047
|
+
this._clearDropOverlay();
|
|
2048
|
+
if (!e.dataTransfer) {
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
const terminalResources = getTerminalResourcesFromDragEvent(e);
|
|
2052
|
+
if (terminalResources) {
|
|
2053
|
+
for (const uri of terminalResources) {
|
|
2054
|
+
const side = this._getDropSide(e);
|
|
2055
|
+
this._onDropTerminal.fire({ uri, side });
|
|
2056
|
+
}
|
|
2057
|
+
return;
|
|
2058
|
+
}
|
|
2059
|
+
let path;
|
|
2060
|
+
const rawResources = e.dataTransfer.getData(DataTransfers.RESOURCES);
|
|
2061
|
+
if (rawResources) {
|
|
2062
|
+
path = ( URI.parse(JSON.parse(rawResources)[0]));
|
|
2063
|
+
}
|
|
2064
|
+
const rawCodeFiles = e.dataTransfer.getData(CodeDataTransfers.FILES);
|
|
2065
|
+
if (!path && rawCodeFiles) {
|
|
2066
|
+
path = URI.file(JSON.parse(rawCodeFiles)[0]);
|
|
2067
|
+
}
|
|
2068
|
+
if (!path && e.dataTransfer.files.length > 0 && getPathForFile(e.dataTransfer.files[0])) {
|
|
2069
|
+
path = URI.file(getPathForFile(e.dataTransfer.files[0]));
|
|
2070
|
+
}
|
|
2071
|
+
if (!path) {
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
this._onDropFile.fire(path);
|
|
2075
|
+
}
|
|
2076
|
+
_getDropSide(e) {
|
|
2077
|
+
const target = this._container;
|
|
2078
|
+
if (!target) {
|
|
2079
|
+
return 'after';
|
|
2080
|
+
}
|
|
2081
|
+
const rect = target.getBoundingClientRect();
|
|
2082
|
+
return this._getViewOrientation() === Orientation.HORIZONTAL
|
|
2083
|
+
? (e.clientX - rect.left < rect.width / 2 ? 'before' : 'after')
|
|
2084
|
+
: (e.clientY - rect.top < rect.height / 2 ? 'before' : 'after');
|
|
2085
|
+
}
|
|
2086
|
+
_getViewOrientation() {
|
|
2087
|
+
const panelPosition = this._layoutService.getPanelPosition();
|
|
2088
|
+
const terminalLocation = this._viewDescriptorService.getViewLocationById(TERMINAL_VIEW_ID);
|
|
2089
|
+
return terminalLocation === ViewContainerLocation.Panel && isHorizontal(panelPosition)
|
|
2090
|
+
? Orientation.HORIZONTAL
|
|
2091
|
+
: Orientation.VERTICAL;
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2094
|
+
TerminalInstanceDragAndDropController = ( __decorate([
|
|
2095
|
+
( __param(1, IWorkbenchLayoutService)),
|
|
2096
|
+
( __param(2, IViewDescriptorService))
|
|
2097
|
+
], TerminalInstanceDragAndDropController));
|
|
2098
|
+
var TerminalLabelType;
|
|
2099
|
+
(function (TerminalLabelType) {
|
|
2100
|
+
TerminalLabelType["Title"] = "title";
|
|
2101
|
+
TerminalLabelType["Description"] = "description";
|
|
2102
|
+
})(TerminalLabelType || (TerminalLabelType = {}));
|
|
2103
|
+
let TerminalLabelComputer = class TerminalLabelComputer extends Disposable {
|
|
2104
|
+
get title() { return this._title; }
|
|
2105
|
+
get description() { return this._description; }
|
|
2106
|
+
constructor(_fileService, _terminalConfigurationService, _workspaceContextService) {
|
|
2107
|
+
super();
|
|
2108
|
+
this._fileService = _fileService;
|
|
2109
|
+
this._terminalConfigurationService = _terminalConfigurationService;
|
|
2110
|
+
this._workspaceContextService = _workspaceContextService;
|
|
2111
|
+
this._title = '';
|
|
2112
|
+
this._description = '';
|
|
2113
|
+
this._onDidChangeLabel = this._register(( new Emitter()));
|
|
2114
|
+
this.onDidChangeLabel = this._onDidChangeLabel.event;
|
|
2115
|
+
}
|
|
2116
|
+
refreshLabel(instance, reset) {
|
|
2117
|
+
this._title = this.computeLabel(instance, this._terminalConfigurationService.config.tabs.title, TerminalLabelType.Title, reset);
|
|
2118
|
+
this._description = this.computeLabel(instance, this._terminalConfigurationService.config.tabs.description, TerminalLabelType.Description);
|
|
2119
|
+
if (this._title !== instance.title || this._description !== instance.description || reset) {
|
|
2120
|
+
this._onDidChangeLabel.fire({ title: this._title, description: this._description });
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
computeLabel(instance, labelTemplate, labelType, reset) {
|
|
2124
|
+
const type = instance.shellLaunchConfig.attachPersistentProcess?.type || instance.shellLaunchConfig.type;
|
|
2125
|
+
const commandDetection = instance.capabilities.get(TerminalCapability.CommandDetection);
|
|
2126
|
+
const promptInputModel = commandDetection?.promptInputModel;
|
|
2127
|
+
const nonTaskSpinner = type === 'Task' ? '' : ' $(loading~spin)';
|
|
2128
|
+
const templateProperties = {
|
|
2129
|
+
cwd: instance.cwd || instance.initialCwd || '',
|
|
2130
|
+
cwdFolder: '',
|
|
2131
|
+
workspaceFolderName: instance.workspaceFolder?.name,
|
|
2132
|
+
workspaceFolder: instance.workspaceFolder ? basename(instance.workspaceFolder.uri.fsPath) : undefined,
|
|
2133
|
+
local: type === 'Local' ? terminalStrings.typeLocal : undefined,
|
|
2134
|
+
process: instance.processName,
|
|
2135
|
+
sequence: instance.sequence,
|
|
2136
|
+
task: type === 'Task' ? terminalStrings.typeTask : undefined,
|
|
2137
|
+
fixedDimensions: instance.fixedCols
|
|
2138
|
+
? (instance.fixedRows ? `\u2194${instance.fixedCols} \u2195${instance.fixedRows}` : `\u2194${instance.fixedCols}`)
|
|
2139
|
+
: (instance.fixedRows ? `\u2195${instance.fixedRows}` : ''),
|
|
2140
|
+
separator: { label: this._terminalConfigurationService.config.tabs.separator },
|
|
2141
|
+
shellType: instance.shellType,
|
|
2142
|
+
shellCommand: commandDetection?.executingCommand && commandDetection.executingCommandConfidence === 'high' && promptInputModel
|
|
2143
|
+
? promptInputModel.value + nonTaskSpinner
|
|
2144
|
+
: undefined,
|
|
2145
|
+
shellPromptInput: commandDetection?.executingCommand && promptInputModel
|
|
2146
|
+
? promptInputModel.getCombinedString(true) + nonTaskSpinner
|
|
2147
|
+
: promptInputModel?.getCombinedString(true),
|
|
2148
|
+
progress: this._getProgressStateString(instance.progressState)
|
|
2149
|
+
};
|
|
2150
|
+
templateProperties.workspaceFolderName = instance.workspaceFolder?.name ?? templateProperties.workspaceFolder;
|
|
2151
|
+
labelTemplate = labelTemplate.trim();
|
|
2152
|
+
if (!labelTemplate) {
|
|
2153
|
+
return labelType === TerminalLabelType.Title ? (instance.processName || '') : '';
|
|
2154
|
+
}
|
|
2155
|
+
if (!reset && instance.staticTitle && labelType === TerminalLabelType.Title) {
|
|
2156
|
+
return instance.staticTitle.replace(/[\n\r\t]/g, '') || templateProperties.process?.replace(/[\n\r\t]/g, '') || '';
|
|
2157
|
+
}
|
|
2158
|
+
const detection = ( instance.capabilities.has(TerminalCapability.CwdDetection)) || ( instance.capabilities.has(TerminalCapability.NaiveCwdDetection));
|
|
2159
|
+
const folders = this._workspaceContextService.getWorkspace().folders;
|
|
2160
|
+
const multiRootWorkspace = folders.length > 1;
|
|
2161
|
+
if (templateProperties.cwd && detection && (!instance.shellLaunchConfig.isFeatureTerminal || labelType === TerminalLabelType.Title)) {
|
|
2162
|
+
const cwdUri = ( URI.from({
|
|
2163
|
+
scheme: instance.workspaceFolder?.uri.scheme || Schemas.file,
|
|
2164
|
+
path: instance.cwd ? resolve(instance.cwd) : undefined
|
|
2165
|
+
}));
|
|
2166
|
+
let showCwd = false;
|
|
2167
|
+
if (multiRootWorkspace) {
|
|
2168
|
+
showCwd = true;
|
|
2169
|
+
}
|
|
2170
|
+
else if (instance.workspaceFolder?.uri) {
|
|
2171
|
+
const caseSensitive = this._fileService.hasCapability(instance.workspaceFolder.uri, FileSystemProviderCapabilities.PathCaseSensitive);
|
|
2172
|
+
showCwd = cwdUri.fsPath.localeCompare(instance.workspaceFolder.uri.fsPath, undefined, { sensitivity: caseSensitive ? 'case' : 'base' }) !== 0;
|
|
2173
|
+
}
|
|
2174
|
+
if (showCwd) {
|
|
2175
|
+
templateProperties.cwdFolder = basename(templateProperties.cwd);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
const label = template(labelTemplate, templateProperties).replace(/[\n\r\t]/g, '').trim();
|
|
2179
|
+
return label === '' && labelType === TerminalLabelType.Title ? (instance.processName || '') : label;
|
|
2180
|
+
}
|
|
2181
|
+
_getProgressStateString(progressState) {
|
|
2182
|
+
if (!progressState) {
|
|
2183
|
+
return '';
|
|
2184
|
+
}
|
|
2185
|
+
switch (progressState.state) {
|
|
2186
|
+
case 0: return '';
|
|
2187
|
+
case 1: return `${Math.round(progressState.value)}%`;
|
|
2188
|
+
case 2: return '$(error)';
|
|
2189
|
+
case 3: return '$(loading~spin)';
|
|
2190
|
+
case 4: return '$(alert)';
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
};
|
|
2194
|
+
TerminalLabelComputer = ( __decorate([
|
|
2195
|
+
( __param(0, IFileService)),
|
|
2196
|
+
( __param(1, ITerminalConfigurationService)),
|
|
2197
|
+
( __param(2, IWorkspaceContextService))
|
|
2198
|
+
], TerminalLabelComputer));
|
|
2199
|
+
function parseExitResult(exitCodeOrError, shellLaunchConfig, processState, initialCwd) {
|
|
2200
|
+
if (exitCodeOrError === undefined || exitCodeOrError === 0) {
|
|
2201
|
+
return { code: exitCodeOrError, message: undefined };
|
|
2202
|
+
}
|
|
2203
|
+
const code = isNumber(exitCodeOrError) ? exitCodeOrError : exitCodeOrError.code;
|
|
2204
|
+
let message = undefined;
|
|
2205
|
+
switch (typeof exitCodeOrError) {
|
|
2206
|
+
case 'number': {
|
|
2207
|
+
let commandLine = undefined;
|
|
2208
|
+
if (shellLaunchConfig.executable) {
|
|
2209
|
+
commandLine = shellLaunchConfig.executable;
|
|
2210
|
+
if (isString(shellLaunchConfig.args)) {
|
|
2211
|
+
commandLine += ` ${shellLaunchConfig.args}`;
|
|
2212
|
+
}
|
|
2213
|
+
else if (shellLaunchConfig.args && shellLaunchConfig.args.length) {
|
|
2214
|
+
commandLine += ( shellLaunchConfig.args.map(a => ` '${a}'`)).join();
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
if (processState === ProcessState.KilledDuringLaunch) {
|
|
2218
|
+
if (commandLine) {
|
|
2219
|
+
message = ( localize(
|
|
2220
|
+
11568,
|
|
2221
|
+
"The terminal process \"{0}\" failed to launch (exit code: {1}).",
|
|
2222
|
+
commandLine,
|
|
2223
|
+
code
|
|
2224
|
+
));
|
|
2225
|
+
}
|
|
2226
|
+
else {
|
|
2227
|
+
message = ( localize(11569, "The terminal process failed to launch (exit code: {0}).", code));
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
if (commandLine) {
|
|
2232
|
+
message = ( localize(
|
|
2233
|
+
11570,
|
|
2234
|
+
"The terminal process \"{0}\" terminated with exit code: {1}.",
|
|
2235
|
+
commandLine,
|
|
2236
|
+
code
|
|
2237
|
+
));
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
message = ( localize(11571, "The terminal process terminated with exit code: {0}.", code));
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
case 'object': {
|
|
2246
|
+
if (( exitCodeOrError.message.toString()).includes('Could not find pty with id')) {
|
|
2247
|
+
break;
|
|
2248
|
+
}
|
|
2249
|
+
let innerMessage = exitCodeOrError.message;
|
|
2250
|
+
const conptyError = exitCodeOrError.message.match(/.*error code:\s*(\d+).*$/);
|
|
2251
|
+
if (conptyError) {
|
|
2252
|
+
const errorCode = conptyError.length > 1 ? parseInt(conptyError[1]) : undefined;
|
|
2253
|
+
switch (errorCode) {
|
|
2254
|
+
case 5:
|
|
2255
|
+
innerMessage = `Access was denied to the path containing your executable "${shellLaunchConfig.executable}". Manage and change your permissions to get this to work`;
|
|
2256
|
+
break;
|
|
2257
|
+
case 267:
|
|
2258
|
+
innerMessage = `Invalid starting directory "${initialCwd}", review your terminal.integrated.cwd setting`;
|
|
2259
|
+
break;
|
|
2260
|
+
case 1260:
|
|
2261
|
+
innerMessage = `Windows cannot open this program because it has been prevented by a software restriction policy. For more information, open Event Viewer or contact your system Administrator`;
|
|
2262
|
+
break;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
message = ( localize(11572, "The terminal process failed to launch: {0}.", innerMessage));
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
return { code, message };
|
|
2270
|
+
}
|
|
2271
|
+
let TerminalInstanceColorProvider = class TerminalInstanceColorProvider {
|
|
2272
|
+
constructor(_target, _viewDescriptorService) {
|
|
2273
|
+
this._target = _target;
|
|
2274
|
+
this._viewDescriptorService = _viewDescriptorService;
|
|
2275
|
+
}
|
|
2276
|
+
getBackgroundColor(theme) {
|
|
2277
|
+
const terminalBackground = theme.getColor(TERMINAL_BACKGROUND_COLOR);
|
|
2278
|
+
if (terminalBackground) {
|
|
2279
|
+
return terminalBackground;
|
|
2280
|
+
}
|
|
2281
|
+
if (this._target.object === TerminalLocation.Editor) {
|
|
2282
|
+
return theme.getColor(editorBackground);
|
|
2283
|
+
}
|
|
2284
|
+
const location = this._viewDescriptorService.getViewLocationById(TERMINAL_VIEW_ID);
|
|
2285
|
+
if (location === ViewContainerLocation.Panel) {
|
|
2286
|
+
return theme.getColor(PANEL_BACKGROUND);
|
|
2287
|
+
}
|
|
2288
|
+
return theme.getColor(SIDE_BAR_BACKGROUND);
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
TerminalInstanceColorProvider = ( __decorate([
|
|
2292
|
+
( __param(1, IViewDescriptorService))
|
|
2293
|
+
], TerminalInstanceColorProvider));
|
|
2294
|
+
function guessShellTypeFromExecutable(os, executable) {
|
|
2295
|
+
const exeBasename = basename(executable);
|
|
2296
|
+
const generalShellTypeMap = ( new Map([
|
|
2297
|
+
[GeneralShellType.Julia, /^julia$/],
|
|
2298
|
+
[GeneralShellType.Node, /^node$/],
|
|
2299
|
+
[GeneralShellType.NuShell, /^nu$/],
|
|
2300
|
+
[GeneralShellType.PowerShell, /^pwsh(-preview)?|powershell$/],
|
|
2301
|
+
[GeneralShellType.Python, /^py(?:thon)?$/]
|
|
2302
|
+
]));
|
|
2303
|
+
for (const [shellType, pattern] of generalShellTypeMap) {
|
|
2304
|
+
if (exeBasename.match(pattern)) {
|
|
2305
|
+
return shellType;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
if (os === OperatingSystem.Windows) {
|
|
2309
|
+
const windowsShellTypeMap = ( new Map([
|
|
2310
|
+
[WindowsShellType.CommandPrompt, /^cmd$/],
|
|
2311
|
+
[WindowsShellType.GitBash, /^bash$/],
|
|
2312
|
+
[WindowsShellType.Wsl, /^wsl$/]
|
|
2313
|
+
]));
|
|
2314
|
+
for (const [shellType, pattern] of windowsShellTypeMap) {
|
|
2315
|
+
if (exeBasename.match(pattern)) {
|
|
2316
|
+
return shellType;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
else {
|
|
2321
|
+
const posixShellTypes = [
|
|
2322
|
+
PosixShellType.Bash,
|
|
2323
|
+
PosixShellType.Csh,
|
|
2324
|
+
PosixShellType.Fish,
|
|
2325
|
+
PosixShellType.Ksh,
|
|
2326
|
+
PosixShellType.Sh,
|
|
2327
|
+
PosixShellType.Zsh,
|
|
2328
|
+
];
|
|
2329
|
+
for (const type of posixShellTypes) {
|
|
2330
|
+
if (exeBasename === type) {
|
|
2331
|
+
return type;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
return undefined;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
export { TerminalInstance, TerminalInstanceColorProvider, TerminalLabelComputer, parseExitResult };
|