@codingame/monaco-vscode-api 1.83.15-next.0 → 1.83.16
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/README.md +430 -0
- package/contributions.js +3 -0
- package/localExtensionHost.js +3 -2
- package/missing-services.js +57 -1
- package/monaco-editor-treemending.patch +3375 -3375
- package/package.json +6 -6
- package/vscode/src/vs/base/common/prefixTree.js +130 -0
- package/vscode/src/vs/platform/actions/browser/floatingMenu.js +26 -2
- package/vscode/src/vs/platform/terminal/common/capabilities/bufferMarkCapability.js +41 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +566 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/cwdDetectionCapability.js +29 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/partialCommandDetectionCapability.js +48 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/terminalCapabilityStore.js +94 -0
- package/vscode/src/vs/platform/terminal/common/terminalEnvironment.js +37 -0
- package/vscode/src/vs/platform/terminal/common/terminalStrings.js +16 -0
- package/vscode/src/vs/platform/terminal/common/xterm/shellIntegrationAddon.js +319 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +91 -1
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +423 -0
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +82 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +564 -11
- package/vscode/src/vs/workbench/contrib/scm/common/scm.js +9 -1
- package/vscode/src/vs/workbench/contrib/terminal/browser/detachedTerminal.js +67 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalExtensions.js +25 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIcons.js +64 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/widgets/widgetManager.js +36 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +538 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +104 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +416 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/suggestAddon.js +390 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +799 -0
- package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +101 -0
- package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +30 -0
- package/vscode/src/vs/workbench/contrib/testing/common/storedValue.js +36 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.js +116 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.js +172 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +384 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testResultService.js +156 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testResultStorage.js +156 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testService.js +75 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +9 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testingContextKeys.js +179 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingContinuousRunService.js +102 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.js +29 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.js +3 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +47 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +594 -2
- package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +307 -1
- package/vscode/src/vs/workbench/services/suggest/browser/media/suggest.css.js +4 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionItem.js +10 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionModel.js +98 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidget.js +428 -0
- package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidgetRenderer.js +83 -0
- package/vscode/src/vs/workbench/services/textfile/common/textfiles.js +6 -2
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/suggest.css.js';
|
|
3
|
+
import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
4
|
+
import { List } from 'monaco-editor/esm/vs/base/browser/ui/list/listWidget.js';
|
|
5
|
+
import { ResizableHTMLElement } from 'monaco-editor/esm/vs/base/browser/ui/resizable/resizable.js';
|
|
6
|
+
import { SimpleSuggestWidgetItemRenderer } from './simpleSuggestWidgetRenderer.js';
|
|
7
|
+
import { TimeoutTimer } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
8
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
9
|
+
import { MutableDisposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
10
|
+
import { clamp } from 'monaco-editor/esm/vs/base/common/numbers.js';
|
|
11
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
12
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
13
|
+
import { SuggestWidgetStatus } from 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestWidgetStatus.js';
|
|
14
|
+
const $ = dom.$;
|
|
15
|
+
let SimpleSuggestWidget = class SimpleSuggestWidget {
|
|
16
|
+
get list() { return this._list; }
|
|
17
|
+
constructor(_container, _persistedSize, options, instantiationService) {
|
|
18
|
+
this._container = _container;
|
|
19
|
+
this._persistedSize = _persistedSize;
|
|
20
|
+
this._state = 0 ;
|
|
21
|
+
this._forceRenderingAbove = false;
|
|
22
|
+
this._pendingLayout = ( new MutableDisposable());
|
|
23
|
+
this._showTimeout = ( new TimeoutTimer());
|
|
24
|
+
this._disposables = ( new DisposableStore());
|
|
25
|
+
this._onDidSelect = ( new Emitter());
|
|
26
|
+
this.onDidSelect = this._onDidSelect.event;
|
|
27
|
+
this._onDidHide = ( new Emitter());
|
|
28
|
+
this.onDidHide = this._onDidHide.event;
|
|
29
|
+
this._onDidShow = ( new Emitter());
|
|
30
|
+
this.onDidShow = this._onDidShow.event;
|
|
31
|
+
this.element = ( new ResizableHTMLElement());
|
|
32
|
+
this.element.domNode.classList.add('workbench-suggest-widget');
|
|
33
|
+
this._container.appendChild(this.element.domNode);
|
|
34
|
+
class ResizeState {
|
|
35
|
+
constructor(persistedSize, currentSize, persistHeight = false, persistWidth = false) {
|
|
36
|
+
this.persistedSize = persistedSize;
|
|
37
|
+
this.currentSize = currentSize;
|
|
38
|
+
this.persistHeight = persistHeight;
|
|
39
|
+
this.persistWidth = persistWidth;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let state;
|
|
43
|
+
this._disposables.add(this.element.onDidWillResize(() => {
|
|
44
|
+
state = ( new ResizeState(this._persistedSize.restore(), this.element.size));
|
|
45
|
+
}));
|
|
46
|
+
this._disposables.add(this.element.onDidResize(e => {
|
|
47
|
+
this._resize(e.dimension.width, e.dimension.height);
|
|
48
|
+
if (state) {
|
|
49
|
+
state.persistHeight = state.persistHeight || !!e.north || !!e.south;
|
|
50
|
+
state.persistWidth = state.persistWidth || !!e.east || !!e.west;
|
|
51
|
+
}
|
|
52
|
+
if (!e.done) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (state) {
|
|
56
|
+
const { itemHeight, defaultSize } = this._getLayoutInfo();
|
|
57
|
+
const threshold = Math.round(itemHeight / 2);
|
|
58
|
+
let { width, height } = this.element.size;
|
|
59
|
+
if (!state.persistHeight || Math.abs(state.currentSize.height - height) <= threshold) {
|
|
60
|
+
height = state.persistedSize?.height ?? defaultSize.height;
|
|
61
|
+
}
|
|
62
|
+
if (!state.persistWidth || Math.abs(state.currentSize.width - width) <= threshold) {
|
|
63
|
+
width = state.persistedSize?.width ?? defaultSize.width;
|
|
64
|
+
}
|
|
65
|
+
this._persistedSize.store(new dom.Dimension(width, height));
|
|
66
|
+
}
|
|
67
|
+
state = undefined;
|
|
68
|
+
}));
|
|
69
|
+
const renderer = ( new SimpleSuggestWidgetItemRenderer());
|
|
70
|
+
this._disposables.add(renderer);
|
|
71
|
+
this._listElement = dom.append(this.element.domNode, $('.tree'));
|
|
72
|
+
this._list = ( new List('SuggestWidget', this._listElement, {
|
|
73
|
+
getHeight: (_element) => this._getLayoutInfo().itemHeight,
|
|
74
|
+
getTemplateId: (_element) => 'suggestion'
|
|
75
|
+
}, [renderer], {
|
|
76
|
+
alwaysConsumeMouseWheel: true,
|
|
77
|
+
useShadows: false,
|
|
78
|
+
mouseSupport: false,
|
|
79
|
+
multipleSelectionSupport: false,
|
|
80
|
+
accessibilityProvider: {
|
|
81
|
+
getRole: () => 'option',
|
|
82
|
+
getWidgetAriaLabel: () => ( localizeWithPath(
|
|
83
|
+
'vs/workbench/services/suggest/browser/simpleSuggestWidget',
|
|
84
|
+
'suggest',
|
|
85
|
+
"Suggest"
|
|
86
|
+
)),
|
|
87
|
+
getWidgetRole: () => 'listbox',
|
|
88
|
+
getAriaLabel: (item) => {
|
|
89
|
+
let label = item.completion.label;
|
|
90
|
+
if (typeof item.completion.label !== 'string') {
|
|
91
|
+
const { detail, description } = item.completion.label;
|
|
92
|
+
if (detail && description) {
|
|
93
|
+
label = ( localizeWithPath(
|
|
94
|
+
'vs/workbench/services/suggest/browser/simpleSuggestWidget',
|
|
95
|
+
'label.full',
|
|
96
|
+
'{0}{1}, {2}',
|
|
97
|
+
label,
|
|
98
|
+
detail,
|
|
99
|
+
description
|
|
100
|
+
));
|
|
101
|
+
}
|
|
102
|
+
else if (detail) {
|
|
103
|
+
label = ( localizeWithPath(
|
|
104
|
+
'vs/workbench/services/suggest/browser/simpleSuggestWidget',
|
|
105
|
+
'label.detail',
|
|
106
|
+
'{0}{1}',
|
|
107
|
+
label,
|
|
108
|
+
detail
|
|
109
|
+
));
|
|
110
|
+
}
|
|
111
|
+
else if (description) {
|
|
112
|
+
label = ( localizeWithPath(
|
|
113
|
+
'vs/workbench/services/suggest/browser/simpleSuggestWidget',
|
|
114
|
+
'label.desc',
|
|
115
|
+
'{0}, {1}',
|
|
116
|
+
label,
|
|
117
|
+
description
|
|
118
|
+
));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const { detail } = item.completion;
|
|
122
|
+
return ( localizeWithPath(
|
|
123
|
+
'vs/workbench/services/suggest/browser/simpleSuggestWidget',
|
|
124
|
+
'ariaCurrenttSuggestionReadDetails',
|
|
125
|
+
'{0}, docs: {1}',
|
|
126
|
+
label,
|
|
127
|
+
detail
|
|
128
|
+
));
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
if (options.statusBarMenuId) {
|
|
133
|
+
this._status = instantiationService.createInstance(SuggestWidgetStatus, this.element.domNode, options.statusBarMenuId);
|
|
134
|
+
this.element.domNode.classList.toggle('with-status-bar', true);
|
|
135
|
+
}
|
|
136
|
+
this._disposables.add(this._list.onMouseDown(e => this._onListMouseDownOrTap(e)));
|
|
137
|
+
this._disposables.add(this._list.onTap(e => this._onListMouseDownOrTap(e)));
|
|
138
|
+
this._disposables.add(this._list.onDidChangeSelection(e => this._onListSelection(e)));
|
|
139
|
+
}
|
|
140
|
+
dispose() {
|
|
141
|
+
this._disposables.dispose();
|
|
142
|
+
this._status?.dispose();
|
|
143
|
+
this.element.dispose();
|
|
144
|
+
}
|
|
145
|
+
showSuggestions(completionModel, selectionIndex, isFrozen, isAuto, cursorPosition) {
|
|
146
|
+
this._cursorPosition = cursorPosition;
|
|
147
|
+
if (this._completionModel !== completionModel) {
|
|
148
|
+
this._completionModel = completionModel;
|
|
149
|
+
}
|
|
150
|
+
if (isFrozen && this._state !== 2 && this._state !== 0 ) {
|
|
151
|
+
this._setState(4 );
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const visibleCount = this._completionModel.items.length;
|
|
155
|
+
const isEmpty = visibleCount === 0;
|
|
156
|
+
if (isEmpty) {
|
|
157
|
+
this._setState(isAuto ? 0 : 2 );
|
|
158
|
+
this._completionModel = undefined;
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
this._list.splice(0, this._list.length, this._completionModel.items);
|
|
163
|
+
this._setState(isFrozen ? 4 : 3 );
|
|
164
|
+
this._list.reveal(selectionIndex, 0);
|
|
165
|
+
this._list.setFocus([selectionIndex]);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
}
|
|
169
|
+
this._pendingLayout.value = dom.runAtThisOrScheduleAtNextAnimationFrame(() => {
|
|
170
|
+
this._pendingLayout.clear();
|
|
171
|
+
this._layout(this.element.size);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
setLineContext(lineContext) {
|
|
175
|
+
if (this._completionModel) {
|
|
176
|
+
this._completionModel.lineContext = lineContext;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_setState(state) {
|
|
180
|
+
if (this._state === state) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
this._state = state;
|
|
184
|
+
this.element.domNode.classList.toggle('frozen', state === 4 );
|
|
185
|
+
this.element.domNode.classList.remove('message');
|
|
186
|
+
switch (state) {
|
|
187
|
+
case 0 :
|
|
188
|
+
dom.hide(this._listElement);
|
|
189
|
+
if (this._status) {
|
|
190
|
+
dom.hide(this._status?.element);
|
|
191
|
+
}
|
|
192
|
+
this._status?.hide();
|
|
193
|
+
this._showTimeout.cancel();
|
|
194
|
+
this.element.domNode.classList.remove('visible');
|
|
195
|
+
this._list.splice(0, this._list.length);
|
|
196
|
+
this._cappedHeight = undefined;
|
|
197
|
+
break;
|
|
198
|
+
case 1 :
|
|
199
|
+
this.element.domNode.classList.add('message');
|
|
200
|
+
dom.hide(this._listElement);
|
|
201
|
+
if (this._status) {
|
|
202
|
+
dom.hide(this._status?.element);
|
|
203
|
+
}
|
|
204
|
+
this._show();
|
|
205
|
+
break;
|
|
206
|
+
case 2 :
|
|
207
|
+
this.element.domNode.classList.add('message');
|
|
208
|
+
dom.hide(this._listElement);
|
|
209
|
+
if (this._status) {
|
|
210
|
+
dom.hide(this._status?.element);
|
|
211
|
+
}
|
|
212
|
+
this._show();
|
|
213
|
+
break;
|
|
214
|
+
case 3 :
|
|
215
|
+
dom.show(this._listElement);
|
|
216
|
+
if (this._status) {
|
|
217
|
+
dom.show(this._status?.element);
|
|
218
|
+
}
|
|
219
|
+
this._show();
|
|
220
|
+
break;
|
|
221
|
+
case 4 :
|
|
222
|
+
dom.show(this._listElement);
|
|
223
|
+
if (this._status) {
|
|
224
|
+
dom.show(this._status?.element);
|
|
225
|
+
}
|
|
226
|
+
this._show();
|
|
227
|
+
break;
|
|
228
|
+
case 5 :
|
|
229
|
+
dom.show(this._listElement);
|
|
230
|
+
if (this._status) {
|
|
231
|
+
dom.show(this._status?.element);
|
|
232
|
+
}
|
|
233
|
+
this._show();
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
_show() {
|
|
238
|
+
this._status?.show();
|
|
239
|
+
dom.show(this.element.domNode);
|
|
240
|
+
this._layout(this._persistedSize.restore());
|
|
241
|
+
this._showTimeout.cancelAndSet(() => {
|
|
242
|
+
this.element.domNode.classList.add('visible');
|
|
243
|
+
this._onDidShow.fire(this);
|
|
244
|
+
}, 100);
|
|
245
|
+
}
|
|
246
|
+
hide() {
|
|
247
|
+
this._pendingLayout.clear();
|
|
248
|
+
this._setState(0 );
|
|
249
|
+
this._onDidHide.fire(this);
|
|
250
|
+
dom.hide(this.element.domNode);
|
|
251
|
+
this.element.clearSashHoverState();
|
|
252
|
+
const dim = this._persistedSize.restore();
|
|
253
|
+
const minPersistedHeight = Math.ceil(this._getLayoutInfo().itemHeight * 4.3);
|
|
254
|
+
if (dim && dim.height < minPersistedHeight) {
|
|
255
|
+
this._persistedSize.store(dim.with(undefined, minPersistedHeight));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_layout(size) {
|
|
259
|
+
if (!this._cursorPosition) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const bodyBox = dom.getClientArea(document.body);
|
|
263
|
+
const info = this._getLayoutInfo();
|
|
264
|
+
if (!size) {
|
|
265
|
+
size = info.defaultSize;
|
|
266
|
+
}
|
|
267
|
+
let height = size.height;
|
|
268
|
+
let width = size.width;
|
|
269
|
+
if (this._status) {
|
|
270
|
+
this._status.element.style.lineHeight = `${info.itemHeight}px`;
|
|
271
|
+
}
|
|
272
|
+
const maxWidth = bodyBox.width - info.borderHeight - 2 * info.horizontalPadding;
|
|
273
|
+
if (width > maxWidth) {
|
|
274
|
+
width = maxWidth;
|
|
275
|
+
}
|
|
276
|
+
const preferredWidth = this._completionModel ? this._completionModel.stats.pLabelLen * info.typicalHalfwidthCharacterWidth : width;
|
|
277
|
+
const fullHeight = info.statusBarHeight + this._list.contentHeight + info.borderHeight;
|
|
278
|
+
const minHeight = info.itemHeight + info.statusBarHeight;
|
|
279
|
+
const editorBox = dom.getDomNodePagePosition(this._container);
|
|
280
|
+
const cursorBox = this._cursorPosition;
|
|
281
|
+
const cursorBottom = editorBox.top + cursorBox.top + cursorBox.height;
|
|
282
|
+
const maxHeightBelow = Math.min(bodyBox.height - cursorBottom - info.verticalPadding, fullHeight);
|
|
283
|
+
const availableSpaceAbove = editorBox.top + cursorBox.top - info.verticalPadding;
|
|
284
|
+
const maxHeightAbove = Math.min(availableSpaceAbove, fullHeight);
|
|
285
|
+
let maxHeight = Math.min(Math.max(maxHeightAbove, maxHeightBelow) + info.borderHeight, fullHeight);
|
|
286
|
+
if (height === this._cappedHeight?.capped) {
|
|
287
|
+
height = this._cappedHeight.wanted;
|
|
288
|
+
}
|
|
289
|
+
if (height < minHeight) {
|
|
290
|
+
height = minHeight;
|
|
291
|
+
}
|
|
292
|
+
if (height > maxHeight) {
|
|
293
|
+
height = maxHeight;
|
|
294
|
+
}
|
|
295
|
+
const forceRenderingAboveRequiredSpace = 150;
|
|
296
|
+
if (height > maxHeightBelow || (this._forceRenderingAbove && availableSpaceAbove > forceRenderingAboveRequiredSpace)) {
|
|
297
|
+
this._preference = 0 ;
|
|
298
|
+
this.element.enableSashes(true, true, false, false);
|
|
299
|
+
maxHeight = maxHeightAbove;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this._preference = 1 ;
|
|
303
|
+
this.element.enableSashes(false, true, true, false);
|
|
304
|
+
maxHeight = maxHeightBelow;
|
|
305
|
+
}
|
|
306
|
+
this.element.preferredSize = new dom.Dimension(preferredWidth, info.defaultSize.height);
|
|
307
|
+
this.element.maxSize = new dom.Dimension(maxWidth, maxHeight);
|
|
308
|
+
this.element.minSize = new dom.Dimension(220, minHeight);
|
|
309
|
+
this._cappedHeight = height === fullHeight
|
|
310
|
+
? { wanted: this._cappedHeight?.wanted ?? size.height, capped: height }
|
|
311
|
+
: undefined;
|
|
312
|
+
this.element.domNode.style.left = `${this._cursorPosition.left}px`;
|
|
313
|
+
if (this._preference === 0 ) {
|
|
314
|
+
this.element.domNode.style.top = `${this._cursorPosition.top - height - info.borderHeight}px`;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
this.element.domNode.style.top = `${this._cursorPosition.top + this._cursorPosition.height}px`;
|
|
318
|
+
}
|
|
319
|
+
this._resize(width, height);
|
|
320
|
+
}
|
|
321
|
+
_resize(width, height) {
|
|
322
|
+
const { width: maxWidth, height: maxHeight } = this.element.maxSize;
|
|
323
|
+
width = Math.min(maxWidth, width);
|
|
324
|
+
if (maxHeight) {
|
|
325
|
+
height = Math.min(maxHeight, height);
|
|
326
|
+
}
|
|
327
|
+
const { statusBarHeight } = this._getLayoutInfo();
|
|
328
|
+
this._list.layout(height - statusBarHeight, width);
|
|
329
|
+
this._listElement.style.height = `${height - statusBarHeight}px`;
|
|
330
|
+
this._listElement.style.width = `${width}px`;
|
|
331
|
+
this._listElement.style.height = `${height}px`;
|
|
332
|
+
this.element.layout(height, width);
|
|
333
|
+
}
|
|
334
|
+
_getLayoutInfo() {
|
|
335
|
+
const fontInfo = {
|
|
336
|
+
lineHeight: 20,
|
|
337
|
+
typicalHalfwidthCharacterWidth: 10
|
|
338
|
+
};
|
|
339
|
+
const itemHeight = clamp(fontInfo.lineHeight, 8, 1000);
|
|
340
|
+
const statusBarHeight = 0;
|
|
341
|
+
const borderWidth = 1;
|
|
342
|
+
const borderHeight = 2 * borderWidth;
|
|
343
|
+
return {
|
|
344
|
+
itemHeight,
|
|
345
|
+
statusBarHeight,
|
|
346
|
+
borderWidth,
|
|
347
|
+
borderHeight,
|
|
348
|
+
typicalHalfwidthCharacterWidth: fontInfo.typicalHalfwidthCharacterWidth,
|
|
349
|
+
verticalPadding: 22,
|
|
350
|
+
horizontalPadding: 14,
|
|
351
|
+
defaultSize: new dom.Dimension(430, statusBarHeight + 12 * itemHeight + borderHeight)
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
_onListMouseDownOrTap(e) {
|
|
355
|
+
if (typeof e.element === 'undefined' || typeof e.index === 'undefined') {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
e.browserEvent.preventDefault();
|
|
359
|
+
e.browserEvent.stopPropagation();
|
|
360
|
+
this._select(e.element, e.index);
|
|
361
|
+
}
|
|
362
|
+
_onListSelection(e) {
|
|
363
|
+
if (e.elements.length) {
|
|
364
|
+
this._select(e.elements[0], e.indexes[0]);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
_select(item, index) {
|
|
368
|
+
const completionModel = this._completionModel;
|
|
369
|
+
if (completionModel) {
|
|
370
|
+
this._onDidSelect.fire({ item, index, model: completionModel });
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
selectNext() {
|
|
374
|
+
this._list.focusNext(1, true);
|
|
375
|
+
const focus = this._list.getFocus();
|
|
376
|
+
if (focus.length > 0) {
|
|
377
|
+
this._list.reveal(focus[0]);
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
selectNextPage() {
|
|
382
|
+
this._list.focusNextPage();
|
|
383
|
+
const focus = this._list.getFocus();
|
|
384
|
+
if (focus.length > 0) {
|
|
385
|
+
this._list.reveal(focus[0]);
|
|
386
|
+
}
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
selectPrevious() {
|
|
390
|
+
this._list.focusPrevious(1, true);
|
|
391
|
+
const focus = this._list.getFocus();
|
|
392
|
+
if (focus.length > 0) {
|
|
393
|
+
this._list.reveal(focus[0]);
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
selectPreviousPage() {
|
|
398
|
+
this._list.focusPreviousPage();
|
|
399
|
+
const focus = this._list.getFocus();
|
|
400
|
+
if (focus.length > 0) {
|
|
401
|
+
this._list.reveal(focus[0]);
|
|
402
|
+
}
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
getFocusedItem() {
|
|
406
|
+
if (this._completionModel) {
|
|
407
|
+
return {
|
|
408
|
+
item: this._list.getFocusedElements()[0],
|
|
409
|
+
index: this._list.getFocus()[0],
|
|
410
|
+
model: this._completionModel
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
return undefined;
|
|
414
|
+
}
|
|
415
|
+
forceRenderingAbove() {
|
|
416
|
+
if (!this._forceRenderingAbove) {
|
|
417
|
+
this._forceRenderingAbove = true;
|
|
418
|
+
this._layout(this._persistedSize.restore());
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
stopForceRenderingAbove() {
|
|
422
|
+
this._forceRenderingAbove = false;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
SimpleSuggestWidget = ( __decorate([
|
|
426
|
+
( __param(3, IInstantiationService))
|
|
427
|
+
], SimpleSuggestWidget));
|
|
428
|
+
export { SimpleSuggestWidget };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { append, $, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
2
|
+
import { IconLabel } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabel.js';
|
|
3
|
+
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
4
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
5
|
+
import { createMatches } from 'monaco-editor/esm/vs/base/common/filters.js';
|
|
6
|
+
import { DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
+
import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
|
|
8
|
+
function getAriaId(index) {
|
|
9
|
+
return `simple-suggest-aria-id:${index}`;
|
|
10
|
+
}
|
|
11
|
+
class SimpleSuggestWidgetItemRenderer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._onDidToggleDetails = ( new Emitter());
|
|
14
|
+
this.onDidToggleDetails = this._onDidToggleDetails.event;
|
|
15
|
+
this.templateId = 'suggestion';
|
|
16
|
+
}
|
|
17
|
+
dispose() {
|
|
18
|
+
this._onDidToggleDetails.dispose();
|
|
19
|
+
}
|
|
20
|
+
renderTemplate(container) {
|
|
21
|
+
const disposables = ( new DisposableStore());
|
|
22
|
+
const root = container;
|
|
23
|
+
root.classList.add('show-file-icons');
|
|
24
|
+
const icon = append(container, $('.icon'));
|
|
25
|
+
const colorspan = append(icon, $('span.colorspan'));
|
|
26
|
+
const text = append(container, $('.contents'));
|
|
27
|
+
const main = append(text, $('.main'));
|
|
28
|
+
const iconContainer = append(main, $('.icon-label.codicon'));
|
|
29
|
+
const left = append(main, $('span.left'));
|
|
30
|
+
const right = append(main, $('span.right'));
|
|
31
|
+
const iconLabel = ( new IconLabel(left, { supportHighlights: true, supportIcons: true }));
|
|
32
|
+
disposables.add(iconLabel);
|
|
33
|
+
const parametersLabel = append(left, $('span.signature-label'));
|
|
34
|
+
const qualifierLabel = append(left, $('span.qualifier-label'));
|
|
35
|
+
const detailsLabel = append(right, $('span.details-label'));
|
|
36
|
+
const configureFont = () => {
|
|
37
|
+
const fontFamily = 'Hack';
|
|
38
|
+
const fontFeatureSettings = '';
|
|
39
|
+
const fontSize = '12';
|
|
40
|
+
const lineHeight = '20';
|
|
41
|
+
const fontWeight = 'normal';
|
|
42
|
+
const letterSpacing = '0';
|
|
43
|
+
const fontSizePx = `${fontSize}px`;
|
|
44
|
+
const lineHeightPx = `${lineHeight}px`;
|
|
45
|
+
const letterSpacingPx = `${letterSpacing}px`;
|
|
46
|
+
root.style.fontSize = fontSizePx;
|
|
47
|
+
root.style.fontWeight = fontWeight;
|
|
48
|
+
root.style.letterSpacing = letterSpacingPx;
|
|
49
|
+
main.style.fontFamily = fontFamily;
|
|
50
|
+
main.style.fontFeatureSettings = fontFeatureSettings;
|
|
51
|
+
main.style.lineHeight = lineHeightPx;
|
|
52
|
+
icon.style.height = lineHeightPx;
|
|
53
|
+
icon.style.width = lineHeightPx;
|
|
54
|
+
};
|
|
55
|
+
configureFont();
|
|
56
|
+
return { root, left, right, icon, colorspan, iconLabel, iconContainer, parametersLabel, qualifierLabel, detailsLabel, disposables };
|
|
57
|
+
}
|
|
58
|
+
renderElement(element, index, data) {
|
|
59
|
+
const { completion } = element;
|
|
60
|
+
data.root.id = getAriaId(index);
|
|
61
|
+
data.colorspan.style.backgroundColor = '';
|
|
62
|
+
const labelOptions = {
|
|
63
|
+
labelEscapeNewLines: true,
|
|
64
|
+
matches: createMatches(element.score)
|
|
65
|
+
};
|
|
66
|
+
data.icon.className = 'icon hide';
|
|
67
|
+
data.iconContainer.className = '';
|
|
68
|
+
data.iconContainer.classList.add('suggest-icon', ...ThemeIcon.asClassNameArray(completion.icon || Codicon.symbolText));
|
|
69
|
+
data.iconLabel.setLabel(completion.label, undefined, labelOptions);
|
|
70
|
+
data.parametersLabel.textContent = '';
|
|
71
|
+
data.detailsLabel.textContent = stripNewLines(completion.detail || '');
|
|
72
|
+
data.root.classList.add('string-label');
|
|
73
|
+
show(data.detailsLabel);
|
|
74
|
+
data.right.classList.remove('can-expand-details');
|
|
75
|
+
}
|
|
76
|
+
disposeTemplate(templateData) {
|
|
77
|
+
templateData.disposables.dispose();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function stripNewLines(str) {
|
|
81
|
+
return str.replace(/\r\n|\r|\n/g, '');
|
|
82
|
+
}
|
|
83
|
+
export { SimpleSuggestWidgetItemRenderer, getAriaId };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileOperationError } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
2
2
|
import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
3
3
|
import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
4
|
-
import { isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
4
|
+
import { isUndefinedOrNull, areFunctions } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
5
5
|
const ITextFileService = ( createDecorator('textFileService'));
|
|
6
6
|
class TextFileOperationError extends FileOperationError {
|
|
7
7
|
static isTextFileOperationError(obj) {
|
|
@@ -13,6 +13,10 @@ class TextFileOperationError extends FileOperationError {
|
|
|
13
13
|
this.options = options;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
function isTextFileEditorModel(model) {
|
|
17
|
+
const candidate = model;
|
|
18
|
+
return areFunctions(candidate.setEncoding, candidate.getEncoding, candidate.save, candidate.revert, candidate.isDirty, candidate.getLanguageId);
|
|
19
|
+
}
|
|
16
20
|
function stringToSnapshot(value) {
|
|
17
21
|
let done = false;
|
|
18
22
|
return {
|
|
@@ -42,4 +46,4 @@ function toBufferOrReadable(value) {
|
|
|
42
46
|
}
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
|
-
export { ITextFileService, TextFileOperationError, stringToSnapshot, toBufferOrReadable };
|
|
49
|
+
export { ITextFileService, TextFileOperationError, isTextFileEditorModel, stringToSnapshot, toBufferOrReadable };
|