@codingame/monaco-vscode-debug-service-override 2.0.3 → 2.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.
Files changed (31) hide show
  1. package/debug.js +3 -1
  2. package/package.json +3 -3
  3. package/vscode/src/vs/workbench/contrib/debug/browser/callStackView.js +3 -3
  4. package/vscode/src/vs/workbench/contrib/debug/browser/debug.contribution.js +47 -3
  5. package/vscode/src/vs/workbench/contrib/debug/browser/debugActionViewItems.js +7 -3
  6. package/vscode/src/vs/workbench/contrib/debug/browser/debugCommands.js +1 -1
  7. package/vscode/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.js +18 -7
  8. package/vscode/src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.js +1 -1
  9. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorActions.js +36 -1
  10. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorContribution.js +137 -121
  11. package/vscode/src/vs/workbench/contrib/debug/browser/debugHover.js +34 -5
  12. package/vscode/src/vs/workbench/contrib/debug/browser/debugMemory.js +1 -1
  13. package/vscode/src/vs/workbench/contrib/debug/browser/debugProgress.js +1 -1
  14. package/vscode/src/vs/workbench/contrib/debug/browser/debugService.js +106 -38
  15. package/vscode/src/vs/workbench/contrib/debug/browser/debugSession.js +123 -56
  16. package/vscode/src/vs/workbench/contrib/debug/browser/debugSessionPicker.js +1 -1
  17. package/vscode/src/vs/workbench/contrib/debug/browser/debugTaskRunner.js +8 -7
  18. package/vscode/src/vs/workbench/contrib/debug/browser/debugToolBar.js +43 -19
  19. package/vscode/src/vs/workbench/contrib/debug/browser/debugViewlet.js +2 -1
  20. package/vscode/src/vs/workbench/contrib/debug/browser/disassemblyView.js +1 -1
  21. package/vscode/src/vs/workbench/contrib/debug/browser/loadedScriptsView.js +2 -2
  22. package/vscode/src/vs/workbench/contrib/debug/browser/media/debug.contribution.css.js +1 -1
  23. package/vscode/src/vs/workbench/contrib/debug/browser/repl.js +18 -8
  24. package/vscode/src/vs/workbench/contrib/debug/browser/replFilter.js +1 -1
  25. package/vscode/src/vs/workbench/contrib/debug/browser/replViewer.js +2 -2
  26. package/vscode/src/vs/workbench/contrib/debug/browser/variablesView.js +87 -36
  27. package/vscode/src/vs/workbench/contrib/debug/browser/watchExpressionsView.js +45 -6
  28. package/vscode/src/vs/workbench/contrib/debug/browser/welcomeView.js +9 -3
  29. package/vscode/src/vs/workbench/contrib/debug/common/debugStorage.js +4 -4
  30. package/vscode/src/vs/workbench/contrib/debug/browser/baseDebugView.js +0 -204
  31. package/vscode/src/vs/workbench/contrib/debug/common/replModel.js +0 -287
@@ -11,7 +11,7 @@ import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPan
11
11
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
12
12
  import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
13
13
  import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
14
- import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
14
+ import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
15
15
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
16
16
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
17
17
  import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
