@codingame/monaco-vscode-8bcd87e5-7461-57cf-b4e4-a7b00d2b33df-common 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/empty.js +1 -0
- package/package.json +44 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.css +22 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.d.ts +88 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +334 -0
package/empty.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {}
|
package/package.json
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"name": "@codingame/monaco-vscode-8bcd87e5-7461-57cf-b4e4-a7b00d2b33df-common",
|
3
|
+
"version": "18.0.0",
|
4
|
+
"private": false,
|
5
|
+
"description": "VSCode public API plugged on the monaco editor - common package (extension-gallery, mcp, preferences, testing)",
|
6
|
+
"keywords": [],
|
7
|
+
"author": {
|
8
|
+
"name": "CodinGame",
|
9
|
+
"url": "http://www.codingame.com"
|
10
|
+
},
|
11
|
+
"license": "MIT",
|
12
|
+
"repository": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
|
15
|
+
},
|
16
|
+
"type": "module",
|
17
|
+
"dependencies": {
|
18
|
+
"@codingame/monaco-vscode-8d39d04c-3201-5bd6-be79-eed8d17a5ad0-common": "18.0.0",
|
19
|
+
"@codingame/monaco-vscode-api": "18.0.0"
|
20
|
+
},
|
21
|
+
"exports": {
|
22
|
+
".": {
|
23
|
+
"default": "./empty.js"
|
24
|
+
},
|
25
|
+
"./vscode/*.css": {
|
26
|
+
"default": "./vscode/src/*.css"
|
27
|
+
},
|
28
|
+
"./vscode/*": {
|
29
|
+
"types": "./vscode/src/*.d.ts",
|
30
|
+
"default": "./vscode/src/*.js"
|
31
|
+
},
|
32
|
+
"./*": {
|
33
|
+
"types": "./*.d.ts",
|
34
|
+
"default": "./*.js"
|
35
|
+
}
|
36
|
+
},
|
37
|
+
"typesVersions": {
|
38
|
+
"*": {
|
39
|
+
"vscode/*": [
|
40
|
+
"./vscode/src/*.d.ts"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.suggest-input-container {
|
2
|
+
padding: 2px 6px;
|
3
|
+
border-radius: 2px;
|
4
|
+
}
|
5
|
+
.suggest-input-container .monaco-editor-background,
|
6
|
+
.suggest-input-container .monaco-editor,
|
7
|
+
.suggest-input-container .mtk1 {
|
8
|
+
color: inherit;
|
9
|
+
}
|
10
|
+
.suggest-input-container .suggest-input-placeholder {
|
11
|
+
position: absolute;
|
12
|
+
z-index: 1;
|
13
|
+
overflow: hidden;
|
14
|
+
white-space: nowrap;
|
15
|
+
text-overflow: ellipsis;
|
16
|
+
pointer-events: none;
|
17
|
+
margin-top: 1px;
|
18
|
+
}
|
19
|
+
.suggest-input-container .monaco-editor,
|
20
|
+
.suggest-input-container .monaco-editor .lines-content {
|
21
|
+
background: none !important;
|
22
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { Dimension } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/dom";
|
2
|
+
import { IHistoryNavigationWidget } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/history";
|
3
|
+
import { Widget } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/widget";
|
4
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
5
|
+
import { HistoryNavigator } from "@codingame/monaco-vscode-api/vscode/vs/base/common/history";
|
6
|
+
import { CodeEditorWidget } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget";
|
7
|
+
import * as languages from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
|
8
|
+
import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service";
|
9
|
+
import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
|
10
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
11
|
+
import { IContextKey } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
|
12
|
+
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
13
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
14
|
+
import { ColorIdentifier } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorRegistry";
|
15
|
+
export interface SuggestResultsProvider {
|
16
|
+
provideResults: (query: string) => (Partial<languages.CompletionItem> & ({
|
17
|
+
label: string;
|
18
|
+
}) | string)[];
|
19
|
+
triggerCharacters?: string[];
|
20
|
+
wordDefinition?: RegExp;
|
21
|
+
alwaysShowSuggestions?: boolean;
|
22
|
+
sortKey?: (result: string) => string;
|
23
|
+
}
|
24
|
+
interface SuggestEnabledInputOptions {
|
25
|
+
placeholderText?: string;
|
26
|
+
value?: string;
|
27
|
+
focusContextKey?: IContextKey<boolean>;
|
28
|
+
overflowWidgetsDomNode?: HTMLElement;
|
29
|
+
styleOverrides?: ISuggestEnabledInputStyleOverrides;
|
30
|
+
}
|
31
|
+
export interface ISuggestEnabledInputStyleOverrides {
|
32
|
+
inputBackground?: ColorIdentifier;
|
33
|
+
inputForeground?: ColorIdentifier;
|
34
|
+
inputBorder?: ColorIdentifier;
|
35
|
+
inputPlaceholderForeground?: ColorIdentifier;
|
36
|
+
}
|
37
|
+
export declare class SuggestEnabledInput extends Widget {
|
38
|
+
private readonly _onShouldFocusResults;
|
39
|
+
readonly onShouldFocusResults: Event<void>;
|
40
|
+
private readonly _onInputDidChange;
|
41
|
+
readonly onInputDidChange: Event<string | undefined>;
|
42
|
+
private readonly _onDidFocus;
|
43
|
+
readonly onDidFocus: Event<void>;
|
44
|
+
private readonly _onDidBlur;
|
45
|
+
readonly onDidBlur: Event<void>;
|
46
|
+
readonly inputWidget: CodeEditorWidget;
|
47
|
+
private readonly inputModel;
|
48
|
+
protected stylingContainer: HTMLDivElement;
|
49
|
+
readonly element: HTMLElement;
|
50
|
+
private placeholderText;
|
51
|
+
constructor(id: string, parent: HTMLElement, suggestionProvider: SuggestResultsProvider, ariaLabel: string, resourceHandle: string, options: SuggestEnabledInputOptions, defaultInstantiationService: IInstantiationService, modelService: IModelService, contextKeyService: IContextKeyService, languageFeaturesService: ILanguageFeaturesService, configurationService: IConfigurationService);
|
52
|
+
protected getScopedContextKeyService(_contextKeyService: IContextKeyService): IContextKeyService | undefined;
|
53
|
+
updateAriaLabel(label: string): void;
|
54
|
+
setValue(val: string): void;
|
55
|
+
getValue(): string;
|
56
|
+
private style;
|
57
|
+
focus(selectAll?: boolean): void;
|
58
|
+
onHide(): void;
|
59
|
+
layout(dimension: Dimension): void;
|
60
|
+
private selectAll;
|
61
|
+
}
|
62
|
+
export interface ISuggestEnabledHistoryOptions {
|
63
|
+
id: string;
|
64
|
+
ariaLabel: string;
|
65
|
+
parent: HTMLElement;
|
66
|
+
suggestionProvider: SuggestResultsProvider;
|
67
|
+
resourceHandle: string;
|
68
|
+
suggestOptions: SuggestEnabledInputOptions;
|
69
|
+
history: string[];
|
70
|
+
}
|
71
|
+
export declare class SuggestEnabledInputWithHistory extends SuggestEnabledInput implements IHistoryNavigationWidget {
|
72
|
+
protected readonly history: HistoryNavigator<string>;
|
73
|
+
constructor({ id, parent, ariaLabel, suggestionProvider, resourceHandle, suggestOptions, history }: ISuggestEnabledHistoryOptions, instantiationService: IInstantiationService, modelService: IModelService, contextKeyService: IContextKeyService, languageFeaturesService: ILanguageFeaturesService, configurationService: IConfigurationService);
|
74
|
+
addToHistory(): void;
|
75
|
+
getHistory(): string[];
|
76
|
+
showNextValue(): void;
|
77
|
+
showPreviousValue(): void;
|
78
|
+
clearHistory(): void;
|
79
|
+
private getCurrentValue;
|
80
|
+
private getPreviousValue;
|
81
|
+
private getNextValue;
|
82
|
+
}
|
83
|
+
export declare class ContextScopedSuggestEnabledInputWithHistory extends SuggestEnabledInputWithHistory {
|
84
|
+
private historyContext;
|
85
|
+
constructor(options: ISuggestEnabledHistoryOptions, instantiationService: IInstantiationService, modelService: IModelService, contextKeyService: IContextKeyService, languageFeaturesService: ILanguageFeaturesService, configurationService: IConfigurationService);
|
86
|
+
protected getScopedContextKeyService(contextKeyService: IContextKeyService): import("@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey").IScopedContextKeyService;
|
87
|
+
}
|
88
|
+
export {};
|
@@ -0,0 +1,334 @@
|
|
1
|
+
|
2
|
+
import { registerCss } from '@codingame/monaco-vscode-api/css';
|
3
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
4
|
+
import { append, $ } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
5
|
+
import { DEFAULT_FONT_FAMILY } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/fonts';
|
6
|
+
import { Widget } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/widget';
|
7
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
8
|
+
import { HistoryNavigator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/history';
|
9
|
+
import { KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
10
|
+
import { mixin } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
11
|
+
import { isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
12
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
13
|
+
import * as suggestEnabledInput from './suggestEnabledInput.css';
|
14
|
+
import { EditorExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
|
15
|
+
import { CodeEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget';
|
16
|
+
import { EditOperation } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/editOperation';
|
17
|
+
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
18
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
19
|
+
import { ensureValidWordDefinition, getWordAtText } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/wordHelper';
|
20
|
+
import { CompletionItemKind } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
21
|
+
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
22
|
+
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
23
|
+
import { ContextMenuController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/contextmenu/browser/contextmenu';
|
24
|
+
import { SnippetController2 } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
25
|
+
import { SuggestController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/suggest/browser/suggestController';
|
26
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
27
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
28
|
+
import { registerAndCreateHistoryNavigationContext } from '@codingame/monaco-vscode-api/vscode/vs/platform/history/browser/contextScopedHistoryWidget';
|
29
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
30
|
+
import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
|
31
|
+
import { asCssVariable, asCssVariableWithDefault } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
|
32
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
|
33
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
|
34
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
|
35
|
+
import { inputBackground, inputForeground, inputPlaceholderForeground, inputBorder } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
|
36
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
|
37
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
|
38
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
|
39
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
|
40
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
|
41
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
|
42
|
+
import { MenuPreventer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/menuPreventer';
|
43
|
+
import { SelectionClipboardContributionID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/selectionClipboard';
|
44
|
+
import { getSimpleEditorOptions, setupSimpleEditorSelectionStyling } from '@codingame/monaco-vscode-8d39d04c-3201-5bd6-be79-eed8d17a5ad0-common/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
|
45
|
+
|
46
|
+
registerCss(suggestEnabledInput);
|
47
|
+
let SuggestEnabledInput = class SuggestEnabledInput extends Widget {
|
48
|
+
constructor(id, parent, suggestionProvider, ariaLabel, resourceHandle, options, defaultInstantiationService, modelService, contextKeyService, languageFeaturesService, configurationService) {
|
49
|
+
super();
|
50
|
+
this._onShouldFocusResults = ( new Emitter());
|
51
|
+
this.onShouldFocusResults = this._onShouldFocusResults.event;
|
52
|
+
this._onInputDidChange = ( new Emitter());
|
53
|
+
this.onInputDidChange = this._onInputDidChange.event;
|
54
|
+
this._onDidFocus = this._register(( new Emitter()));
|
55
|
+
this.onDidFocus = this._onDidFocus.event;
|
56
|
+
this._onDidBlur = this._register(( new Emitter()));
|
57
|
+
this.onDidBlur = this._onDidBlur.event;
|
58
|
+
this.stylingContainer = append(parent, $('.suggest-input-container'));
|
59
|
+
this.element = parent;
|
60
|
+
this.placeholderText = append(this.stylingContainer, $('.suggest-input-placeholder', undefined, options.placeholderText || ''));
|
61
|
+
const editorOptions = mixin(getSimpleEditorOptions(configurationService), getSuggestEnabledInputOptions(ariaLabel));
|
62
|
+
editorOptions.overflowWidgetsDomNode = options.overflowWidgetsDomNode;
|
63
|
+
const scopedContextKeyService = this.getScopedContextKeyService(contextKeyService);
|
64
|
+
const instantiationService = scopedContextKeyService
|
65
|
+
? this._register(defaultInstantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService]))))
|
66
|
+
: defaultInstantiationService;
|
67
|
+
this.inputWidget = this._register(instantiationService.createInstance(CodeEditorWidget, this.stylingContainer, editorOptions, {
|
68
|
+
contributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
69
|
+
SuggestController.ID,
|
70
|
+
SnippetController2.ID,
|
71
|
+
ContextMenuController.ID,
|
72
|
+
MenuPreventer.ID,
|
73
|
+
SelectionClipboardContributionID,
|
74
|
+
]),
|
75
|
+
isSimpleWidget: true,
|
76
|
+
}));
|
77
|
+
this._register(configurationService.onDidChangeConfiguration((e) => {
|
78
|
+
if (e.affectsConfiguration('editor.accessibilitySupport') ||
|
79
|
+
e.affectsConfiguration('editor.cursorBlinking')) {
|
80
|
+
const accessibilitySupport = configurationService.getValue('editor.accessibilitySupport');
|
81
|
+
const cursorBlinking = configurationService.getValue('editor.cursorBlinking');
|
82
|
+
this.inputWidget.updateOptions({
|
83
|
+
accessibilitySupport,
|
84
|
+
cursorBlinking
|
85
|
+
});
|
86
|
+
}
|
87
|
+
}));
|
88
|
+
this._register(this.inputWidget.onDidFocusEditorText(() => this._onDidFocus.fire()));
|
89
|
+
this._register(this.inputWidget.onDidBlurEditorText(() => this._onDidBlur.fire()));
|
90
|
+
const scopeHandle = URI.parse(resourceHandle);
|
91
|
+
this.inputModel = modelService.createModel('', null, scopeHandle, true);
|
92
|
+
this._register(this.inputModel);
|
93
|
+
this.inputWidget.setModel(this.inputModel);
|
94
|
+
this._register(this.inputWidget.onDidPaste(() => this.setValue(this.getValue())));
|
95
|
+
this._register((this.inputWidget.onDidFocusEditorText(() => {
|
96
|
+
if (options.focusContextKey) {
|
97
|
+
options.focusContextKey.set(true);
|
98
|
+
}
|
99
|
+
this.stylingContainer.classList.add('synthetic-focus');
|
100
|
+
})));
|
101
|
+
this._register((this.inputWidget.onDidBlurEditorText(() => {
|
102
|
+
if (options.focusContextKey) {
|
103
|
+
options.focusContextKey.set(false);
|
104
|
+
}
|
105
|
+
this.stylingContainer.classList.remove('synthetic-focus');
|
106
|
+
})));
|
107
|
+
this._register(Event.chain(this.inputWidget.onKeyDown, $ => $.filter(e => e.keyCode === KeyCode.Enter))(e => { e.preventDefault(); }, this));
|
108
|
+
this._register(Event.chain(this.inputWidget.onKeyDown, $ => $.filter(e => e.keyCode === KeyCode.DownArrow && (isMacintosh ? e.metaKey : e.ctrlKey)))(() => this._onShouldFocusResults.fire(), this));
|
109
|
+
let preexistingContent = this.getValue();
|
110
|
+
const inputWidgetModel = this.inputWidget.getModel();
|
111
|
+
if (inputWidgetModel) {
|
112
|
+
this._register(inputWidgetModel.onDidChangeContent(() => {
|
113
|
+
const content = this.getValue();
|
114
|
+
this.placeholderText.style.visibility = content ? 'hidden' : 'visible';
|
115
|
+
if (preexistingContent.trim() === content.trim()) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
this._onInputDidChange.fire(undefined);
|
119
|
+
preexistingContent = content;
|
120
|
+
}));
|
121
|
+
}
|
122
|
+
const validatedSuggestProvider = {
|
123
|
+
provideResults: suggestionProvider.provideResults,
|
124
|
+
sortKey: suggestionProvider.sortKey || (a => a),
|
125
|
+
triggerCharacters: suggestionProvider.triggerCharacters || [],
|
126
|
+
wordDefinition: suggestionProvider.wordDefinition ? ensureValidWordDefinition(suggestionProvider.wordDefinition) : undefined,
|
127
|
+
alwaysShowSuggestions: !!suggestionProvider.alwaysShowSuggestions,
|
128
|
+
};
|
129
|
+
this.setValue(options.value || '');
|
130
|
+
this._register(languageFeaturesService.completionProvider.register({ scheme: scopeHandle.scheme, pattern: '**/' + scopeHandle.path, hasAccessToAllModels: true }, {
|
131
|
+
_debugDisplayName: `suggestEnabledInput/${id}`,
|
132
|
+
triggerCharacters: validatedSuggestProvider.triggerCharacters,
|
133
|
+
provideCompletionItems: (model, position, _context) => {
|
134
|
+
const query = model.getValue();
|
135
|
+
const zeroIndexedColumn = position.column - 1;
|
136
|
+
let alreadyTypedCount = 0, zeroIndexedWordStart = 0;
|
137
|
+
if (validatedSuggestProvider.wordDefinition) {
|
138
|
+
const wordAtText = getWordAtText(position.column, validatedSuggestProvider.wordDefinition, query, 0);
|
139
|
+
alreadyTypedCount = wordAtText?.word.length ?? 0;
|
140
|
+
zeroIndexedWordStart = wordAtText ? wordAtText.startColumn - 1 : 0;
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
zeroIndexedWordStart = query.lastIndexOf(' ', zeroIndexedColumn - 1) + 1;
|
144
|
+
alreadyTypedCount = zeroIndexedColumn - zeroIndexedWordStart;
|
145
|
+
}
|
146
|
+
if (!validatedSuggestProvider.alwaysShowSuggestions && alreadyTypedCount > 0 && validatedSuggestProvider.triggerCharacters?.indexOf(query[zeroIndexedWordStart]) === -1) {
|
147
|
+
return { suggestions: [] };
|
148
|
+
}
|
149
|
+
return {
|
150
|
+
suggestions: ( suggestionProvider.provideResults(query).map((result) => {
|
151
|
+
let label;
|
152
|
+
let rest;
|
153
|
+
if (typeof result === 'string') {
|
154
|
+
label = result;
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
label = result.label;
|
158
|
+
rest = result;
|
159
|
+
}
|
160
|
+
return {
|
161
|
+
label,
|
162
|
+
insertText: label,
|
163
|
+
range: Range.fromPositions(position.delta(0, -alreadyTypedCount), position),
|
164
|
+
sortText: validatedSuggestProvider.sortKey(label),
|
165
|
+
kind: CompletionItemKind.Keyword,
|
166
|
+
...rest
|
167
|
+
};
|
168
|
+
}))
|
169
|
+
};
|
170
|
+
}
|
171
|
+
}));
|
172
|
+
this.style(options.styleOverrides || {});
|
173
|
+
}
|
174
|
+
getScopedContextKeyService(_contextKeyService) {
|
175
|
+
return undefined;
|
176
|
+
}
|
177
|
+
updateAriaLabel(label) {
|
178
|
+
this.inputWidget.updateOptions({ ariaLabel: label });
|
179
|
+
}
|
180
|
+
setValue(val) {
|
181
|
+
val = val.replace(/\s/g, ' ');
|
182
|
+
const fullRange = this.inputModel.getFullModelRange();
|
183
|
+
this.inputWidget.executeEdits('suggestEnabledInput.setValue', [EditOperation.replace(fullRange, val)]);
|
184
|
+
this.inputWidget.setScrollTop(0);
|
185
|
+
this.inputWidget.setPosition(( new Position(1, val.length + 1)));
|
186
|
+
}
|
187
|
+
getValue() {
|
188
|
+
return this.inputWidget.getValue();
|
189
|
+
}
|
190
|
+
style(styleOverrides) {
|
191
|
+
this.stylingContainer.style.backgroundColor = asCssVariable(styleOverrides.inputBackground ?? inputBackground);
|
192
|
+
this.stylingContainer.style.color = asCssVariable(styleOverrides.inputForeground ?? inputForeground);
|
193
|
+
this.placeholderText.style.color = asCssVariable(styleOverrides.inputPlaceholderForeground ?? inputPlaceholderForeground);
|
194
|
+
this.stylingContainer.style.borderWidth = '1px';
|
195
|
+
this.stylingContainer.style.borderStyle = 'solid';
|
196
|
+
this.stylingContainer.style.borderColor = asCssVariableWithDefault(styleOverrides.inputBorder ?? inputBorder, 'transparent');
|
197
|
+
const cursor = this.stylingContainer.getElementsByClassName('cursor')[0];
|
198
|
+
if (cursor) {
|
199
|
+
cursor.style.backgroundColor = asCssVariable(styleOverrides.inputForeground ?? inputForeground);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
focus(selectAll) {
|
203
|
+
this.inputWidget.focus();
|
204
|
+
if (selectAll && this.inputWidget.getValue()) {
|
205
|
+
this.selectAll();
|
206
|
+
}
|
207
|
+
}
|
208
|
+
onHide() {
|
209
|
+
this.inputWidget.onHide();
|
210
|
+
}
|
211
|
+
layout(dimension) {
|
212
|
+
this.inputWidget.layout(dimension);
|
213
|
+
this.placeholderText.style.width = `${dimension.width - 2}px`;
|
214
|
+
}
|
215
|
+
selectAll() {
|
216
|
+
this.inputWidget.setSelection(( new Range(1, 1, 1, this.getValue().length + 1)));
|
217
|
+
}
|
218
|
+
};
|
219
|
+
SuggestEnabledInput = ( __decorate([
|
220
|
+
( __param(6, IInstantiationService)),
|
221
|
+
( __param(7, IModelService)),
|
222
|
+
( __param(8, IContextKeyService)),
|
223
|
+
( __param(9, ILanguageFeaturesService)),
|
224
|
+
( __param(10, IConfigurationService))
|
225
|
+
], SuggestEnabledInput));
|
226
|
+
let SuggestEnabledInputWithHistory = class SuggestEnabledInputWithHistory extends SuggestEnabledInput {
|
227
|
+
constructor({ id, parent, ariaLabel, suggestionProvider, resourceHandle, suggestOptions, history }, instantiationService, modelService, contextKeyService, languageFeaturesService, configurationService) {
|
228
|
+
super(id, parent, suggestionProvider, ariaLabel, resourceHandle, suggestOptions, instantiationService, modelService, contextKeyService, languageFeaturesService, configurationService);
|
229
|
+
this.history = this._register(( new HistoryNavigator(( new Set(history)), 100)));
|
230
|
+
}
|
231
|
+
addToHistory() {
|
232
|
+
const value = this.getValue();
|
233
|
+
if (value && value !== this.getCurrentValue()) {
|
234
|
+
this.history.add(value);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
getHistory() {
|
238
|
+
return this.history.getHistory();
|
239
|
+
}
|
240
|
+
showNextValue() {
|
241
|
+
if (!( this.history.has(this.getValue()))) {
|
242
|
+
this.addToHistory();
|
243
|
+
}
|
244
|
+
let next = this.getNextValue();
|
245
|
+
if (next) {
|
246
|
+
next = next === this.getValue() ? this.getNextValue() : next;
|
247
|
+
}
|
248
|
+
this.setValue(next ?? '');
|
249
|
+
}
|
250
|
+
showPreviousValue() {
|
251
|
+
if (!( this.history.has(this.getValue()))) {
|
252
|
+
this.addToHistory();
|
253
|
+
}
|
254
|
+
let previous = this.getPreviousValue();
|
255
|
+
if (previous) {
|
256
|
+
previous = previous === this.getValue() ? this.getPreviousValue() : previous;
|
257
|
+
}
|
258
|
+
if (previous) {
|
259
|
+
this.setValue(previous);
|
260
|
+
this.inputWidget.setPosition({ lineNumber: 0, column: 0 });
|
261
|
+
}
|
262
|
+
}
|
263
|
+
clearHistory() {
|
264
|
+
this.history.clear();
|
265
|
+
}
|
266
|
+
getCurrentValue() {
|
267
|
+
let currentValue = this.history.current();
|
268
|
+
if (!currentValue) {
|
269
|
+
currentValue = this.history.last();
|
270
|
+
this.history.next();
|
271
|
+
}
|
272
|
+
return currentValue;
|
273
|
+
}
|
274
|
+
getPreviousValue() {
|
275
|
+
return this.history.previous() || this.history.first();
|
276
|
+
}
|
277
|
+
getNextValue() {
|
278
|
+
return this.history.next();
|
279
|
+
}
|
280
|
+
};
|
281
|
+
SuggestEnabledInputWithHistory = ( __decorate([
|
282
|
+
( __param(1, IInstantiationService)),
|
283
|
+
( __param(2, IModelService)),
|
284
|
+
( __param(3, IContextKeyService)),
|
285
|
+
( __param(4, ILanguageFeaturesService)),
|
286
|
+
( __param(5, IConfigurationService))
|
287
|
+
], SuggestEnabledInputWithHistory));
|
288
|
+
let ContextScopedSuggestEnabledInputWithHistory = class ContextScopedSuggestEnabledInputWithHistory extends SuggestEnabledInputWithHistory {
|
289
|
+
constructor(options, instantiationService, modelService, contextKeyService, languageFeaturesService, configurationService) {
|
290
|
+
super(options, instantiationService, modelService, contextKeyService, languageFeaturesService, configurationService);
|
291
|
+
const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this.historyContext;
|
292
|
+
this._register(this.inputWidget.onDidChangeCursorPosition(({ position }) => {
|
293
|
+
const viewModel = this.inputWidget._getViewModel();
|
294
|
+
const lastLineNumber = viewModel.getLineCount();
|
295
|
+
const lastLineCol = viewModel.getLineLength(lastLineNumber) + 1;
|
296
|
+
const viewPosition = viewModel.coordinatesConverter.convertModelPositionToViewPosition(position);
|
297
|
+
historyNavigationBackwardsEnablement.set(viewPosition.lineNumber === 1 && viewPosition.column === 1);
|
298
|
+
historyNavigationForwardsEnablement.set(viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol);
|
299
|
+
}));
|
300
|
+
}
|
301
|
+
getScopedContextKeyService(contextKeyService) {
|
302
|
+
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
|
303
|
+
this.historyContext = this._register(registerAndCreateHistoryNavigationContext(scopedContextKeyService, this));
|
304
|
+
return scopedContextKeyService;
|
305
|
+
}
|
306
|
+
};
|
307
|
+
ContextScopedSuggestEnabledInputWithHistory = ( __decorate([
|
308
|
+
( __param(1, IInstantiationService)),
|
309
|
+
( __param(2, IModelService)),
|
310
|
+
( __param(3, IContextKeyService)),
|
311
|
+
( __param(4, ILanguageFeaturesService)),
|
312
|
+
( __param(5, IConfigurationService))
|
313
|
+
], ContextScopedSuggestEnabledInputWithHistory));
|
314
|
+
setupSimpleEditorSelectionStyling('.suggest-input-container');
|
315
|
+
function getSuggestEnabledInputOptions(ariaLabel) {
|
316
|
+
return {
|
317
|
+
fontSize: 13,
|
318
|
+
lineHeight: 20,
|
319
|
+
wordWrap: 'off',
|
320
|
+
scrollbar: { vertical: 'hidden', },
|
321
|
+
roundedSelection: false,
|
322
|
+
guides: {
|
323
|
+
indentation: false
|
324
|
+
},
|
325
|
+
cursorWidth: 1,
|
326
|
+
fontFamily: DEFAULT_FONT_FAMILY,
|
327
|
+
ariaLabel: ariaLabel || '',
|
328
|
+
snippetSuggestions: 'none',
|
329
|
+
suggest: { filterGraceful: false, showIcons: false },
|
330
|
+
autoClosingBrackets: 'never'
|
331
|
+
};
|
332
|
+
}
|
333
|
+
|
334
|
+
export { ContextScopedSuggestEnabledInputWithHistory, SuggestEnabledInput, SuggestEnabledInputWithHistory };
|