@codingame/monaco-vscode-debug-service-override 1.82.4 → 1.82.5-next.1

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.
Files changed (73) hide show
  1. package/debug.d.ts +5 -0
  2. package/debug.js +24 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -1
  6. package/index.js +1 -1
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +2 -2
  9. package/vscode/src/vs/editor/common/services/languageFeaturesService.js +44 -0
  10. package/vscode/src/vs/workbench/contrib/debug/browser/baseDebugView.js +200 -0
  11. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +785 -0
  12. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +399 -0
  13. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1298 -0
  14. package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
  15. package/vscode/src/vs/workbench/contrib/debug/browser/callStackView.js +960 -0
  16. package/vscode/src/vs/workbench/contrib/debug/browser/debug.contribution.js +497 -0
  17. package/vscode/src/vs/workbench/contrib/debug/browser/debugANSIHandling.js +347 -0
  18. package/vscode/src/vs/workbench/contrib/debug/browser/debugActionViewItems.js +299 -0
  19. package/vscode/src/vs/workbench/contrib/debug/browser/debugAdapterManager.js +400 -0
  20. package/vscode/src/vs/workbench/contrib/debug/browser/debugCommands.js +827 -0
  21. package/vscode/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.js +621 -0
  22. package/vscode/src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.js +60 -0
  23. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorActions.js +527 -0
  24. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorContribution.js +681 -0
  25. package/vscode/src/vs/workbench/contrib/debug/browser/debugHover.js +356 -0
  26. package/vscode/src/vs/workbench/contrib/debug/browser/debugMemory.js +206 -0
  27. package/vscode/src/vs/workbench/contrib/debug/browser/debugProgress.js +82 -0
  28. package/vscode/src/vs/workbench/contrib/debug/browser/debugQuickAccess.js +143 -0
  29. package/vscode/src/vs/workbench/contrib/debug/browser/debugService.js +1174 -0
  30. package/vscode/src/vs/workbench/contrib/debug/browser/debugSession.js +1144 -0
  31. package/vscode/src/vs/workbench/contrib/debug/browser/debugSessionPicker.js +106 -0
  32. package/vscode/src/vs/workbench/contrib/debug/browser/debugStatus.js +68 -0
  33. package/vscode/src/vs/workbench/contrib/debug/browser/debugTaskRunner.js +275 -0
  34. package/vscode/src/vs/workbench/contrib/debug/browser/debugToolBar.js +314 -0
  35. package/vscode/src/vs/workbench/contrib/debug/browser/debugViewlet.js +168 -0
  36. package/vscode/src/vs/workbench/contrib/debug/browser/disassemblyView.js +663 -0
  37. package/vscode/src/vs/workbench/contrib/debug/browser/exceptionWidget.js +105 -0
  38. package/vscode/src/vs/workbench/contrib/debug/browser/linkDetector.js +231 -0
  39. package/vscode/src/vs/workbench/contrib/debug/browser/loadedScriptsView.js +631 -0
  40. package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +6 -0
  41. package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +6 -0
  42. package/vscode/src/vs/workbench/contrib/debug/browser/media/debug.contribution.css.js +6 -0
  43. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugHover.css.js +6 -0
  44. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugToolBar.css.js +6 -0
  45. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css.js +6 -0
  46. package/vscode/src/vs/workbench/contrib/debug/browser/media/exceptionWidget.css.js +6 -0
  47. package/vscode/src/vs/workbench/contrib/debug/browser/media/repl.css.js +6 -0
  48. package/vscode/src/vs/workbench/contrib/debug/browser/rawDebugSession.js +695 -0
  49. package/vscode/src/vs/workbench/contrib/debug/browser/repl.js +953 -0
  50. package/vscode/src/vs/workbench/contrib/debug/browser/replFilter.js +48 -0
  51. package/vscode/src/vs/workbench/contrib/debug/browser/replViewer.js +336 -0
  52. package/vscode/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.js +98 -0
  53. package/vscode/src/vs/workbench/contrib/debug/browser/variablesView.js +575 -0
  54. package/vscode/src/vs/workbench/contrib/debug/browser/watchExpressionsView.js +415 -0
  55. package/vscode/src/vs/workbench/contrib/debug/browser/welcomeView.js +102 -0
  56. package/vscode/src/vs/workbench/contrib/debug/common/breakpoints.js +21 -0
  57. package/vscode/src/vs/workbench/contrib/debug/common/debugCompoundRoot.js +17 -0
  58. package/vscode/src/vs/workbench/contrib/debug/common/debugContentProvider.js +100 -0
  59. package/vscode/src/vs/workbench/contrib/debug/common/debugLifecycle.js +59 -0
  60. package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1482 -0
  61. package/vscode/src/vs/workbench/contrib/debug/common/debugSchemas.js +346 -0
  62. package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +123 -0
  63. package/vscode/src/vs/workbench/contrib/debug/common/debugStorage.js +175 -0
  64. package/vscode/src/vs/workbench/contrib/debug/common/debugTelemetry.js +36 -0
  65. package/vscode/src/vs/workbench/contrib/debug/common/debugViewModel.js +117 -0
  66. package/vscode/src/vs/workbench/contrib/debug/common/debugger.js +260 -0
  67. package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +27 -0
  68. package/vscode/src/vs/workbench/contrib/debug/common/loadedScriptsPicker.js +83 -0
  69. package/vscode/src/vs/workbench/contrib/debug/common/replModel.js +283 -0
  70. package/vscode/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.js +305 -0
  71. package/vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.js +28 -0
  72. package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverSchema.js +176 -0
  73. package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverUtils.js +12 -0
