@codingame/monaco-vscode-scm-service-override 26.2.2 → 27.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.
@@ -0,0 +1,828 @@
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 * as scm from './media/scm.css';
5
+ import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
6
+ import { MutableDisposable, DisposableStore, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
+ import { append, $, Dimension, trackFocus } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
8
+ import { InputValidationType, SCMInputChangeReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/scm';
9
+ import { ISCMViewService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/scm.service';
10
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
11
+ import { IContextMenuService, IContextViewService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
12
+ import { RawContextKey, ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
13
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
14
+ import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
15
+ import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
16
+ import { MenuItemAction, MenuId, registerAction2, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
17
+ import { IMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions.service';
18
+ import { ActionRunner, Action } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
19
+ import { ActionBar } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionbar';
20
+ import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
21
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
22
+ import { ThrottledDelayer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
23
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
24
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
25
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
26
+ import { CodeEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget';
27
+ import { getSimpleEditorOptions, setupSimpleEditorSelectionStyling } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
28
+ import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
29
+ import { EditorExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
30
+ import { MenuPreventer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/menuPreventer';
31
+ import { SelectionClipboardContributionID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/selectionClipboard';
32
+ import { EditorDictation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/dictation/editorDictation';
33
+ import { ContextMenuController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/contextmenu/browser/contextmenu';
34
+ import { isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
35
+ import { format } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
36
+ import { SuggestController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/suggest/browser/suggestController';
37
+ import { SnippetController2 } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/snippet/browser/snippetController2';
38
+ import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
39
+ import { ColorDetector } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/colorPicker/browser/colorDetector';
40
+ import { LinkDetector } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/links/browser/links';
41
+ import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
42
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
43
+ import { KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
44
+ import { DEFAULT_FONT_FAMILY } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/fonts';
45
+ import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
46
+ import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
47
+ import '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/contextview/contextview';
48
+ import { getFlatActionBarActions, createActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
49
+ import { openLinkFromMarkdown } from '@codingame/monaco-vscode-api/vscode/vs/platform/markdown/browser/markdownRenderer';
50
+ import { IMarkdownRendererService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markdown/browser/markdownRenderer.service';
51
+ import { DragAndDropController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/dnd/browser/dnd';
52
+ import { CopyPasteController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
53
+ import { DropIntoEditorController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
54
+ import { MessageController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/message/browser/messageController';
55
+ import { InlineCompletionsController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController';
56
+ import { CodeActionController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/codeAction/browser/codeActionController';
57
+ import { FormatOnType } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/format/browser/formatActions';
58
+ import { EditorOptions, EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
59
+ import { EditOperation } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/editOperation';
60
+ import { WorkbenchToolBar, HiddenItemStrategy } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/toolbar';
61
+ import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
62
+ import { DropdownWithPrimaryActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
63
+ import { clamp } from '@codingame/monaco-vscode-api/vscode/vs/base/common/numbers';
64
+ import { ContentHoverController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/hover/browser/contentHoverController';
65
+ import { GlyphHoverController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/hover/browser/glyphHoverController';
66
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
67
+ import { PlaceholderTextContribution } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/placeholderText/browser/placeholderTextContribution';
68
+ import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
69
+ import { AccessibilityVerbositySettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
70
+ import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
71
+ import { AccessibilityCommandId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/common/accessibilityCommands';
72
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/actions/chatContextKeys';
73
+ import product from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/product';
74
+ import { CHAT_SETUP_SUPPORT_ANONYMOUS_ACTION_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
75
+ import { AnchorAlignment } from '@codingame/monaco-vscode-api/vscode/vs/base/common/layout';
76
+ import { runOnChange } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/runOnChange';
77
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
78
+
79
+ var SCMInputWidget_1;
80
+ registerCss(scm);
81
+ const SCMInputContextKeys = {
82
+ SCMInputHasValidationMessage: ( new RawContextKey("scmInputHasValidationMessage", false))
83
+ };
84
+ var SCMInputWidgetCommandId;
85
+ (function(SCMInputWidgetCommandId) {
86
+ SCMInputWidgetCommandId["CancelAction"] = "scm.input.cancelAction";
87
+ SCMInputWidgetCommandId["SetupAction"] = "scm.input.triggerSetup";
88
+ })(SCMInputWidgetCommandId || (SCMInputWidgetCommandId = {}));
89
+ var SCMInputWidgetStorageKey;
90
+ (function(SCMInputWidgetStorageKey) {
91
+ SCMInputWidgetStorageKey["LastActionId"] = "scm.input.lastActionId";
92
+ })(SCMInputWidgetStorageKey || (SCMInputWidgetStorageKey = {}));
93
+ let SCMInputWidgetActionRunner = class SCMInputWidgetActionRunner extends ActionRunner {
94
+ get runningActions() {
95
+ return this._runningActions;
96
+ }
97
+ constructor(input, storageService) {
98
+ super();
99
+ this.input = input;
100
+ this.storageService = storageService;
101
+ this._runningActions = ( new Set());
102
+ }
103
+ async runAction(action) {
104
+ try {
105
+ if (this.runningActions.size !== 0) {
106
+ this._cts?.cancel();
107
+ if (action.id === SCMInputWidgetCommandId.CancelAction) {
108
+ return;
109
+ }
110
+ }
111
+ const context = [];
112
+ for (const group of this.input.repository.provider.groups) {
113
+ context.push({
114
+ resourceGroupId: group.id,
115
+ resources: [...( group.resources.map(r => r.sourceUri))]
116
+ });
117
+ }
118
+ this._runningActions.add(action);
119
+ this._cts = ( new CancellationTokenSource());
120
+ await action.run(...[this.input.repository.provider.rootUri, context, this._cts.token]);
121
+ } finally {
122
+ this._runningActions.delete(action);
123
+ if (this._runningActions.size === 0) {
124
+ const actionId = action.id === SCMInputWidgetCommandId.SetupAction ? product.defaultChatAgent?.generateCommitMessageCommand ?? action.id : action.id;
125
+ this.storageService.store(
126
+ SCMInputWidgetStorageKey.LastActionId,
127
+ actionId,
128
+ StorageScope.PROFILE,
129
+ StorageTarget.USER
130
+ );
131
+ }
132
+ }
133
+ }
134
+ };
135
+ SCMInputWidgetActionRunner = ( __decorate([( __param(1, IStorageService))], SCMInputWidgetActionRunner));
136
+ let SCMInputWidgetToolbar = class SCMInputWidgetToolbar extends WorkbenchToolBar {
137
+ get dropdownActions() {
138
+ return this._dropdownActions;
139
+ }
140
+ get dropdownAction() {
141
+ return this._dropdownAction;
142
+ }
143
+ constructor(
144
+ container,
145
+ options,
146
+ menuService,
147
+ contextKeyService,
148
+ contextMenuService,
149
+ commandService,
150
+ keybindingService,
151
+ storageService,
152
+ telemetryService
153
+ ) {
154
+ super(
155
+ container,
156
+ options,
157
+ menuService,
158
+ contextKeyService,
159
+ contextMenuService,
160
+ keybindingService,
161
+ commandService,
162
+ telemetryService
163
+ );
164
+ this.menuService = menuService;
165
+ this.contextKeyService = contextKeyService;
166
+ this.storageService = storageService;
167
+ this._dropdownActions = [];
168
+ this._onDidChange = this._register(( new Emitter()));
169
+ this.onDidChange = this._onDidChange.event;
170
+ this._disposables = this._register(( new MutableDisposable()));
171
+ this._dropdownAction = ( new Action("scmInputMoreActions", ( localize(11874, "More Actions...")), "codicon-chevron-down"));
172
+ this._cancelAction = ( new MenuItemAction({
173
+ id: SCMInputWidgetCommandId.CancelAction,
174
+ title: ( localize(11875, "Cancel")),
175
+ icon: Codicon.stopCircle
176
+ }, undefined, undefined, undefined, undefined, contextKeyService, commandService));
177
+ }
178
+ setInput(input) {
179
+ this._disposables.value = ( new DisposableStore());
180
+ const contextKeyService = this.contextKeyService.createOverlay([
181
+ ["scmProvider", input.repository.provider.providerId],
182
+ ["scmProviderRootUri", input.repository.provider.rootUri?.toString()],
183
+ ["scmProviderHasRootUri", !!input.repository.provider.rootUri]
184
+ ]);
185
+ const menu = this._disposables.value.add(this.menuService.createMenu(MenuId.SCMInputBox, contextKeyService, {
186
+ emitEventsForSubmenuChanges: true
187
+ }));
188
+ const isEnabled = () => {
189
+ return ( input.repository.provider.groups.some(g => g.resources.length > 0));
190
+ };
191
+ const updateToolbar = () => {
192
+ const actions = getFlatActionBarActions(menu.getActions({
193
+ shouldForwardArgs: true
194
+ }));
195
+ for (const action of actions) {
196
+ action.enabled = isEnabled();
197
+ }
198
+ this._dropdownAction.enabled = isEnabled();
199
+ let primaryAction = undefined;
200
+ if (this.actionRunner.runningActions.size !== 0) {
201
+ primaryAction = this._cancelAction;
202
+ } else if (actions.length === 1) {
203
+ primaryAction = actions[0];
204
+ } else if (actions.length > 1) {
205
+ const lastActionId = this.storageService.get(SCMInputWidgetStorageKey.LastActionId, StorageScope.PROFILE, "");
206
+ primaryAction = actions.find(a => a.id === lastActionId) ?? actions[0];
207
+ }
208
+ this._dropdownActions = actions.length === 1 ? [] : actions;
209
+ super.setActions(primaryAction ? [primaryAction] : [], []);
210
+ this._onDidChange.fire();
211
+ };
212
+ this._disposables.value.add(menu.onDidChange(() => updateToolbar()));
213
+ this._disposables.value.add(input.repository.provider.onDidChangeResources(() => updateToolbar()));
214
+ this._disposables.value.add(this.storageService.onDidChangeValue(
215
+ StorageScope.PROFILE,
216
+ SCMInputWidgetStorageKey.LastActionId,
217
+ this._disposables.value
218
+ )(() => updateToolbar()));
219
+ this.actionRunner = this._disposables.value.add(( new SCMInputWidgetActionRunner(input, this.storageService)));
220
+ this._disposables.value.add(this.actionRunner.onWillRun(e => {
221
+ if (this.actionRunner.runningActions.size === 0) {
222
+ super.setActions([this._cancelAction], []);
223
+ this._onDidChange.fire();
224
+ }
225
+ }));
226
+ this._disposables.value.add(this.actionRunner.onDidRun(e => {
227
+ if (this.actionRunner.runningActions.size === 0) {
228
+ updateToolbar();
229
+ }
230
+ }));
231
+ updateToolbar();
232
+ }
233
+ };
234
+ SCMInputWidgetToolbar = ( __decorate([( __param(2, IMenuService)), ( __param(3, IContextKeyService)), ( __param(4, IContextMenuService)), ( __param(5, ICommandService)), ( __param(6, IKeybindingService)), ( __param(7, IStorageService)), ( __param(8, ITelemetryService))], SCMInputWidgetToolbar));
235
+ class SCMInputWidgetEditorOptions {
236
+ constructor(overflowWidgetsDomNode, configurationService) {
237
+ this.overflowWidgetsDomNode = overflowWidgetsDomNode;
238
+ this.configurationService = configurationService;
239
+ this._onDidChange = ( new Emitter());
240
+ this.onDidChange = this._onDidChange.event;
241
+ this.defaultInputFontFamily = DEFAULT_FONT_FAMILY;
242
+ this._disposables = ( new DisposableStore());
243
+ const onDidChangeConfiguration = Event.filter(this.configurationService.onDidChangeConfiguration, e => {
244
+ return e.affectsConfiguration("editor.accessibilitySupport") || e.affectsConfiguration("editor.cursorBlinking") || e.affectsConfiguration("editor.cursorStyle") || e.affectsConfiguration("editor.cursorWidth") || e.affectsConfiguration("editor.emptySelectionClipboard") || e.affectsConfiguration("editor.fontFamily") || e.affectsConfiguration("editor.rulers") || e.affectsConfiguration("editor.wordWrap") || e.affectsConfiguration("editor.wordSegmenterLocales") || e.affectsConfiguration("scm.inputFontFamily") || e.affectsConfiguration("scm.inputFontSize");
245
+ }, this._disposables);
246
+ this._disposables.add(onDidChangeConfiguration(() => this._onDidChange.fire()));
247
+ }
248
+ getEditorConstructionOptions() {
249
+ return {
250
+ ...getSimpleEditorOptions(this.configurationService),
251
+ ...this.getEditorOptions(),
252
+ dragAndDrop: true,
253
+ dropIntoEditor: {
254
+ enabled: true
255
+ },
256
+ formatOnType: true,
257
+ lineDecorationsWidth: 6,
258
+ overflowWidgetsDomNode: this.overflowWidgetsDomNode,
259
+ padding: {
260
+ top: 2,
261
+ bottom: 2
262
+ },
263
+ quickSuggestions: false,
264
+ renderWhitespace: "none",
265
+ scrollbar: {
266
+ alwaysConsumeMouseWheel: false,
267
+ vertical: "hidden"
268
+ },
269
+ wrappingIndent: "none",
270
+ wrappingStrategy: "advanced"
271
+ };
272
+ }
273
+ getEditorOptions() {
274
+ const fontFamily = this._getEditorFontFamily();
275
+ const fontSize = this._getEditorFontSize();
276
+ const lineHeight = this._getEditorLineHeight(fontSize);
277
+ const wordSegmenterLocales = this.configurationService.getValue("editor.wordSegmenterLocales");
278
+ const accessibilitySupport = this.configurationService.getValue("editor.accessibilitySupport");
279
+ const cursorBlinking = this.configurationService.getValue("editor.cursorBlinking");
280
+ const cursorStyle = this.configurationService.getValue("editor.cursorStyle");
281
+ const cursorWidth = this.configurationService.getValue("editor.cursorWidth") ?? 1;
282
+ const emptySelectionClipboard = this.configurationService.getValue("editor.emptySelectionClipboard") === true;
283
+ return {
284
+ ...this._getEditorLanguageConfiguration(),
285
+ accessibilitySupport,
286
+ cursorBlinking,
287
+ cursorStyle,
288
+ cursorWidth,
289
+ fontFamily,
290
+ fontSize,
291
+ lineHeight,
292
+ emptySelectionClipboard,
293
+ wordSegmenterLocales
294
+ };
295
+ }
296
+ _getEditorFontFamily() {
297
+ const inputFontFamily = this.configurationService.getValue("scm.inputFontFamily").trim();
298
+ if (inputFontFamily.toLowerCase() === "editor") {
299
+ return this.configurationService.getValue("editor.fontFamily").trim();
300
+ }
301
+ if (inputFontFamily.length !== 0 && inputFontFamily.toLowerCase() !== "default") {
302
+ return inputFontFamily;
303
+ }
304
+ return this.defaultInputFontFamily;
305
+ }
306
+ _getEditorFontSize() {
307
+ return this.configurationService.getValue("scm.inputFontSize");
308
+ }
309
+ _getEditorLanguageConfiguration() {
310
+ const rulersConfig = this.configurationService.inspect("editor.rulers", {
311
+ overrideIdentifier: "scminput"
312
+ });
313
+ const rulers = rulersConfig.overrideIdentifiers?.includes("scminput") ? EditorOptions.rulers.validate(rulersConfig.value) : [];
314
+ const wordWrapConfig = this.configurationService.inspect("editor.wordWrap", {
315
+ overrideIdentifier: "scminput"
316
+ });
317
+ const wordWrap = wordWrapConfig.overrideIdentifiers?.includes("scminput") ? EditorOptions.wordWrap.validate(wordWrapConfig.value) : "on";
318
+ return {
319
+ rulers,
320
+ wordWrap
321
+ };
322
+ }
323
+ _getEditorLineHeight(fontSize) {
324
+ return Math.round(fontSize * 1.5);
325
+ }
326
+ dispose() {
327
+ this._disposables.dispose();
328
+ this._onDidChange.dispose();
329
+ }
330
+ }
331
+ let SCMInputWidget = class SCMInputWidget {
332
+ static {
333
+ SCMInputWidget_1 = this;
334
+ }
335
+ static {
336
+ this.ValidationTimeouts = {
337
+ [InputValidationType.Information]: 5000,
338
+ [InputValidationType.Warning]: 8000,
339
+ [InputValidationType.Error]: 10000
340
+ };
341
+ }
342
+ get input() {
343
+ return this.model?.input;
344
+ }
345
+ set input(input) {
346
+ if (input === this.input) {
347
+ return;
348
+ }
349
+ this.clearValidation();
350
+ this.element.classList.remove("synthetic-focus");
351
+ this.repositoryDisposables.clear();
352
+ this.repositoryIdContextKey.set(input?.repository.id);
353
+ if (!input) {
354
+ this.inputEditor.setModel(undefined);
355
+ this.model = undefined;
356
+ return;
357
+ }
358
+ const textModel = input.repository.provider.inputBoxTextModel;
359
+ this.inputEditor.setModel(textModel);
360
+ if (this.configurationService.getValue("editor.wordBasedSuggestions", {
361
+ resource: textModel.uri
362
+ }) !== "off") {
363
+ this.configurationService.updateValue("editor.wordBasedSuggestions", "off", {
364
+ resource: textModel.uri
365
+ }, ConfigurationTarget.MEMORY);
366
+ }
367
+ const validationDelayer = ( new ThrottledDelayer(200));
368
+ const validate = async () => {
369
+ const position = this.inputEditor.getSelection()?.getStartPosition();
370
+ const offset = position && textModel.getOffsetAt(position);
371
+ const value = textModel.getValue();
372
+ this.setValidation(await input.validateInput(value, offset || 0));
373
+ };
374
+ const triggerValidation = () => validationDelayer.trigger(validate);
375
+ this.repositoryDisposables.add(validationDelayer);
376
+ this.repositoryDisposables.add(this.inputEditor.onDidChangeCursorPosition(triggerValidation));
377
+ const opts = this.modelService.getCreationOptions(textModel.getLanguageId(), textModel.uri, textModel.isForSimpleWidget);
378
+ const onEnter = Event.filter(
379
+ this.inputEditor.onKeyDown,
380
+ e => e.keyCode === KeyCode.Enter,
381
+ this.repositoryDisposables
382
+ );
383
+ this.repositoryDisposables.add(
384
+ onEnter(() => textModel.detectIndentation(opts.insertSpaces, opts.tabSize))
385
+ );
386
+ textModel.setValue(input.value);
387
+ this.repositoryDisposables.add(input.onDidChange((
388
+ {
389
+ value,
390
+ reason
391
+ }
392
+ ) => {
393
+ const currentValue = textModel.getValue();
394
+ if (value === currentValue) {
395
+ return;
396
+ }
397
+ textModel.pushStackElement();
398
+ textModel.pushEditOperations(
399
+ null,
400
+ [EditOperation.replaceMove(textModel.getFullModelRange(), value)],
401
+ () => []
402
+ );
403
+ const position = reason === SCMInputChangeReason.HistoryPrevious ? textModel.getFullModelRange().getStartPosition() : textModel.getFullModelRange().getEndPosition();
404
+ this.inputEditor.setPosition(position);
405
+ this.inputEditor.revealPositionInCenterIfOutsideViewport(position);
406
+ }));
407
+ this.repositoryDisposables.add(input.onDidChangeFocus(() => this.focus()));
408
+ this.repositoryDisposables.add(input.onDidChangeValidationMessage(e => this.setValidation(e, {
409
+ focus: true,
410
+ timeout: true
411
+ })));
412
+ this.repositoryDisposables.add(input.onDidChangeValidateInput(e => triggerValidation()));
413
+ this.repositoryDisposables.add(input.onDidClearValidation(() => this.clearValidation()));
414
+ this.repositoryDisposables.add(textModel.onDidChangeContent(() => {
415
+ input.setValue(textModel.getValue(), true);
416
+ triggerValidation();
417
+ }));
418
+ const accessibilityVerbosityConfig = observableConfigValue(
419
+ AccessibilityVerbositySettingId.SourceControl,
420
+ true,
421
+ this.configurationService
422
+ );
423
+ const getAriaLabel = (placeholder, verbosity) => {
424
+ verbosity = verbosity ?? accessibilityVerbosityConfig.get();
425
+ if (!verbosity || !this.accessibilityService.isScreenReaderOptimized()) {
426
+ return placeholder;
427
+ }
428
+ const kbLabel = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
429
+ return kbLabel ? ( localize(
430
+ 11876,
431
+ "{0}, Use {1} to open Source Control Accessibility Help.",
432
+ placeholder,
433
+ kbLabel
434
+ )) : ( localize(
435
+ 11877,
436
+ "{0}, Run the Open Accessibility Help command for more information.",
437
+ placeholder
438
+ ));
439
+ };
440
+ const getPlaceholderText = () => {
441
+ const binding = this.keybindingService.lookupKeybinding("scm.acceptInput");
442
+ const label = binding ? binding.getLabel() : (isMacintosh ? "Cmd+Enter" : "Ctrl+Enter");
443
+ return format(input.placeholder, label);
444
+ };
445
+ const updatePlaceholderText = () => {
446
+ const placeholder = getPlaceholderText();
447
+ const ariaLabel = getAriaLabel(placeholder);
448
+ this.inputEditor.updateOptions({
449
+ ariaLabel,
450
+ placeholder
451
+ });
452
+ };
453
+ this.repositoryDisposables.add(input.onDidChangePlaceholder(updatePlaceholderText));
454
+ this.repositoryDisposables.add(this.keybindingService.onDidUpdateKeybindings(updatePlaceholderText));
455
+ this.repositoryDisposables.add(runOnChange(accessibilityVerbosityConfig, verbosity => {
456
+ const placeholder = getPlaceholderText();
457
+ const ariaLabel = getAriaLabel(placeholder, verbosity);
458
+ this.inputEditor.updateOptions({
459
+ ariaLabel
460
+ });
461
+ }));
462
+ updatePlaceholderText();
463
+ let commitTemplate = "";
464
+ this.repositoryDisposables.add(autorun(reader => {
465
+ if (!input.visible) {
466
+ return;
467
+ }
468
+ const oldCommitTemplate = commitTemplate;
469
+ commitTemplate = input.repository.provider.commitTemplate.read(reader);
470
+ const value = textModel.getValue();
471
+ if (value && value !== oldCommitTemplate) {
472
+ return;
473
+ }
474
+ textModel.setValue(commitTemplate);
475
+ }));
476
+ const updateEnablement = enabled => {
477
+ this.inputEditor.updateOptions({
478
+ readOnly: !enabled
479
+ });
480
+ };
481
+ this.repositoryDisposables.add(input.onDidChangeEnablement(enabled => updateEnablement(enabled)));
482
+ updateEnablement(input.enabled);
483
+ this.toolbar.setInput(input);
484
+ this.model = {
485
+ input,
486
+ textModel
487
+ };
488
+ }
489
+ get selections() {
490
+ return this.inputEditor.getSelections();
491
+ }
492
+ set selections(selections) {
493
+ if (selections) {
494
+ this.inputEditor.setSelections(selections);
495
+ }
496
+ }
497
+ setValidation(validation, options) {
498
+ if (this._validationTimer) {
499
+ clearTimeout(this._validationTimer);
500
+ this._validationTimer = undefined;
501
+ }
502
+ this.validation = validation;
503
+ this.renderValidation();
504
+ if (options?.focus && !this.hasFocus()) {
505
+ this.focus();
506
+ }
507
+ if (validation && options?.timeout) {
508
+ this._validationTimer = setTimeout(
509
+ () => this.setValidation(undefined),
510
+ SCMInputWidget_1.ValidationTimeouts[validation.type]
511
+ );
512
+ }
513
+ }
514
+ constructor(
515
+ container,
516
+ overflowWidgetsDomNode,
517
+ contextKeyService,
518
+ instantiationService,
519
+ modelService,
520
+ keybindingService,
521
+ configurationService,
522
+ scmViewService,
523
+ contextViewService,
524
+ openerService,
525
+ accessibilityService,
526
+ markdownRendererService
527
+ ) {
528
+ this.modelService = modelService;
529
+ this.keybindingService = keybindingService;
530
+ this.configurationService = configurationService;
531
+ this.scmViewService = scmViewService;
532
+ this.contextViewService = contextViewService;
533
+ this.openerService = openerService;
534
+ this.accessibilityService = accessibilityService;
535
+ this.markdownRendererService = markdownRendererService;
536
+ this.disposables = ( new DisposableStore());
537
+ this.repositoryDisposables = ( new DisposableStore());
538
+ this.validationHasFocus = false;
539
+ this.lastLayoutWasTrash = false;
540
+ this.shouldFocusAfterLayout = false;
541
+ this.element = append(container, $(".scm-editor"));
542
+ this.editorContainer = append(this.element, $(".scm-editor-container"));
543
+ this.toolbarContainer = append(this.element, $(".scm-editor-toolbar"));
544
+ this.contextKeyService = this.disposables.add(contextKeyService.createScoped(this.element));
545
+ this.repositoryIdContextKey = this.contextKeyService.createKey("scmRepository", undefined);
546
+ this.validationMessageContextKey = SCMInputContextKeys.SCMInputHasValidationMessage.bindTo(this.contextKeyService);
547
+ this.inputEditorOptions = ( new SCMInputWidgetEditorOptions(overflowWidgetsDomNode, this.configurationService));
548
+ this.disposables.add(this.inputEditorOptions.onDidChange(this.onDidChangeEditorOptions, this));
549
+ this.disposables.add(this.inputEditorOptions);
550
+ const codeEditorWidgetOptions = {
551
+ contributions: EditorExtensionsRegistry.getSomeEditorContributions([
552
+ CodeActionController.ID,
553
+ ColorDetector.ID,
554
+ ContextMenuController.ID,
555
+ CopyPasteController.ID,
556
+ DragAndDropController.ID,
557
+ DropIntoEditorController.ID,
558
+ EditorDictation.ID,
559
+ FormatOnType.ID,
560
+ ContentHoverController.ID,
561
+ GlyphHoverController.ID,
562
+ InlineCompletionsController.ID,
563
+ LinkDetector.ID,
564
+ MenuPreventer.ID,
565
+ MessageController.ID,
566
+ PlaceholderTextContribution.ID,
567
+ SelectionClipboardContributionID,
568
+ SnippetController2.ID,
569
+ SuggestController.ID
570
+ ]),
571
+ isSimpleWidget: true
572
+ };
573
+ const services = ( new ServiceCollection([IContextKeyService, this.contextKeyService]));
574
+ const instantiationService2 = instantiationService.createChild(services, this.disposables);
575
+ const editorConstructionOptions = this.inputEditorOptions.getEditorConstructionOptions();
576
+ this.inputEditor = instantiationService2.createInstance(
577
+ CodeEditorWidget,
578
+ this.editorContainer,
579
+ editorConstructionOptions,
580
+ codeEditorWidgetOptions
581
+ );
582
+ this.disposables.add(this.inputEditor);
583
+ this.disposables.add(this.inputEditor.onDidFocusEditorText(() => {
584
+ if (this.input?.repository) {
585
+ this.scmViewService.focus(this.input.repository);
586
+ }
587
+ this.element.classList.add("synthetic-focus");
588
+ this.renderValidation();
589
+ }));
590
+ this.disposables.add(this.inputEditor.onDidBlurEditorText(() => {
591
+ this.element.classList.remove("synthetic-focus");
592
+ setTimeout(() => {
593
+ if (!this.validation || !this.validationHasFocus) {
594
+ this.clearValidation();
595
+ }
596
+ }, 0);
597
+ }));
598
+ this.disposables.add(this.inputEditor.onDidBlurEditorWidget(() => {
599
+ CopyPasteController.get(this.inputEditor)?.clearWidgets();
600
+ DropIntoEditorController.get(this.inputEditor)?.clearWidgets();
601
+ }));
602
+ const firstLineKey = this.contextKeyService.createKey("scmInputIsInFirstPosition", false);
603
+ const lastLineKey = this.contextKeyService.createKey("scmInputIsInLastPosition", false);
604
+ this.disposables.add(this.inputEditor.onDidChangeCursorPosition((
605
+ {
606
+ position
607
+ }
608
+ ) => {
609
+ const viewModel = this.inputEditor._getViewModel();
610
+ const lastLineNumber = viewModel.getLineCount();
611
+ const lastLineCol = viewModel.getLineLength(lastLineNumber) + 1;
612
+ const viewPosition = viewModel.coordinatesConverter.convertModelPositionToViewPosition(position);
613
+ firstLineKey.set(viewPosition.lineNumber === 1 && viewPosition.column === 1);
614
+ lastLineKey.set(
615
+ viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol
616
+ );
617
+ }));
618
+ this.disposables.add(this.inputEditor.onDidScrollChange(e => {
619
+ this.toolbarContainer.classList.toggle("scroll-decoration", e.scrollTop > 0);
620
+ }));
621
+ Event.filter(
622
+ this.configurationService.onDidChangeConfiguration,
623
+ e => e.affectsConfiguration("scm.showInputActionButton")
624
+ )(() => this.layout(), this, this.disposables);
625
+ this.onDidChangeContentHeight = Event.signal(Event.filter(
626
+ this.inputEditor.onDidContentSizeChange,
627
+ e => e.contentHeightChanged,
628
+ this.disposables
629
+ ));
630
+ this.toolbar = instantiationService2.createInstance(SCMInputWidgetToolbar, this.toolbarContainer, {
631
+ actionViewItemProvider: (action, options) => {
632
+ if (action instanceof MenuItemAction && this.toolbar.dropdownActions.length > 1) {
633
+ return instantiationService.createInstance(
634
+ DropdownWithPrimaryActionViewItem,
635
+ action,
636
+ this.toolbar.dropdownAction,
637
+ this.toolbar.dropdownActions,
638
+ "",
639
+ {
640
+ actionRunner: this.toolbar.actionRunner,
641
+ hoverDelegate: options.hoverDelegate
642
+ }
643
+ );
644
+ }
645
+ return createActionViewItem(instantiationService, action, options);
646
+ },
647
+ hiddenItemStrategy: HiddenItemStrategy.NoHide,
648
+ menuOptions: {
649
+ shouldForwardArgs: true
650
+ }
651
+ });
652
+ this.disposables.add(this.toolbar.onDidChange(() => this.layout()));
653
+ this.disposables.add(this.toolbar);
654
+ }
655
+ getContentHeight() {
656
+ const lineHeight = this.inputEditor.getOption(EditorOption.lineHeight);
657
+ const {
658
+ top,
659
+ bottom
660
+ } = this.inputEditor.getOption(EditorOption.padding);
661
+ const inputMinLinesConfig = this.configurationService.getValue("scm.inputMinLineCount");
662
+ const inputMinLines = typeof inputMinLinesConfig === "number" ? clamp(inputMinLinesConfig, 1, 50) : 1;
663
+ const editorMinHeight = inputMinLines * lineHeight + top + bottom;
664
+ const inputMaxLinesConfig = this.configurationService.getValue("scm.inputMaxLineCount");
665
+ const inputMaxLines = typeof inputMaxLinesConfig === "number" ? clamp(inputMaxLinesConfig, 1, 50) : 10;
666
+ const editorMaxHeight = inputMaxLines * lineHeight + top + bottom;
667
+ return clamp(this.inputEditor.getContentHeight(), editorMinHeight, editorMaxHeight);
668
+ }
669
+ layout() {
670
+ const editorHeight = this.getContentHeight();
671
+ const toolbarWidth = this.getToolbarWidth();
672
+ const dimension = ( new Dimension(this.element.clientWidth - toolbarWidth, editorHeight));
673
+ if (dimension.width < 0) {
674
+ this.lastLayoutWasTrash = true;
675
+ return;
676
+ }
677
+ this.lastLayoutWasTrash = false;
678
+ this.inputEditor.layout(dimension);
679
+ this.renderValidation();
680
+ const showInputActionButton = this.configurationService.getValue("scm.showInputActionButton") === true;
681
+ this.toolbarContainer.classList.toggle("hidden", !showInputActionButton || this.toolbar?.isEmpty() === true);
682
+ if (this.shouldFocusAfterLayout) {
683
+ this.shouldFocusAfterLayout = false;
684
+ this.focus();
685
+ }
686
+ }
687
+ focus() {
688
+ if (this.lastLayoutWasTrash) {
689
+ this.lastLayoutWasTrash = false;
690
+ this.shouldFocusAfterLayout = true;
691
+ return;
692
+ }
693
+ this.inputEditor.focus();
694
+ this.element.classList.add("synthetic-focus");
695
+ }
696
+ hasFocus() {
697
+ return this.inputEditor.hasTextFocus();
698
+ }
699
+ onDidChangeEditorOptions() {
700
+ this.inputEditor.updateOptions(this.inputEditorOptions.getEditorOptions());
701
+ }
702
+ renderValidation() {
703
+ this.clearValidation();
704
+ this.element.classList.toggle(
705
+ "validation-info",
706
+ this.validation?.type === InputValidationType.Information
707
+ );
708
+ this.element.classList.toggle(
709
+ "validation-warning",
710
+ this.validation?.type === InputValidationType.Warning
711
+ );
712
+ this.element.classList.toggle("validation-error", this.validation?.type === InputValidationType.Error);
713
+ if (!this.validation || !this.inputEditor.hasTextFocus()) {
714
+ return;
715
+ }
716
+ this.validationMessageContextKey.set(true);
717
+ const disposables = ( new DisposableStore());
718
+ this.validationContextView = this.contextViewService.showContextView({
719
+ getAnchor: () => this.element,
720
+ render: container => {
721
+ this.element.style.borderBottomLeftRadius = "0";
722
+ this.element.style.borderBottomRightRadius = "0";
723
+ const validationContainer = append(container, $(".scm-editor-validation-container"));
724
+ validationContainer.classList.toggle(
725
+ "validation-info",
726
+ this.validation.type === InputValidationType.Information
727
+ );
728
+ validationContainer.classList.toggle("validation-warning", this.validation.type === InputValidationType.Warning);
729
+ validationContainer.classList.toggle("validation-error", this.validation.type === InputValidationType.Error);
730
+ validationContainer.style.width = `${this.element.clientWidth + 2}px`;
731
+ const element = append(validationContainer, $(".scm-editor-validation"));
732
+ const message = this.validation.message;
733
+ if (typeof message === "string") {
734
+ element.textContent = message;
735
+ } else {
736
+ const tracker = trackFocus(element);
737
+ disposables.add(tracker);
738
+ disposables.add(tracker.onDidFocus(() => (this.validationHasFocus = true)));
739
+ disposables.add(tracker.onDidBlur(() => {
740
+ this.validationHasFocus = false;
741
+ this.element.style.borderBottomLeftRadius = "2px";
742
+ this.element.style.borderBottomRightRadius = "2px";
743
+ this.contextViewService.hideContextView();
744
+ }));
745
+ const renderedMarkdown = this.markdownRendererService.render(message, {
746
+ actionHandler: (link, mdStr) => {
747
+ openLinkFromMarkdown(this.openerService, link, mdStr.isTrusted);
748
+ this.element.style.borderBottomLeftRadius = "2px";
749
+ this.element.style.borderBottomRightRadius = "2px";
750
+ this.contextViewService.hideContextView();
751
+ }
752
+ });
753
+ disposables.add(renderedMarkdown);
754
+ element.appendChild(renderedMarkdown.element);
755
+ }
756
+ const actionsContainer = append(validationContainer, $(".scm-editor-validation-actions"));
757
+ const actionbar = ( new ActionBar(actionsContainer));
758
+ const action = ( new Action("scmInputWidget.validationMessage.close", ( localize(11878, "Close")), ThemeIcon.asClassName(Codicon.close), true, () => {
759
+ this.contextViewService.hideContextView();
760
+ this.element.style.borderBottomLeftRadius = "2px";
761
+ this.element.style.borderBottomRightRadius = "2px";
762
+ }));
763
+ disposables.add(actionbar);
764
+ actionbar.push(action, {
765
+ icon: true,
766
+ label: false
767
+ });
768
+ return Disposable.None;
769
+ },
770
+ onHide: () => {
771
+ this.validationHasFocus = false;
772
+ this.element.style.borderBottomLeftRadius = "2px";
773
+ this.element.style.borderBottomRightRadius = "2px";
774
+ disposables.dispose();
775
+ },
776
+ anchorAlignment: AnchorAlignment.LEFT
777
+ });
778
+ }
779
+ getToolbarWidth() {
780
+ const showInputActionButton = this.configurationService.getValue("scm.showInputActionButton");
781
+ if (!this.toolbar || !showInputActionButton || this.toolbar?.isEmpty() === true) {
782
+ return 0;
783
+ }
784
+ return this.toolbar.dropdownActions.length === 0 ? 26 : 39 ;
785
+ }
786
+ clearValidation() {
787
+ this.validationContextView?.close();
788
+ this.validationContextView = undefined;
789
+ this.validationHasFocus = false;
790
+ this.validationMessageContextKey.set(false);
791
+ }
792
+ dispose() {
793
+ this.input = undefined;
794
+ this.repositoryDisposables.dispose();
795
+ this.clearValidation();
796
+ this.disposables.dispose();
797
+ }
798
+ };
799
+ SCMInputWidget = SCMInputWidget_1 = ( __decorate([( __param(2, IContextKeyService)), ( __param(3, IInstantiationService)), ( __param(4, IModelService)), ( __param(5, IKeybindingService)), ( __param(6, IConfigurationService)), ( __param(7, ISCMViewService)), ( __param(8, IContextViewService)), ( __param(9, IOpenerService)), ( __param(10, IAccessibilityService)), ( __param(11, IMarkdownRendererService))], SCMInputWidget));
800
+ registerAction2(class extends Action2 {
801
+ constructor() {
802
+ super({
803
+ id: SCMInputWidgetCommandId.SetupAction,
804
+ title: ( localize(11879, "Generate Commit Message")),
805
+ icon: Codicon.sparkle,
806
+ f1: false,
807
+ menu: {
808
+ id: MenuId.SCMInputBox,
809
+ when: ( ContextKeyExpr.and(( ChatContextKeys.Setup.hidden.negate()), ( ChatContextKeys.Setup.disabled.negate()), ( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.equals("scmProvider", "git"))))
810
+ }
811
+ });
812
+ }
813
+ async run(accessor, ...args) {
814
+ const commandService = accessor.get(ICommandService);
815
+ const result = await commandService.executeCommand(CHAT_SETUP_SUPPORT_ANONYMOUS_ACTION_ID);
816
+ if (!result) {
817
+ return;
818
+ }
819
+ const command = product.defaultChatAgent?.generateCommitMessageCommand;
820
+ if (!command) {
821
+ return;
822
+ }
823
+ await commandService.executeCommand(command, ...args);
824
+ }
825
+ });
826
+ setupSimpleEditorSelectionStyling(".scm-view .scm-editor-container");
827
+
828
+ export { SCMInputContextKeys, SCMInputWidget };