@@ -32,7 +32,10 @@ let WelcomeView = class WelcomeView extends ViewPane {
32
32
  const lastSetLanguage = storageSevice.get(debugStartLanguageKey, 1 );
33
33
  this.debugStartLanguageContext.set(lastSetLanguage);
34
34
  const setContextKey = () => {
35
- const editorControl = this.editorService.activeTextEditorControl;
35
+ let editorControl = this.editorService.activeTextEditorControl;
36
+ if (isDiffEditor(editorControl)) {
37
+ editorControl = editorControl.getModifiedEditor();
38
+ }
36
39
  if (isCodeEditor(editorControl)) {
37
40
  const model = editorControl.getModel();
38
41
  const language = model ? model.getLanguageId() : undefined;
@@ -49,7 +52,10 @@ let WelcomeView = class WelcomeView extends ViewPane {
49
52
  this._register(disposables);
50
53
  this._register(editorService.onDidActiveEditorChange(() => {
51
54
  disposables.clear();
52
- const editorControl = this.editorService.activeTextEditorControl;
55
+ let editorControl = this.editorService.activeTextEditorControl;
56
+ if (isDiffEditor(editorControl)) {
57
+ editorControl = editorControl.getModifiedEditor();
58
+ }
53
59
  if (isCodeEditor(editorControl)) {
54
60
  disposables.add(editorControl.onDidChangeModelLanguage(setContextKey));
55
61
  }
@@ -1,11 +1,11 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
2
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
4
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
3
5
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
6
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
4
7
  import { Breakpoint, FunctionBreakpoint, ExceptionBreakpoint, DataBreakpoint, Expression } from 'vscode/vscode/vs/workbench/contrib/debug/common/debugModel';
5
8
  import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
6
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
7
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
8
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
9
9
  import { observableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
10
10
 
11
11
  const DEBUG_BREAKPOINTS_KEY = 'debug.breakpoint';
@@ -54,7 +54,7 @@ let DebugStorage = class DebugStorage extends Disposable {
54
54
  let result;
55
55
  try {
56
56
  result = ( JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, 1 , '[]')).map((breakpoint) => {
57
- return ( new Breakpoint(( URI.parse(breakpoint.uri.external || breakpoint.source.uri.external)), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService, this.uriIdentityService, this.logService, breakpoint.id));
57
+ return ( new Breakpoint(( URI.parse(breakpoint.uri.external || breakpoint.source.uri.external)), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService, this.uriIdentityService, this.logService, breakpoint.id, breakpoint.triggeredBy));
58
58
  }));
59
59
  }
60
60
  catch (e) { }
@@ -1,204 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { append, addDisposableListener, EventType, clearNode, addStandardDisposableListener, $ as $$1 } from 'vscode/vscode/vs/base/browser/dom';
3
- import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
4
- import { HighlightedLabel } from 'vscode/vscode/vs/base/browser/ui/highlightedlabel/highlightedLabel';
5
- import { InputBox } from 'vscode/vscode/vs/base/browser/ui/inputbox/inputBox';
6
- import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
7
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
8
- import { createMatches } from 'vscode/vscode/vs/base/common/filters';
9
- import { createSingleCallFunction } from 'vscode/vscode/vs/base/common/functional';
10
- import { DisposableStore, dispose, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
11
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
12
- import { IContextViewService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
13
- import { defaultInputBoxStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
14
- import { IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
15
- import { Expression, Variable, ExpressionContainer } from 'vscode/vscode/vs/workbench/contrib/debug/common/debugModel';
16
- import { ReplEvaluationResult } from '../common/replModel.js';
17
-
18
- const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024;
19
- const booleanRegex = /^(true|false)$/i;
20
- const stringRegex = /^(['"]).*\1$/;
21
- const $ = $$1;
22
- function renderViewTree(container) {
23
- const treeContainer = $('.');
24
- treeContainer.classList.add('debug-view-content');
25
- container.appendChild(treeContainer);
26
- return treeContainer;
27
- }
28
- function renderExpressionValue(expressionOrValue, container, options) {
29
- let value = typeof expressionOrValue === 'string' ? expressionOrValue : expressionOrValue.value;
30
- container.className = 'value';
31
- if (value === null || ((expressionOrValue instanceof Expression || expressionOrValue instanceof Variable || expressionOrValue instanceof ReplEvaluationResult) && !expressionOrValue.available)) {
32
- container.classList.add('unavailable');
33
- if (value !== Expression.DEFAULT_VALUE) {
34
- container.classList.add('error');
35
- }
36
- }
37
- else {
38
- if ((expressionOrValue instanceof ExpressionContainer) && options.showChanged && expressionOrValue.valueChanged && value !== Expression.DEFAULT_VALUE) {
39
- container.className = 'value changed';
40
- expressionOrValue.valueChanged = false;
41
- }
42
- if (options.colorize && typeof expressionOrValue !== 'string') {
43
- if (expressionOrValue.type === 'number' || expressionOrValue.type === 'boolean' || expressionOrValue.type === 'string') {
44
- container.classList.add(expressionOrValue.type);
45
- }
46
- else if (!isNaN(+value)) {
47
- container.classList.add('number');
48
- }
49
- else if (booleanRegex.test(value)) {
50
- container.classList.add('boolean');
51
- }
52
- else if (stringRegex.test(value)) {
53
- container.classList.add('string');
54
- }
55
- }
56
- }
57
- if (options.maxValueLength && value && value.length > options.maxValueLength) {
58
- value = value.substring(0, options.maxValueLength) + '...';
59
- }
60
- if (!value) {
61
- value = '';
62
- }
63
- if (options.linkDetector) {
64
- container.textContent = '';
65
- const session = (expressionOrValue instanceof ExpressionContainer) ? expressionOrValue.getSession() : undefined;
66
- container.appendChild(options.linkDetector.linkify(value, false, session ? session.root : undefined, true));
67
- }
68
- else {
69
- container.textContent = value;
70
- }
71
- if (options.showHover) {
72
- container.title = value || '';
73
- }
74
- }
75
- function renderVariable(variable, data, showChanged, highlights, linkDetector) {
76
- if (variable.available) {
77
- let text = variable.name;
78
- if (variable.value && typeof variable.name === 'string') {
79
- text += ':';
80
- }
81
- data.label.set(text, highlights, variable.type ? variable.type : variable.name);
82
- data.name.classList.toggle('virtual', variable.presentationHint?.kind === 'virtual');
83
- data.name.classList.toggle('internal', variable.presentationHint?.visibility === 'internal');
84
- }
85
- else if (variable.value && typeof variable.name === 'string' && variable.name) {
86
- data.label.set(':');
87
- }
88
- data.expression.classList.toggle('lazy', !!variable.presentationHint?.lazy);
89
- renderExpressionValue(variable, data.value, {
90
- showChanged,
91
- maxValueLength: MAX_VALUE_RENDER_LENGTH_IN_VIEWLET,
92
- showHover: true,
93
- colorize: true,
94
- linkDetector
95
- });
96
- }
97
- let AbstractExpressionsRenderer = class AbstractExpressionsRenderer {
98
- constructor(debugService, contextViewService) {
99
- this.debugService = debugService;
100
- this.contextViewService = contextViewService;
101
- }
102
- renderTemplate(container) {
103
- const expression = append(container, $('.expression'));
104
- const name = append(expression, $('span.name'));
105
- const lazyButton = append(expression, $('span.lazy-button'));
106
- lazyButton.classList.add(...ThemeIcon.asClassNameArray(Codicon.eye));
107
- lazyButton.title = ( localizeWithPath(
108
- 'vs/workbench/contrib/debug/browser/baseDebugView',
109
- 'debug.lazyButton.tooltip',
110
- "Click to expand"
111
- ));
112
- const value = append(expression, $('span.value'));
113
- const label = ( new HighlightedLabel(name));
114
- const inputBoxContainer = append(expression, $('.inputBoxContainer'));
115
- const templateDisposable = ( new DisposableStore());
116
- let actionBar;
117
- if (this.renderActionBar) {
118
- append(expression, $('.span.actionbar-spacer'));
119
- actionBar = templateDisposable.add(( new ActionBar(expression)));
120
- }
121
- const template = { expression, name, value, label, inputBoxContainer, actionBar, elementDisposable: [], templateDisposable, lazyButton, currentElement: undefined };
122
- templateDisposable.add(addDisposableListener(lazyButton, EventType.CLICK, () => {
123
- if (template.currentElement) {
124
- this.debugService.getViewModel().evaluateLazyExpression(template.currentElement);
125
- }
126
- }));
127
- return template;
128
- }
129
- renderExpressionElement(element, node, data) {
130
- data.currentElement = element;
131
- this.renderExpression(node.element, data, createMatches(node.filterData));
132
- if (data.actionBar) {
133
- this.renderActionBar(data.actionBar, element, data);
134
- }
135
- const selectedExpression = this.debugService.getViewModel().getSelectedExpression();
136
- if (element === selectedExpression?.expression || (element instanceof Variable && element.errorMessage)) {
137
- const options = this.getInputBoxOptions(element, !!selectedExpression?.settingWatch);
138
- if (options) {
139
- data.elementDisposable.push(this.renderInputBox(data.name, data.value, data.inputBoxContainer, options));
140
- }
141
- }
142
- }
143
- renderInputBox(nameElement, valueElement, inputBoxContainer, options) {
144
- nameElement.style.display = 'none';
145
- valueElement.style.display = 'none';
146
- inputBoxContainer.style.display = 'initial';
147
- clearNode(inputBoxContainer);
148
- const inputBox = ( new InputBox(
149
- inputBoxContainer,
150
- this.contextViewService,
151
- { ...options, inputBoxStyles: defaultInputBoxStyles }
152
- ));
153
- inputBox.value = options.initialValue;
154
- inputBox.focus();
155
- inputBox.select();
156
- const done = createSingleCallFunction((success, finishEditing) => {
157
- nameElement.style.display = '';
158
- valueElement.style.display = '';
159
- inputBoxContainer.style.display = 'none';
160
- const value = inputBox.value;
161
- dispose(toDispose);
162
- if (finishEditing) {
163
- this.debugService.getViewModel().setSelectedExpression(undefined, false);
164
- options.onFinish(value, success);
165
- }
166
- });
167
- const toDispose = [
168
- inputBox,
169
- addStandardDisposableListener(inputBox.inputElement, EventType.KEY_DOWN, (e) => {
170
- const isEscape = e.equals(9 );
171
- const isEnter = e.equals(3 );
172
- if (isEscape || isEnter) {
173
- e.preventDefault();
174
- e.stopPropagation();
175
- done(isEnter, true);
176
- }
177
- }),
178
- addDisposableListener(inputBox.inputElement, EventType.BLUR, () => {
179
- done(true, true);
180
- }),
181
- addDisposableListener(inputBox.inputElement, EventType.CLICK, e => {
182
- e.preventDefault();
183
- e.stopPropagation();
184
- })
185
- ];
186
- return toDisposable(() => {
187
- done(false, false);
188
- });
189
- }
190
- disposeElement(node, index, templateData) {
191
- dispose(templateData.elementDisposable);
192
- templateData.elementDisposable = [];
193
- }
194
- disposeTemplate(templateData) {
195
- dispose(templateData.elementDisposable);
196
- templateData.templateDisposable.dispose();
197
- }
198
- };
199
- AbstractExpressionsRenderer = ( __decorate([
200
- ( __param(0, IDebugService)),
201
- ( __param(1, IContextViewService))
202
- ], AbstractExpressionsRenderer));
203
-
204
- export { AbstractExpressionsRenderer, renderExpressionValue, renderVariable, renderViewTree };
@@ -1,287 +0,0 @@
1
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
2
- import Severity from 'vscode/vscode/vs/base/common/severity';
3
- import { isObject, isString } from 'vscode/vscode/vs/base/common/types';
4
- import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
5
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
6
- import { ExpressionContainer } from 'vscode/vscode/vs/workbench/contrib/debug/common/debugModel';
7
-
8
- const MAX_REPL_LENGTH = 10000;
9
- let topReplElementCounter = 0;
10
- const getUniqueId = () => `topReplElement:${topReplElementCounter++}`;
11
- class ReplOutputElement {
12
- constructor(session, id, value, severity, sourceData, expression) {
13
- this.session = session;
14
- this.id = id;
15
- this.value = value;
16
- this.severity = severity;
17
- this.sourceData = sourceData;
18
- this.expression = expression;
19
- this._count = 1;
20
- this._onDidChangeCount = ( new Emitter());
21
- }
22
- toString(includeSource = false) {
23
- let valueRespectCount = this.value;
24
- for (let i = 1; i < this.count; i++) {
25
- valueRespectCount += (valueRespectCount.endsWith('\n') ? '' : '\n') + this.value;
26
- }
27
- const sourceStr = (this.sourceData && includeSource) ? ` ${this.sourceData.source.name}` : '';
28
- return valueRespectCount + sourceStr;
29
- }
30
- getId() {
31
- return this.id;
32
- }
33
- getChildren() {
34
- return this.expression?.getChildren() || Promise.resolve([]);
35
- }
36
- set count(value) {
37
- this._count = value;
38
- this._onDidChangeCount.fire();
39
- }
40
- get count() {
41
- return this._count;
42
- }
43
- get onDidChangeCount() {
44
- return this._onDidChangeCount.event;
45
- }
46
- get hasChildren() {
47
- return !!this.expression?.hasChildren;
48
- }
49
- }
50
- class ReplVariableElement {
51
- constructor(expression, severity, sourceData) {
52
- this.expression = expression;
53
- this.severity = severity;
54
- this.sourceData = sourceData;
55
- this.id = generateUuid();
56
- this.hasChildren = expression.hasChildren;
57
- }
58
- getChildren() {
59
- return this.expression.getChildren();
60
- }
61
- toString() {
62
- return ( this.expression.toString());
63
- }
64
- getId() {
65
- return this.id;
66
- }
67
- }
68
- class RawObjectReplElement {
69
- static { this.MAX_CHILDREN = 1000; }
70
- constructor(id, name, valueObj, sourceData, annotation) {
71
- this.id = id;
72
- this.name = name;
73
- this.valueObj = valueObj;
74
- this.sourceData = sourceData;
75
- this.annotation = annotation;
76
- }
77
- getId() {
78
- return this.id;
79
- }
80
- get value() {
81
- if (this.valueObj === null) {
82
- return 'null';
83
- }
84
- else if (Array.isArray(this.valueObj)) {
85
- return `Array[${this.valueObj.length}]`;
86
- }
87
- else if (isObject(this.valueObj)) {
88
- return 'Object';
89
- }
90
- else if (isString(this.valueObj)) {
91
- return `"${this.valueObj}"`;
92
- }
93
- return String(this.valueObj) || '';
94
- }
95
- get hasChildren() {
96
- return (Array.isArray(this.valueObj) && this.valueObj.length > 0) || (isObject(this.valueObj) && Object.getOwnPropertyNames(this.valueObj).length > 0);
97
- }
98
- evaluateLazy() {
99
- throw new Error('Method not implemented.');
100
- }
101
- getChildren() {
102
- let result = [];
103
- if (Array.isArray(this.valueObj)) {
104
- result = ( this.valueObj.slice(0, RawObjectReplElement.MAX_CHILDREN)
105
- .map((v, index) => ( new RawObjectReplElement(`${this.id}:${index}`, String(index), v))));
106
- }
107
- else if (isObject(this.valueObj)) {
108
- result = ( Object.getOwnPropertyNames(this.valueObj).slice(0, RawObjectReplElement.MAX_CHILDREN)
109
- .map((key, index) => ( new RawObjectReplElement(`${this.id}:${index}`, key, this.valueObj[key]))));
110
- }
111
- return Promise.resolve(result);
112
- }
113
- toString() {
114
- return `${this.name}\n${this.value}`;
115
- }
116
- }
117
- class ReplEvaluationInput {
118
- constructor(value) {
119
- this.value = value;
120
- this.id = generateUuid();
121
- }
122
- toString() {
123
- return this.value;
124
- }
125
- getId() {
126
- return this.id;
127
- }
128
- }
129
- class ReplEvaluationResult extends ExpressionContainer {
130
- get available() {
131
- return this._available;
132
- }
133
- constructor(originalExpression) {
134
- super(undefined, undefined, 0, generateUuid());
135
- this.originalExpression = originalExpression;
136
- this._available = true;
137
- }
138
- async evaluateExpression(expression, session, stackFrame, context) {
139
- const result = await super.evaluateExpression(expression, session, stackFrame, context);
140
- this._available = result;
141
- return result;
142
- }
143
- toString() {
144
- return `${this.value}`;
145
- }
146
- }
147
- class ReplGroup {
148
- static { this.COUNTER = 0; }
149
- constructor(name, autoExpand, sourceData) {
150
- this.name = name;
151
- this.autoExpand = autoExpand;
152
- this.sourceData = sourceData;
153
- this.children = [];
154
- this.ended = false;
155
- this.id = `replGroup:${ReplGroup.COUNTER++}`;
156
- }
157
- get hasChildren() {
158
- return true;
159
- }
160
- getId() {
161
- return this.id;
162
- }
163
- toString(includeSource = false) {
164
- const sourceStr = (includeSource && this.sourceData) ? ` ${this.sourceData.source.name}` : '';
165
- return this.name + sourceStr;
166
- }
167
- addChild(child) {
168
- const lastElement = this.children.length ? this.children[this.children.length - 1] : undefined;
169
- if (lastElement instanceof ReplGroup && !lastElement.hasEnded) {
170
- lastElement.addChild(child);
171
- }
172
- else {
173
- this.children.push(child);
174
- }
175
- }
176
- getChildren() {
177
- return this.children;
178
- }
179
- end() {
180
- const lastElement = this.children.length ? this.children[this.children.length - 1] : undefined;
181
- if (lastElement instanceof ReplGroup && !lastElement.hasEnded) {
182
- lastElement.end();
183
- }
184
- else {
185
- this.ended = true;
186
- }
187
- }
188
- get hasEnded() {
189
- return this.ended;
190
- }
191
- }
192
- function areSourcesEqual(first, second) {
193
- if (!first && !second) {
194
- return true;
195
- }
196
- if (first && second) {
197
- return first.column === second.column && first.lineNumber === second.lineNumber && ( first.source.uri.toString()) === ( second.source.uri.toString());
198
- }
199
- return false;
200
- }
201
- class ReplModel {
202
- constructor(configurationService) {
203
- this.configurationService = configurationService;
204
- this.replElements = [];
205
- this._onDidChangeElements = ( new Emitter());
206
- this.onDidChangeElements = this._onDidChangeElements.event;
207
- }
208
- getReplElements() {
209
- return this.replElements;
210
- }
211
- async addReplExpression(session, stackFrame, name) {
212
- this.addReplElement(( new ReplEvaluationInput(name)));
213
- const result = ( new ReplEvaluationResult(name));
214
- await result.evaluateExpression(name, session, stackFrame, 'repl');
215
- this.addReplElement(result);
216
- }
217
- appendToRepl(session, { output, expression, sev, source }) {
218
- const clearAnsiSequence = '\u001b[2J';
219
- const clearAnsiIndex = output.lastIndexOf(clearAnsiSequence);
220
- if (clearAnsiIndex !== -1) {
221
- this.removeReplExpressions();
222
- this.appendToRepl(session, { output: ( localizeWithPath(
223
- 'vs/workbench/contrib/debug/common/replModel',
224
- 'consoleCleared',
225
- "Console was cleared"
226
- )), sev: Severity.Ignore });
227
- output = output.substring(clearAnsiIndex + clearAnsiSequence.length);
228
- }
229
- if (expression) {
230
- this.addReplElement(output
231
- ? ( new ReplOutputElement(session, getUniqueId(), output, sev, source, expression))
232
- : ( new ReplVariableElement(expression, sev, source)));
233
- return;
234
- }
235
- const previousElement = this.replElements.length ? this.replElements[this.replElements.length - 1] : undefined;
236
- if (previousElement instanceof ReplOutputElement && previousElement.severity === sev) {
237
- const config = this.configurationService.getValue('debug');
238
- if (previousElement.value === output && areSourcesEqual(previousElement.sourceData, source) && config.console.collapseIdenticalLines) {
239
- previousElement.count++;
240
- return;
241
- }
242
- if (!previousElement.value.endsWith('\n') && !previousElement.value.endsWith('\r\n') && previousElement.count === 1) {
243
- this.replElements[this.replElements.length - 1] = ( new ReplOutputElement(session, getUniqueId(), previousElement.value + output, sev, source));
244
- this._onDidChangeElements.fire();
245
- return;
246
- }
247
- }
248
- const element = ( new ReplOutputElement(session, getUniqueId(), output, sev, source));
249
- this.addReplElement(element);
250
- }
251
- startGroup(name, autoExpand, sourceData) {
252
- const group = ( new ReplGroup(name, autoExpand, sourceData));
253
- this.addReplElement(group);
254
- }
255
- endGroup() {
256
- const lastElement = this.replElements[this.replElements.length - 1];
257
- if (lastElement instanceof ReplGroup) {
258
- lastElement.end();
259
- }
260
- }
261
- addReplElement(newElement) {
262
- const lastElement = this.replElements.length ? this.replElements[this.replElements.length - 1] : undefined;
263
- if (lastElement instanceof ReplGroup && !lastElement.hasEnded) {
264
- lastElement.addChild(newElement);
265
- }
266
- else {
267
- this.replElements.push(newElement);
268
- if (this.replElements.length > MAX_REPL_LENGTH) {
269
- this.replElements.splice(0, this.replElements.length - MAX_REPL_LENGTH);
270
- }
271
- }
272
- this._onDidChangeElements.fire();
273
- }
274
- removeReplExpressions() {
275
- if (this.replElements.length > 0) {
276
- this.replElements = [];
277
- this._onDidChangeElements.fire();
278
- }
279
- }
280
- clone() {
281
- const newRepl = ( new ReplModel(this.configurationService));
282
- newRepl.replElements = this.replElements.slice();
283
- return newRepl;
284
- }
285
- }
286
-
287
- export { RawObjectReplElement, ReplEvaluationInput, ReplEvaluationResult, ReplGroup, ReplModel, ReplOutputElement, ReplVariableElement };