@@ -0,0 +1,953 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
3
+ import * as aria from 'monaco-editor/esm/vs/base/browser/ui/aria/aria.js';
4
+ import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'monaco-editor/esm/vs/base/browser/ui/mouseCursor/mouseCursor.js';
5
+ import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
6
+ import { memoize } from 'monaco-editor/esm/vs/base/common/decorators.js';
7
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
8
+ import { HistoryNavigator } from 'monaco-editor/esm/vs/base/common/history.js';
9
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
10
+ import { removeAnsiEscapeCodes } from 'monaco-editor/esm/vs/base/common/strings.js';
11
+ import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
12
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
13
+ import './media/repl.css.js';
14
+ import { isCodeEditor } from 'monaco-editor/esm/vs/editor/browser/editorBrowser.js';
15
+ import { registerEditorAction, EditorAction } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
16
+ import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
17
+ import { CodeEditorWidget } from 'monaco-editor/esm/vs/editor/browser/widget/codeEditorWidget.js';
18
+ import { EDITOR_FONT_DEFAULTS } from 'monaco-editor/esm/vs/editor/common/config/editorOptions.js';
19
+ import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
20
+ import { EditorContextKeys } from 'monaco-editor/esm/vs/editor/common/editorContextKeys.js';
21
+ import { CompletionItemKinds } from 'monaco-editor/esm/vs/editor/common/languages.js';
22
+ import { ILanguageFeaturesService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
23
+ import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
24
+ import { ITextResourcePropertiesService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
25
+ import { SuggestController } from 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestController.js';
26
+ import { localize } from 'monaco-editor/esm/vs/nls.js';
27
+ import { createAndFillInContextMenuActions } from 'monaco-editor/esm/vs/platform/actions/browser/menuEntryActionViewItem.js';
28
+ import { MenuId, registerAction2, Action2, IMenuService } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
29
+ import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
30
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
31
+ import { IContextKeyService, ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
32
+ import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
33
+ import { registerAndCreateHistoryNavigationContext } from 'monaco-editor/esm/vs/platform/history/browser/contextScopedHistoryWidget.js';
34
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
35
+ import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
36
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
37
+ import { WorkbenchAsyncDataTree } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
38
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
39
+ import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
40
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
41
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
42
+ import { resolveColorValue, editorForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
43
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
44
+ import { FilterViewPane, ViewAction } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
45
+ import { IViewsService, IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
46
+ import { getSimpleEditorOptions, getSimpleCodeEditorWidgetOptions } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
47
+ import { FocusSessionActionViewItem } from './debugActionViewItems.js';
48
+ import { debugConsoleEvaluationPrompt, debugConsoleClearAll } from 'vscode/vscode/vs/workbench/contrib/debug/browser/debugIcons';
49
+ import { LinkDetector } from './linkDetector.js';
50
+ import { ReplFilter } from './replFilter.js';
51
+ import { ReplDelegate, ReplVariablesRenderer, ReplOutputElementRenderer, ReplEvaluationInputsRenderer, ReplGroupRenderer, ReplEvaluationResultsRenderer, ReplRawObjectsRenderer, ReplDataSource, ReplAccessibilityProvider } from './replViewer.js';
52
+ import { DEBUG_SCHEME, CONTEXT_MULTI_SESSION_REPL, CONTEXT_IN_DEBUG_REPL, REPL_VIEW_ID, IDebugService, CONTEXT_DEBUG_STATE, getStateLabel } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
53
+ import { Variable } from '../common/debugModel.js';
54
+ import { ReplEvaluationResult, ReplGroup } from '../common/replModel.js';
55
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
56
+ import { registerNavigableContainer } from 'vscode/vscode/vs/workbench/browser/actions/widgetNavigationCommands';
57
+
58
+ var Repl_1, ReplOptions_1;
59
+ const $ = dom.$;
60
+ const HISTORY_STORAGE_KEY = 'debug.repl.history';
61
+ const FILTER_HISTORY_STORAGE_KEY = 'debug.repl.filterHistory';
62
+ const FILTER_VALUE_STORAGE_KEY = 'debug.repl.filterValue';
63
+ const DECORATION_KEY = 'replinputdecoration';
64
+ function revealLastElement(tree) {
65
+ tree.scrollTop = tree.scrollHeight - tree.renderHeight;
66
+ }
67
+ const sessionsToIgnore = ( (new Set()));
68
+ const identityProvider = { getId: (element) => element.getId() };
69
+ let Repl = class Repl extends FilterViewPane {
70
+ static { Repl_1 = this; }
71
+ static { this.REFRESH_DELAY = 50; }
72
+ static { this.URI = ( URI.parse(`${DEBUG_SCHEME}:replinput`)); }
73
+ constructor(options, debugService, instantiationService, storageService, themeService, modelService, contextKeyService, codeEditorService, viewDescriptorService, contextMenuService, configurationService, textResourcePropertiesService, editorService, keybindingService, openerService, telemetryService, menuService, languageFeaturesService, logService) {
74
+ const filterText = storageService.get(FILTER_VALUE_STORAGE_KEY, 1 , '');
75
+ super({
76
+ ...options,
77
+ filterOptions: {
78
+ placeholder: ( (localize(
79
+ { key: 'workbench.debug.filter.placeholder', comment: ['Text in the brackets after e.g. is not localizable'] },
80
+ "Filter (e.g. text, !exclude)"
81
+ ))),
82
+ text: filterText,
83
+ history: JSON.parse(storageService.get(FILTER_HISTORY_STORAGE_KEY, 1 , '[]')),
84
+ }
85
+ }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
86
+ this.debugService = debugService;
87
+ this.storageService = storageService;
88
+ this.modelService = modelService;
89
+ this.textResourcePropertiesService = textResourcePropertiesService;
90
+ this.editorService = editorService;
91
+ this.languageFeaturesService = languageFeaturesService;
92
+ this.logService = logService;
93
+ this.previousTreeScrollHeight = 0;
94
+ this.replInputLineCount = 1;
95
+ this.modelChangeListener = Disposable.None;
96
+ this.menu = menuService.createMenu(MenuId.DebugConsoleContext, contextKeyService);
97
+ this._register(this.menu);
98
+ this.history = ( (new HistoryNavigator(
99
+ JSON.parse(this.storageService.get(HISTORY_STORAGE_KEY, 1 , '[]')),
100
+ 50
101
+ )));
102
+ this.filter = ( (new ReplFilter()));
103
+ this.filter.filterQuery = filterText;
104
+ this.multiSessionRepl = CONTEXT_MULTI_SESSION_REPL.bindTo(contextKeyService);
105
+ this.replOptions = this._register(this.instantiationService.createInstance(ReplOptions, this.id, () => this.getBackgroundColor()));
106
+ this._register(this.replOptions.onDidChange(() => this.onDidStyleChange()));
107
+ codeEditorService.registerDecorationType('repl-decoration', DECORATION_KEY, {});
108
+ this.multiSessionRepl.set(this.isMultiSessionView);
109
+ this.registerListeners();
110
+ }
111
+ registerListeners() {
112
+ if (this.debugService.getViewModel().focusedSession) {
113
+ this.onDidFocusSession(this.debugService.getViewModel().focusedSession);
114
+ }
115
+ this._register(this.debugService.getViewModel().onDidFocusSession(async (session) => this.onDidFocusSession(session)));
116
+ this._register(this.debugService.getViewModel().onDidEvaluateLazyExpression(async (e) => {
117
+ if (e instanceof Variable && this.tree?.hasNode(e)) {
118
+ await this.tree.updateChildren(e, false, true);
119
+ await this.tree.expand(e);
120
+ }
121
+ }));
122
+ this._register(this.debugService.onWillNewSession(async (newSession) => {
123
+ const input = this.tree?.getInput();
124
+ if (!input || input.state === 0 ) {
125
+ await this.selectSession(newSession);
126
+ }
127
+ this.multiSessionRepl.set(this.isMultiSessionView);
128
+ }));
129
+ this._register(this.debugService.onDidEndSession(async (session) => {
130
+ await Promise.resolve();
131
+ this.multiSessionRepl.set(this.isMultiSessionView);
132
+ }));
133
+ this._register(this.themeService.onDidColorThemeChange(() => {
134
+ this.refreshReplElements(false);
135
+ if (this.isVisible()) {
136
+ this.updateInputDecoration();
137
+ }
138
+ }));
139
+ this._register(this.onDidChangeBodyVisibility(visible => {
140
+ if (visible) {
141
+ if (!this.model) {
142
+ this.model = this.modelService.getModel(Repl_1.URI) || this.modelService.createModel('', null, Repl_1.URI, true);
143
+ }
144
+ this.setMode();
145
+ this.replInput.setModel(this.model);
146
+ this.updateInputDecoration();
147
+ this.refreshReplElements(true);
148
+ }
149
+ }));
150
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
151
+ if (e.affectsConfiguration('debug.console.wordWrap') && this.tree) {
152
+ this.tree.dispose();
153
+ this.treeContainer.innerText = '';
154
+ dom.clearNode(this.treeContainer);
155
+ this.createReplTree();
156
+ }
157
+ if (e.affectsConfiguration('debug.console.acceptSuggestionOnEnter')) {
158
+ const config = this.configurationService.getValue('debug');
159
+ this.replInput.updateOptions({
160
+ acceptSuggestionOnEnter: config.console.acceptSuggestionOnEnter === 'on' ? 'on' : 'off'
161
+ });
162
+ }
163
+ }));
164
+ this._register(this.editorService.onDidActiveEditorChange(() => {
165
+ this.setMode();
166
+ }));
167
+ this._register(this.filterWidget.onDidChangeFilterText(() => {
168
+ this.filter.filterQuery = this.filterWidget.getFilterText();
169
+ if (this.tree) {
170
+ this.tree.refilter();
171
+ revealLastElement(this.tree);
172
+ }
173
+ }));
174
+ }
175
+ async onDidFocusSession(session) {
176
+ if (session) {
177
+ sessionsToIgnore.delete(session);
178
+ this.completionItemProvider?.dispose();
179
+ if (session.capabilities.supportsCompletionsRequest) {
180
+ this.completionItemProvider = this.languageFeaturesService.completionProvider.register({ scheme: DEBUG_SCHEME, pattern: '**/replinput', hasAccessToAllModels: true }, {
181
+ _debugDisplayName: 'debugConsole',
182
+ triggerCharacters: session.capabilities.completionTriggerCharacters || ['.'],
183
+ provideCompletionItems: async (_, position, _context, token) => {
184
+ this.setHistoryNavigationEnablement(false);
185
+ const model = this.replInput.getModel();
186
+ if (model) {
187
+ const word = model.getWordAtPosition(position);
188
+ const overwriteBefore = word ? word.word.length : 0;
189
+ const text = model.getValue();
190
+ const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
191
+ const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
192
+ const response = await session.completions(frameId, focusedStackFrame?.thread.threadId || 0, text, position, overwriteBefore, token);
193
+ const suggestions = [];
194
+ const computeRange = (length) => Range.fromPositions(position.delta(0, -length), position);
195
+ if (response && response.body && response.body.targets) {
196
+ response.body.targets.forEach(item => {
197
+ if (item && item.label) {
198
+ let insertTextRules = undefined;
199
+ let insertText = item.text || item.label;
200
+ if (typeof item.selectionStart === 'number') {
201
+ insertTextRules = 4 ;
202
+ const selectionLength = typeof item.selectionLength === 'number' ? item.selectionLength : 0;
203
+ const placeholder = selectionLength > 0 ? '${1:' + insertText.substring(item.selectionStart, item.selectionStart + selectionLength) + '}$0' : '$0';
204
+ insertText = insertText.substring(0, item.selectionStart) + placeholder + insertText.substring(item.selectionStart + selectionLength);
205
+ }
206
+ suggestions.push({
207
+ label: item.label,
208
+ insertText,
209
+ detail: item.detail,
210
+ kind: CompletionItemKinds.fromString(item.type || 'property'),
211
+ filterText: (item.start && item.length) ? text.substring(item.start, item.start + item.length).concat(item.label) : undefined,
212
+ range: computeRange(item.length || overwriteBefore),
213
+ sortText: item.sortText,
214
+ insertTextRules
215
+ });
216
+ }
217
+ });
218
+ }
219
+ if (this.configurationService.getValue('debug').console.historySuggestions) {
220
+ const history = this.history.getHistory();
221
+ const idxLength = String(history.length).length;
222
+ history.forEach((h, i) => suggestions.push({
223
+ label: h,
224
+ insertText: h,
225
+ kind: 18 ,
226
+ range: computeRange(h.length),
227
+ sortText: 'ZZZ' + String(history.length - i).padStart(idxLength, '0')
228
+ }));
229
+ }
230
+ return { suggestions };
231
+ }
232
+ return Promise.resolve({ suggestions: [] });
233
+ }
234
+ });
235
+ }
236
+ }
237
+ await this.selectSession();
238
+ }
239
+ getFilterStats() {
240
+ return {
241
+ total: this.tree?.getNode().children.length ?? 0,
242
+ filtered: this.tree?.getNode().children.filter(c => c.visible).length ?? 0
243
+ };
244
+ }
245
+ get isReadonly() {
246
+ const session = this.tree?.getInput();
247
+ if (session && session.state !== 0 ) {
248
+ return false;
249
+ }
250
+ return true;
251
+ }
252
+ showPreviousValue() {
253
+ if (!this.isReadonly) {
254
+ this.navigateHistory(true);
255
+ }
256
+ }
257
+ showNextValue() {
258
+ if (!this.isReadonly) {
259
+ this.navigateHistory(false);
260
+ }
261
+ }
262
+ focusFilter() {
263
+ this.filterWidget.focus();
264
+ }
265
+ setMode() {
266
+ if (!this.isVisible()) {
267
+ return;
268
+ }
269
+ const activeEditorControl = this.editorService.activeTextEditorControl;
270
+ if (isCodeEditor(activeEditorControl)) {
271
+ this.modelChangeListener.dispose();
272
+ this.modelChangeListener = activeEditorControl.onDidChangeModelLanguage(() => this.setMode());
273
+ if (this.model && activeEditorControl.hasModel()) {
274
+ this.model.setLanguage(activeEditorControl.getModel().getLanguageId());
275
+ }
276
+ }
277
+ }
278
+ onDidStyleChange() {
279
+ if (this.styleElement) {
280
+ this.replInput.updateOptions({
281
+ fontSize: this.replOptions.replConfiguration.fontSize,
282
+ lineHeight: this.replOptions.replConfiguration.lineHeight,
283
+ fontFamily: this.replOptions.replConfiguration.fontFamily === 'default' ? EDITOR_FONT_DEFAULTS.fontFamily : this.replOptions.replConfiguration.fontFamily
284
+ });
285
+ const replInputLineHeight = this.replInput.getOption(65 );
286
+ this.styleElement.textContent = `
287
+ .repl .repl-input-wrapper .repl-input-chevron {
288
+ line-height: ${replInputLineHeight}px
289
+ }
290
+
291
+ .repl .repl-input-wrapper .monaco-editor .lines-content {
292
+ background-color: ${this.replOptions.replConfiguration.backgroundColor};
293
+ }
294
+ `;
295
+ const cssFontFamily = this.replOptions.replConfiguration.fontFamily === 'default' ? 'var(--monaco-monospace-font)' : this.replOptions.replConfiguration.fontFamily;
296
+ this.container.style.setProperty(`--vscode-repl-font-family`, cssFontFamily);
297
+ this.container.style.setProperty(`--vscode-repl-font-size`, `${this.replOptions.replConfiguration.fontSize}px`);
298
+ this.container.style.setProperty(`--vscode-repl-font-size-for-twistie`, `${this.replOptions.replConfiguration.fontSizeForTwistie}px`);
299
+ this.container.style.setProperty(`--vscode-repl-line-height`, this.replOptions.replConfiguration.cssLineHeight);
300
+ this.tree?.rerender();
301
+ if (this.bodyContentDimension) {
302
+ this.layoutBodyContent(this.bodyContentDimension.height, this.bodyContentDimension.width);
303
+ }
304
+ }
305
+ }
306
+ navigateHistory(previous) {
307
+ const historyInput = (previous ?
308
+ (this.history.previous() ?? this.history.first()) : this.history.next())
309
+ ?? '';
310
+ this.replInput.setValue(historyInput);
311
+ aria.status(historyInput);
312
+ this.replInput.setPosition({ lineNumber: 1, column: historyInput.length + 1 });
313
+ this.setHistoryNavigationEnablement(true);
314
+ }
315
+ async selectSession(session) {
316
+ const treeInput = this.tree?.getInput();
317
+ if (!session) {
318
+ const focusedSession = this.debugService.getViewModel().focusedSession;
319
+ if (focusedSession) {
320
+ session = focusedSession;
321
+ }
322
+ else if (!treeInput || ( (sessionsToIgnore.has(treeInput)))) {
323
+ session = this.debugService.getModel().getSessions(true).find(s => !( (sessionsToIgnore.has(s))));
324
+ }
325
+ }
326
+ if (session) {
327
+ this.replElementsChangeListener?.dispose();
328
+ this.replElementsChangeListener = session.onDidChangeReplElements(() => {
329
+ this.refreshReplElements(session.getReplElements().length === 0);
330
+ });
331
+ if (this.tree && treeInput !== session) {
332
+ try {
333
+ await this.tree.setInput(session);
334
+ }
335
+ catch (err) {
336
+ this.logService.error(err);
337
+ }
338
+ revealLastElement(this.tree);
339
+ }
340
+ }
341
+ this.replInput?.updateOptions({ readOnly: this.isReadonly });
342
+ this.updateInputDecoration();
343
+ }
344
+ async clearRepl() {
345
+ const session = this.tree?.getInput();
346
+ if (session) {
347
+ session.removeReplExpressions();
348
+ if (session.state === 0 ) {
349
+ sessionsToIgnore.add(session);
350
+ await this.selectSession();
351
+ this.multiSessionRepl.set(this.isMultiSessionView);
352
+ }
353
+ }
354
+ this.replInput.focus();
355
+ }
356
+ acceptReplInput() {
357
+ const session = this.tree?.getInput();
358
+ if (session && !this.isReadonly) {
359
+ session.addReplExpression(this.debugService.getViewModel().focusedStackFrame, this.replInput.getValue());
360
+ revealLastElement(this.tree);
361
+ this.history.add(this.replInput.getValue());
362
+ this.replInput.setValue('');
363
+ const shouldRelayout = this.replInputLineCount > 1;
364
+ this.replInputLineCount = 1;
365
+ if (shouldRelayout && this.bodyContentDimension) {
366
+ this.layoutBodyContent(this.bodyContentDimension.height, this.bodyContentDimension.width);
367
+ }
368
+ }
369
+ }
370
+ getVisibleContent() {
371
+ let text = '';
372
+ if (this.model && this.tree) {
373
+ const lineDelimiter = this.textResourcePropertiesService.getEOL(this.model.uri);
374
+ const traverseAndAppend = (node) => {
375
+ node.children.forEach(child => {
376
+ if (child.visible) {
377
+ text += ( (child.element.toString())).trimRight() + lineDelimiter;
378
+ if (!child.collapsed && child.children.length) {
379
+ traverseAndAppend(child);
380
+ }
381
+ }
382
+ });
383
+ };
384
+ traverseAndAppend(this.tree.getNode());
385
+ }
386
+ return removeAnsiEscapeCodes(text);
387
+ }
388
+ layoutBodyContent(height, width) {
389
+ this.bodyContentDimension = new dom.Dimension(width, height);
390
+ const replInputHeight = Math.min(this.replInput.getContentHeight(), height);
391
+ if (this.tree) {
392
+ const lastElementVisible = this.tree.scrollTop + this.tree.renderHeight >= this.tree.scrollHeight;
393
+ const treeHeight = height - replInputHeight;
394
+ this.tree.getHTMLElement().style.height = `${treeHeight}px`;
395
+ this.tree.layout(treeHeight, width);
396
+ if (lastElementVisible) {
397
+ revealLastElement(this.tree);
398
+ }
399
+ }
400
+ this.replInputContainer.style.height = `${replInputHeight}px`;
401
+ this.replInput.layout({ width: width - 30, height: replInputHeight });
402
+ }
403
+ collapseAll() {
404
+ this.tree?.collapseAll();
405
+ }
406
+ getReplInput() {
407
+ return this.replInput;
408
+ }
409
+ focus() {
410
+ setTimeout(() => this.replInput.focus(), 0);
411
+ }
412
+ getActionViewItem(action) {
413
+ if (action.id === selectReplCommandId) {
414
+ const session = (this.tree ? this.tree.getInput() : undefined) ?? this.debugService.getViewModel().focusedSession;
415
+ return this.instantiationService.createInstance(SelectReplActionViewItem, action, session);
416
+ }
417
+ return super.getActionViewItem(action);
418
+ }
419
+ get isMultiSessionView() {
420
+ return this.debugService.getModel().getSessions(true).filter(s => s.hasSeparateRepl() && !( (sessionsToIgnore.has(s)))).length > 1;
421
+ }
422
+ get refreshScheduler() {
423
+ const autoExpanded = ( (new Set()));
424
+ return (
425
+ (new RunOnceScheduler(async () => {
426
+ if (!this.tree) {
427
+ return;
428
+ }
429
+ if (!this.tree.getInput()) {
430
+ return;
431
+ }
432
+ await this.tree.updateChildren(undefined, true, false, { diffIdentityProvider: identityProvider });
433
+ const session = this.tree.getInput();
434
+ if (session) {
435
+ const autoExpandElements = async (elements) => {
436
+ for (const element of elements) {
437
+ if (element instanceof ReplGroup) {
438
+ if (element.autoExpand && !( (autoExpanded.has(element.getId())))) {
439
+ autoExpanded.add(element.getId());
440
+ await this.tree.expand(element);
441
+ }
442
+ if (!this.tree.isCollapsed(element)) {
443
+ await autoExpandElements(element.getChildren());
444
+ }
445
+ }
446
+ }
447
+ };
448
+ await autoExpandElements(session.getReplElements());
449
+ }
450
+ const { total, filtered } = this.getFilterStats();
451
+ this.filterWidget.updateBadge(total === filtered || total === 0 ? undefined : ( (localize('showing filtered repl lines', "Showing {0} of {1}", filtered, total))));
452
+ }, Repl_1.REFRESH_DELAY))
453
+ );
454
+ }
455
+ render() {
456
+ super.render();
457
+ this._register(registerNavigableContainer({
458
+ focusNotifiers: [this, this.filterWidget],
459
+ focusNextWidget: () => {
460
+ if (this.filterWidget.hasFocus()) {
461
+ this.tree?.domFocus();
462
+ }
463
+ else if (this.tree?.getHTMLElement() === document.activeElement) {
464
+ this.focus();
465
+ }
466
+ },
467
+ focusPreviousWidget: () => {
468
+ if (this.replInput.hasTextFocus()) {
469
+ this.tree?.domFocus();
470
+ }
471
+ else if (this.tree?.getHTMLElement() === document.activeElement) {
472
+ this.focusFilter();
473
+ }
474
+ }
475
+ }));
476
+ }
477
+ renderBody(parent) {
478
+ super.renderBody(parent);
479
+ this.container = dom.append(parent, $('.repl'));
480
+ this.treeContainer = dom.append(this.container, $(`.repl-tree.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
481
+ this.createReplInput(this.container);
482
+ this.createReplTree();
483
+ }
484
+ createReplTree() {
485
+ this.replDelegate = ( (new ReplDelegate(this.configurationService, this.replOptions)));
486
+ const wordWrap = this.configurationService.getValue('debug').console.wordWrap;
487
+ this.treeContainer.classList.toggle('word-wrap', wordWrap);
488
+ const linkDetector = this.instantiationService.createInstance(LinkDetector);
489
+ const tree = this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, 'DebugRepl', this.treeContainer, this.replDelegate, [
490
+ this.instantiationService.createInstance(ReplVariablesRenderer, linkDetector),
491
+ this.instantiationService.createInstance(ReplOutputElementRenderer, linkDetector),
492
+ ( (new ReplEvaluationInputsRenderer())),
493
+ this.instantiationService.createInstance(ReplGroupRenderer, linkDetector),
494
+ ( (new ReplEvaluationResultsRenderer(linkDetector))),
495
+ ( (new ReplRawObjectsRenderer(linkDetector))),
496
+ ],
497
+ (
498
+ (new ReplDataSource())), {
499
+ filter: this.filter,
500
+ accessibilityProvider: ( (new ReplAccessibilityProvider())),
501
+ identityProvider,
502
+ mouseSupport: false,
503
+ findWidgetEnabled: false,
504
+ keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e) => ( (e.toString(true))) },
505
+ horizontalScrolling: !wordWrap,
506
+ setRowLineHeight: false,
507
+ supportDynamicHeights: wordWrap,
508
+ overrideStyles: {
509
+ listBackground: this.getBackgroundColor()
510
+ }
511
+ });
512
+ this._register(tree.onDidChangeContentHeight(() => {
513
+ if (tree.scrollHeight !== this.previousTreeScrollHeight) {
514
+ const lastElementWasVisible = tree.scrollTop + tree.renderHeight >= this.previousTreeScrollHeight - 2;
515
+ if (lastElementWasVisible) {
516
+ setTimeout(() => {
517
+ revealLastElement(tree);
518
+ }, 0);
519
+ }
520
+ }
521
+ this.previousTreeScrollHeight = tree.scrollHeight;
522
+ }));
523
+ this._register(tree.onContextMenu(e => this.onContextMenu(e)));
524
+ let lastSelectedString;
525
+ this._register(tree.onMouseClick(() => {
526
+ const selection = window.getSelection();
527
+ if (!selection || selection.type !== 'Range' || lastSelectedString === ( (selection.toString()))) {
528
+ this.replInput.focus();
529
+ }
530
+ lastSelectedString = selection ? ( (selection.toString())) : '';
531
+ }));
532
+ this.selectSession();
533
+ this.styleElement = dom.createStyleSheet(this.container);
534
+ this.onDidStyleChange();
535
+ }
536
+ createReplInput(container) {
537
+ this.replInputContainer = dom.append(container, $('.repl-input-wrapper'));
538
+ dom.append(this.replInputContainer, $('.repl-input-chevron' + ThemeIcon.asCSSSelector(debugConsoleEvaluationPrompt)));
539
+ const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(this.scopedContextKeyService, this));
540
+ this.setHistoryNavigationEnablement = enabled => {
541
+ historyNavigationBackwardsEnablement.set(enabled);
542
+ historyNavigationForwardsEnablement.set(enabled);
543
+ };
544
+ CONTEXT_IN_DEBUG_REPL.bindTo(this.scopedContextKeyService).set(true);
545
+ this.scopedInstantiationService = this.instantiationService.createChild(( (new ServiceCollection([IContextKeyService, this.scopedContextKeyService]))));
546
+ const options = getSimpleEditorOptions(this.configurationService);
547
+ options.readOnly = true;
548
+ options.suggest = { showStatusBar: true };
549
+ const config = this.configurationService.getValue('debug');
550
+ options.acceptSuggestionOnEnter = config.console.acceptSuggestionOnEnter === 'on' ? 'on' : 'off';
551
+ options.ariaLabel = ( (localize('debugConsole', "Debug Console")));
552
+ this.replInput = this.scopedInstantiationService.createInstance(CodeEditorWidget, this.replInputContainer, options, getSimpleCodeEditorWidgetOptions());
553
+ this._register(this.replInput.onDidChangeModelContent(() => {
554
+ const model = this.replInput.getModel();
555
+ this.setHistoryNavigationEnablement(!!model && model.getValue() === '');
556
+ const lineCount = model ? Math.min(10, model.getLineCount()) : 1;
557
+ if (lineCount !== this.replInputLineCount) {
558
+ this.replInputLineCount = lineCount;
559
+ if (this.bodyContentDimension) {
560
+ this.layoutBodyContent(this.bodyContentDimension.height, this.bodyContentDimension.width);
561
+ }
562
+ }
563
+ }));
564
+ this._register(this.replInput.onDidFocusEditorText(() => this.updateInputDecoration()));
565
+ this._register(this.replInput.onDidBlurEditorText(() => this.updateInputDecoration()));
566
+ this._register(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.FOCUS, () => this.replInputContainer.classList.add('synthetic-focus')));
567
+ this._register(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.BLUR, () => this.replInputContainer.classList.remove('synthetic-focus')));
568
+ }
569
+ onContextMenu(e) {
570
+ const actions = [];
571
+ createAndFillInContextMenuActions(this.menu, { arg: e.element, shouldForwardArgs: false }, actions);
572
+ this.contextMenuService.showContextMenu({
573
+ getAnchor: () => e.anchor,
574
+ getActions: () => actions,
575
+ getActionsContext: () => e.element
576
+ });
577
+ }
578
+ refreshReplElements(noDelay) {
579
+ if (this.tree && this.isVisible()) {
580
+ if (this.refreshScheduler.isScheduled()) {
581
+ return;
582
+ }
583
+ this.refreshScheduler.schedule(noDelay ? 0 : undefined);
584
+ }
585
+ }
586
+ updateInputDecoration() {
587
+ if (!this.replInput) {
588
+ return;
589
+ }
590
+ const decorations = [];
591
+ if (this.isReadonly && this.replInput.hasTextFocus() && !this.replInput.getValue()) {
592
+ const transparentForeground = resolveColorValue(editorForeground, this.themeService.getColorTheme())?.transparent(0.4);
593
+ decorations.push({
594
+ range: {
595
+ startLineNumber: 0,
596
+ endLineNumber: 0,
597
+ startColumn: 0,
598
+ endColumn: 1
599
+ },
600
+ renderOptions: {
601
+ after: {
602
+ contentText: ( (localize('startDebugFirst', "Please start a debug session to evaluate expressions"))),
603
+ color: transparentForeground ? ( (transparentForeground.toString())) : undefined
604
+ }
605
+ }
606
+ });
607
+ }
608
+ this.replInput.setDecorationsByType('repl-decoration', DECORATION_KEY, decorations);
609
+ }
610
+ saveState() {
611
+ const replHistory = this.history.getHistory();
612
+ if (replHistory.length) {
613
+ this.storageService.store(HISTORY_STORAGE_KEY, JSON.stringify(replHistory), 1 , 1 );
614
+ }
615
+ else {
616
+ this.storageService.remove(HISTORY_STORAGE_KEY, 1 );
617
+ }
618
+ const filterHistory = this.filterWidget.getHistory();
619
+ if (filterHistory.length) {
620
+ this.storageService.store(FILTER_HISTORY_STORAGE_KEY, JSON.stringify(filterHistory), 1 , 1 );
621
+ }
622
+ else {
623
+ this.storageService.remove(FILTER_HISTORY_STORAGE_KEY, 1 );
624
+ }
625
+ const filterValue = this.filterWidget.getFilterText();
626
+ if (filterValue) {
627
+ this.storageService.store(FILTER_VALUE_STORAGE_KEY, filterValue, 1 , 1 );
628
+ }
629
+ else {
630
+ this.storageService.remove(FILTER_VALUE_STORAGE_KEY, 1 );
631
+ }
632
+ super.saveState();
633
+ }
634
+ dispose() {
635
+ this.replInput?.dispose();
636
+ this.replElementsChangeListener?.dispose();
637
+ this.refreshScheduler.dispose();
638
+ this.modelChangeListener.dispose();
639
+ super.dispose();
640
+ }
641
+ };
642
+ Repl.__decorator = ( (__decorate([
643
+ memoize
644
+ ], Repl.prototype, "refreshScheduler", null)));
645
+ Repl = Repl_1 = ( (__decorate([
646
+ ( (__param(1, IDebugService))),
647
+ ( (__param(2, IInstantiationService))),
648
+ ( (__param(3, IStorageService))),
649
+ ( (__param(4, IThemeService))),
650
+ ( (__param(5, IModelService))),
651
+ ( (__param(6, IContextKeyService))),
652
+ ( (__param(7, ICodeEditorService))),
653
+ ( (__param(8, IViewDescriptorService))),
654
+ ( (__param(9, IContextMenuService))),
655
+ ( (__param(10, IConfigurationService))),
656
+ ( (__param(11, ITextResourcePropertiesService))),
657
+ ( (__param(12, IEditorService))),
658
+ ( (__param(13, IKeybindingService))),
659
+ ( (__param(14, IOpenerService))),
660
+ ( (__param(15, ITelemetryService))),
661
+ ( (__param(16, IMenuService))),
662
+ ( (__param(17, ILanguageFeaturesService))),
663
+ ( (__param(18, ILogService)))
664
+ ], Repl)));
665
+ let ReplOptions = class ReplOptions extends Disposable {
666
+ static { ReplOptions_1 = this; }
667
+ static { this.lineHeightEm = 1.4; }
668
+ get replConfiguration() {
669
+ return this._replConfig;
670
+ }
671
+ constructor(viewId, backgroundColorDelegate, configurationService, themeService, viewDescriptorService) {
672
+ super();
673
+ this.backgroundColorDelegate = backgroundColorDelegate;
674
+ this.configurationService = configurationService;
675
+ this.themeService = themeService;
676
+ this.viewDescriptorService = viewDescriptorService;
677
+ this._onDidChange = this._register(( (new Emitter())));
678
+ this.onDidChange = this._onDidChange.event;
679
+ this._register(this.themeService.onDidColorThemeChange(e => this.update()));
680
+ this._register(this.viewDescriptorService.onDidChangeLocation(e => {
681
+ if (( (e.views.some(v => v.id === viewId)))) {
682
+ this.update();
683
+ }
684
+ }));
685
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
686
+ if (e.affectsConfiguration('debug.console.lineHeight') || e.affectsConfiguration('debug.console.fontSize') || e.affectsConfiguration('debug.console.fontFamily')) {
687
+ this.update();
688
+ }
689
+ }));
690
+ this.update();
691
+ }
692
+ update() {
693
+ const debugConsole = this.configurationService.getValue('debug').console;
694
+ this._replConfig = {
695
+ fontSize: debugConsole.fontSize,
696
+ fontFamily: debugConsole.fontFamily,
697
+ lineHeight: debugConsole.lineHeight ? debugConsole.lineHeight : ReplOptions_1.lineHeightEm * debugConsole.fontSize,
698
+ cssLineHeight: debugConsole.lineHeight ? `${debugConsole.lineHeight}px` : `${ReplOptions_1.lineHeightEm}em`,
699
+ backgroundColor: this.themeService.getColorTheme().getColor(this.backgroundColorDelegate()),
700
+ fontSizeForTwistie: debugConsole.fontSize * ReplOptions_1.lineHeightEm / 2 - 8
701
+ };
702
+ this._onDidChange.fire();
703
+ }
704
+ };
705
+ ReplOptions = ReplOptions_1 = ( (__decorate([
706
+ ( (__param(2, IConfigurationService))),
707
+ ( (__param(3, IThemeService))),
708
+ ( (__param(4, IViewDescriptorService)))
709
+ ], ReplOptions)));
710
+ class AcceptReplInputAction extends EditorAction {
711
+ constructor() {
712
+ super({
713
+ id: 'repl.action.acceptInput',
714
+ label: ( (localize(
715
+ { key: 'actions.repl.acceptInput', comment: ['Apply input from the debug console input box'] },
716
+ "REPL Accept Input"
717
+ ))),
718
+ alias: 'REPL Accept Input',
719
+ precondition: CONTEXT_IN_DEBUG_REPL,
720
+ kbOpts: {
721
+ kbExpr: EditorContextKeys.textInputFocus,
722
+ primary: 3 ,
723
+ weight: 100
724
+ }
725
+ });
726
+ }
727
+ run(accessor, editor) {
728
+ SuggestController.get(editor)?.cancelSuggestWidget();
729
+ const repl = getReplView(accessor.get(IViewsService));
730
+ repl?.acceptReplInput();
731
+ }
732
+ }
733
+ class FilterReplAction extends EditorAction {
734
+ constructor() {
735
+ super({
736
+ id: 'repl.action.filter',
737
+ label: ( (localize('repl.action.filter', "REPL Focus Content to Filter"))),
738
+ alias: 'REPL Filter',
739
+ precondition: CONTEXT_IN_DEBUG_REPL,
740
+ kbOpts: {
741
+ kbExpr: EditorContextKeys.textInputFocus,
742
+ primary: 2048 | 36 ,
743
+ weight: 100
744
+ }
745
+ });
746
+ }
747
+ run(accessor, editor) {
748
+ const repl = getReplView(accessor.get(IViewsService));
749
+ repl?.focusFilter();
750
+ }
751
+ }
752
+ class ReplCopyAllAction extends EditorAction {
753
+ constructor() {
754
+ super({
755
+ id: 'repl.action.copyAll',
756
+ label: ( (localize('actions.repl.copyAll', "Debug: Console Copy All"))),
757
+ alias: 'Debug Console Copy All',
758
+ precondition: CONTEXT_IN_DEBUG_REPL,
759
+ });
760
+ }
761
+ run(accessor, editor) {
762
+ const clipboardService = accessor.get(IClipboardService);
763
+ const repl = getReplView(accessor.get(IViewsService));
764
+ if (repl) {
765
+ return clipboardService.writeText(repl.getVisibleContent());
766
+ }
767
+ }
768
+ }
769
+ registerEditorAction(AcceptReplInputAction);
770
+ registerEditorAction(ReplCopyAllAction);
771
+ registerEditorAction(FilterReplAction);
772
+ class SelectReplActionViewItem extends FocusSessionActionViewItem {
773
+ getSessions() {
774
+ return this.debugService.getModel().getSessions(true).filter(s => s.hasSeparateRepl() && !( (sessionsToIgnore.has(s))));
775
+ }
776
+ mapFocusedSessionToSelected(focusedSession) {
777
+ while (focusedSession.parentSession && !focusedSession.hasSeparateRepl()) {
778
+ focusedSession = focusedSession.parentSession;
779
+ }
780
+ return focusedSession;
781
+ }
782
+ }
783
+ function getReplView(viewsService) {
784
+ return viewsService.getActiveViewWithId(REPL_VIEW_ID) ?? undefined;
785
+ }
786
+ const selectReplCommandId = 'workbench.action.debug.selectRepl';
787
+ registerAction2(class extends ViewAction {
788
+ constructor() {
789
+ super({
790
+ id: selectReplCommandId,
791
+ viewId: REPL_VIEW_ID,
792
+ title: ( (localize('selectRepl', "Select Debug Console"))),
793
+ f1: false,
794
+ menu: {
795
+ id: MenuId.ViewTitle,
796
+ group: 'navigation',
797
+ when: ( (ContextKeyExpr.and(
798
+ (ContextKeyExpr.equals('view', REPL_VIEW_ID)),
799
+ CONTEXT_MULTI_SESSION_REPL
800
+ ))),
801
+ order: 20
802
+ }
803
+ });
804
+ }
805
+ async runInView(accessor, view, session) {
806
+ const debugService = accessor.get(IDebugService);
807
+ if (session && session.state !== 0 && session !== debugService.getViewModel().focusedSession) {
808
+ if (session.state !== 2 ) {
809
+ const stopppedChildSession = debugService.getModel().getSessions().find(s => s.parentSession === session && s.state === 2 );
810
+ if (stopppedChildSession) {
811
+ session = stopppedChildSession;
812
+ }
813
+ }
814
+ await debugService.focusStackFrame(undefined, undefined, session, { explicit: true });
815
+ }
816
+ await view.selectSession(session);
817
+ }
818
+ });
819
+ registerAction2(class extends ViewAction {
820
+ constructor() {
821
+ super({
822
+ id: 'workbench.debug.panel.action.clearReplAction',
823
+ viewId: REPL_VIEW_ID,
824
+ title: { value: ( (localize('clearRepl', "Clear Console"))), original: 'Clear Console' },
825
+ f1: true,
826
+ icon: debugConsoleClearAll,
827
+ menu: [{
828
+ id: MenuId.ViewTitle,
829
+ group: 'navigation',
830
+ when: ( (ContextKeyExpr.equals('view', REPL_VIEW_ID))),
831
+ order: 30
832
+ }, {
833
+ id: MenuId.DebugConsoleContext,
834
+ group: 'z_commands',
835
+ order: 20
836
+ }]
837
+ });
838
+ }
839
+ runInView(_accessor, view) {
840
+ view.clearRepl();
841
+ aria.status(( (localize('debugConsoleCleared', "Debug console was cleared"))));
842
+ }
843
+ });
844
+ registerAction2(class extends ViewAction {
845
+ constructor() {
846
+ super({
847
+ id: 'debug.collapseRepl',
848
+ title: ( (localize('collapse', "Collapse All"))),
849
+ viewId: REPL_VIEW_ID,
850
+ menu: {
851
+ id: MenuId.DebugConsoleContext,
852
+ group: 'z_commands',
853
+ order: 10
854
+ }
855
+ });
856
+ }
857
+ runInView(_accessor, view) {
858
+ view.collapseAll();
859
+ view.focus();
860
+ }
861
+ });
862
+ registerAction2(class extends ViewAction {
863
+ constructor() {
864
+ super({
865
+ id: 'debug.replPaste',
866
+ title: ( (localize('paste', "Paste"))),
867
+ viewId: REPL_VIEW_ID,
868
+ precondition: ( (CONTEXT_DEBUG_STATE.notEqualsTo(getStateLabel(0 )))),
869
+ menu: {
870
+ id: MenuId.DebugConsoleContext,
871
+ group: '2_cutcopypaste',
872
+ order: 30
873
+ }
874
+ });
875
+ }
876
+ async runInView(accessor, view) {
877
+ const clipboardService = accessor.get(IClipboardService);
878
+ const clipboardText = await clipboardService.readText();
879
+ if (clipboardText) {
880
+ const replInput = view.getReplInput();
881
+ replInput.setValue(replInput.getValue().concat(clipboardText));
882
+ view.focus();
883
+ const model = replInput.getModel();
884
+ const lineNumber = model ? model.getLineCount() : 0;
885
+ const column = model?.getLineMaxColumn(lineNumber);
886
+ if (typeof lineNumber === 'number' && typeof column === 'number') {
887
+ replInput.setPosition({ lineNumber, column });
888
+ }
889
+ }
890
+ }
891
+ });
892
+ registerAction2(class extends ViewAction {
893
+ constructor() {
894
+ super({
895
+ id: 'workbench.debug.action.copyAll',
896
+ title: ( (localize('copyAll', "Copy All"))),
897
+ viewId: REPL_VIEW_ID,
898
+ menu: {
899
+ id: MenuId.DebugConsoleContext,
900
+ group: '2_cutcopypaste',
901
+ order: 20
902
+ }
903
+ });
904
+ }
905
+ async runInView(accessor, view) {
906
+ const clipboardService = accessor.get(IClipboardService);
907
+ await clipboardService.writeText(view.getVisibleContent());
908
+ }
909
+ });
910
+ registerAction2(class extends Action2 {
911
+ constructor() {
912
+ super({
913
+ id: 'debug.replCopy',
914
+ title: ( (localize('copy', "Copy"))),
915
+ menu: {
916
+ id: MenuId.DebugConsoleContext,
917
+ group: '2_cutcopypaste',
918
+ order: 10
919
+ }
920
+ });
921
+ }
922
+ async run(accessor, element) {
923
+ const clipboardService = accessor.get(IClipboardService);
924
+ const debugService = accessor.get(IDebugService);
925
+ const nativeSelection = window.getSelection();
926
+ const selectedText = nativeSelection?.toString();
927
+ if (selectedText && selectedText.length > 0) {
928
+ return clipboardService.writeText(selectedText);
929
+ }
930
+ else if (element) {
931
+ return clipboardService.writeText((await this.tryEvaluateAndCopy(debugService, element)) || ( (element.toString())));
932
+ }
933
+ }
934
+ async tryEvaluateAndCopy(debugService, element) {
935
+ if (!(element instanceof ReplEvaluationResult)) {
936
+ return;
937
+ }
938
+ const stackFrame = debugService.getViewModel().focusedStackFrame;
939
+ const session = debugService.getViewModel().focusedSession;
940
+ if (!stackFrame || !session || !session.capabilities.supportsClipboardContext) {
941
+ return;
942
+ }
943
+ try {
944
+ const evaluation = await session.evaluate(element.originalExpression, stackFrame.frameId, 'clipboard');
945
+ return evaluation?.body.result;
946
+ }
947
+ catch (e) {
948
+ return;
949
+ }
950
+ }
951
+ });
952
+
953
+ export { Repl };