@codingame/monaco-vscode-scm-service-override 26.2.2 → 28.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/index.js +6 -2
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/activity.js +5 -5
- package/vscode/src/vs/workbench/contrib/scm/browser/media/scm.css +1 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/menus.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/menus.js +3 -3
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffDecorator.js +3 -3
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffWidget.js +13 -13
- package/vscode/src/vs/workbench/contrib/scm/browser/scm.contribution.js +75 -74
- package/vscode/src/vs/workbench/contrib/scm/browser/scmAccessibilityHelp.js +23 -23
- package/vscode/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.js +26 -26
- package/vscode/src/vs/workbench/contrib/scm/browser/scmInput.d.ts +62 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/scmInput.js +830 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.js +2 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewPane.d.ts +1 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewPane.js +35 -814
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewService.js +2 -1
- package/vscode/src/vs/workbench/contrib/scm/common/scmService.js +10 -8
|
@@ -0,0 +1,830 @@
|
|
|
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(12070, "More Actions...")), "codicon-chevron-down"));
|
|
172
|
+
this._cancelAction = ( new MenuItemAction({
|
|
173
|
+
id: SCMInputWidgetCommandId.CancelAction,
|
|
174
|
+
title: ( localize(12071, "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.roundedSelection") || 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
|
+
const roundedSelection = this.configurationService.getValue("editor.roundedSelection") === true;
|
|
284
|
+
return {
|
|
285
|
+
...this._getEditorLanguageConfiguration(),
|
|
286
|
+
accessibilitySupport,
|
|
287
|
+
cursorBlinking,
|
|
288
|
+
cursorStyle,
|
|
289
|
+
cursorWidth,
|
|
290
|
+
fontFamily,
|
|
291
|
+
fontSize,
|
|
292
|
+
lineHeight,
|
|
293
|
+
emptySelectionClipboard,
|
|
294
|
+
roundedSelection,
|
|
295
|
+
wordSegmenterLocales
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
_getEditorFontFamily() {
|
|
299
|
+
const inputFontFamily = this.configurationService.getValue("scm.inputFontFamily").trim();
|
|
300
|
+
if (inputFontFamily.toLowerCase() === "editor") {
|
|
301
|
+
return this.configurationService.getValue("editor.fontFamily").trim();
|
|
302
|
+
}
|
|
303
|
+
if (inputFontFamily.length !== 0 && inputFontFamily.toLowerCase() !== "default") {
|
|
304
|
+
return inputFontFamily;
|
|
305
|
+
}
|
|
306
|
+
return this.defaultInputFontFamily;
|
|
307
|
+
}
|
|
308
|
+
_getEditorFontSize() {
|
|
309
|
+
return this.configurationService.getValue("scm.inputFontSize");
|
|
310
|
+
}
|
|
311
|
+
_getEditorLanguageConfiguration() {
|
|
312
|
+
const rulersConfig = this.configurationService.inspect("editor.rulers", {
|
|
313
|
+
overrideIdentifier: "scminput"
|
|
314
|
+
});
|
|
315
|
+
const rulers = rulersConfig.overrideIdentifiers?.includes("scminput") ? EditorOptions.rulers.validate(rulersConfig.value) : [];
|
|
316
|
+
const wordWrapConfig = this.configurationService.inspect("editor.wordWrap", {
|
|
317
|
+
overrideIdentifier: "scminput"
|
|
318
|
+
});
|
|
319
|
+
const wordWrap = wordWrapConfig.overrideIdentifiers?.includes("scminput") ? EditorOptions.wordWrap.validate(wordWrapConfig.value) : "on";
|
|
320
|
+
return {
|
|
321
|
+
rulers,
|
|
322
|
+
wordWrap
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
_getEditorLineHeight(fontSize) {
|
|
326
|
+
return Math.round(fontSize * 1.5);
|
|
327
|
+
}
|
|
328
|
+
dispose() {
|
|
329
|
+
this._disposables.dispose();
|
|
330
|
+
this._onDidChange.dispose();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
let SCMInputWidget = class SCMInputWidget {
|
|
334
|
+
static {
|
|
335
|
+
SCMInputWidget_1 = this;
|
|
336
|
+
}
|
|
337
|
+
static {
|
|
338
|
+
this.ValidationTimeouts = {
|
|
339
|
+
[InputValidationType.Information]: 5000,
|
|
340
|
+
[InputValidationType.Warning]: 8000,
|
|
341
|
+
[InputValidationType.Error]: 10000
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
get input() {
|
|
345
|
+
return this.model?.input;
|
|
346
|
+
}
|
|
347
|
+
set input(input) {
|
|
348
|
+
if (input === this.input) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this.clearValidation();
|
|
352
|
+
this.element.classList.remove("synthetic-focus");
|
|
353
|
+
this.repositoryDisposables.clear();
|
|
354
|
+
this.repositoryIdContextKey.set(input?.repository.id);
|
|
355
|
+
if (!input) {
|
|
356
|
+
this.inputEditor.setModel(undefined);
|
|
357
|
+
this.model = undefined;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const textModel = input.repository.provider.inputBoxTextModel;
|
|
361
|
+
this.inputEditor.setModel(textModel);
|
|
362
|
+
if (this.configurationService.getValue("editor.wordBasedSuggestions", {
|
|
363
|
+
resource: textModel.uri
|
|
364
|
+
}) !== "off") {
|
|
365
|
+
this.configurationService.updateValue("editor.wordBasedSuggestions", "off", {
|
|
366
|
+
resource: textModel.uri
|
|
367
|
+
}, ConfigurationTarget.MEMORY);
|
|
368
|
+
}
|
|
369
|
+
const validationDelayer = ( new ThrottledDelayer(200));
|
|
370
|
+
const validate = async () => {
|
|
371
|
+
const position = this.inputEditor.getSelection()?.getStartPosition();
|
|
372
|
+
const offset = position && textModel.getOffsetAt(position);
|
|
373
|
+
const value = textModel.getValue();
|
|
374
|
+
this.setValidation(await input.validateInput(value, offset || 0));
|
|
375
|
+
};
|
|
376
|
+
const triggerValidation = () => validationDelayer.trigger(validate);
|
|
377
|
+
this.repositoryDisposables.add(validationDelayer);
|
|
378
|
+
this.repositoryDisposables.add(this.inputEditor.onDidChangeCursorPosition(triggerValidation));
|
|
379
|
+
const opts = this.modelService.getCreationOptions(textModel.getLanguageId(), textModel.uri, textModel.isForSimpleWidget);
|
|
380
|
+
const onEnter = Event.filter(
|
|
381
|
+
this.inputEditor.onKeyDown,
|
|
382
|
+
e => e.keyCode === KeyCode.Enter,
|
|
383
|
+
this.repositoryDisposables
|
|
384
|
+
);
|
|
385
|
+
this.repositoryDisposables.add(
|
|
386
|
+
onEnter(() => textModel.detectIndentation(opts.insertSpaces, opts.tabSize))
|
|
387
|
+
);
|
|
388
|
+
textModel.setValue(input.value);
|
|
389
|
+
this.repositoryDisposables.add(input.onDidChange((
|
|
390
|
+
{
|
|
391
|
+
value,
|
|
392
|
+
reason
|
|
393
|
+
}
|
|
394
|
+
) => {
|
|
395
|
+
const currentValue = textModel.getValue();
|
|
396
|
+
if (value === currentValue) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
textModel.pushStackElement();
|
|
400
|
+
textModel.pushEditOperations(
|
|
401
|
+
null,
|
|
402
|
+
[EditOperation.replaceMove(textModel.getFullModelRange(), value)],
|
|
403
|
+
() => []
|
|
404
|
+
);
|
|
405
|
+
const position = reason === SCMInputChangeReason.HistoryPrevious ? textModel.getFullModelRange().getStartPosition() : textModel.getFullModelRange().getEndPosition();
|
|
406
|
+
this.inputEditor.setPosition(position);
|
|
407
|
+
this.inputEditor.revealPositionInCenterIfOutsideViewport(position);
|
|
408
|
+
}));
|
|
409
|
+
this.repositoryDisposables.add(input.onDidChangeFocus(() => this.focus()));
|
|
410
|
+
this.repositoryDisposables.add(input.onDidChangeValidationMessage(e => this.setValidation(e, {
|
|
411
|
+
focus: true,
|
|
412
|
+
timeout: true
|
|
413
|
+
})));
|
|
414
|
+
this.repositoryDisposables.add(input.onDidChangeValidateInput(e => triggerValidation()));
|
|
415
|
+
this.repositoryDisposables.add(input.onDidClearValidation(() => this.clearValidation()));
|
|
416
|
+
this.repositoryDisposables.add(textModel.onDidChangeContent(() => {
|
|
417
|
+
input.setValue(textModel.getValue(), true);
|
|
418
|
+
triggerValidation();
|
|
419
|
+
}));
|
|
420
|
+
const accessibilityVerbosityConfig = observableConfigValue(
|
|
421
|
+
AccessibilityVerbositySettingId.SourceControl,
|
|
422
|
+
true,
|
|
423
|
+
this.configurationService
|
|
424
|
+
);
|
|
425
|
+
const getAriaLabel = (placeholder, verbosity) => {
|
|
426
|
+
verbosity = verbosity ?? accessibilityVerbosityConfig.get();
|
|
427
|
+
if (!verbosity || !this.accessibilityService.isScreenReaderOptimized()) {
|
|
428
|
+
return placeholder;
|
|
429
|
+
}
|
|
430
|
+
const kbLabel = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
|
|
431
|
+
return kbLabel ? ( localize(
|
|
432
|
+
12072,
|
|
433
|
+
"{0}, Use {1} to open Source Control Accessibility Help.",
|
|
434
|
+
placeholder,
|
|
435
|
+
kbLabel
|
|
436
|
+
)) : ( localize(
|
|
437
|
+
12073,
|
|
438
|
+
"{0}, Run the Open Accessibility Help command for more information.",
|
|
439
|
+
placeholder
|
|
440
|
+
));
|
|
441
|
+
};
|
|
442
|
+
const getPlaceholderText = () => {
|
|
443
|
+
const binding = this.keybindingService.lookupKeybinding("scm.acceptInput");
|
|
444
|
+
const label = binding ? binding.getLabel() : (isMacintosh ? "Cmd+Enter" : "Ctrl+Enter");
|
|
445
|
+
return format(input.placeholder, label);
|
|
446
|
+
};
|
|
447
|
+
const updatePlaceholderText = () => {
|
|
448
|
+
const placeholder = getPlaceholderText();
|
|
449
|
+
const ariaLabel = getAriaLabel(placeholder);
|
|
450
|
+
this.inputEditor.updateOptions({
|
|
451
|
+
ariaLabel,
|
|
452
|
+
placeholder
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
this.repositoryDisposables.add(input.onDidChangePlaceholder(updatePlaceholderText));
|
|
456
|
+
this.repositoryDisposables.add(this.keybindingService.onDidUpdateKeybindings(updatePlaceholderText));
|
|
457
|
+
this.repositoryDisposables.add(runOnChange(accessibilityVerbosityConfig, verbosity => {
|
|
458
|
+
const placeholder = getPlaceholderText();
|
|
459
|
+
const ariaLabel = getAriaLabel(placeholder, verbosity);
|
|
460
|
+
this.inputEditor.updateOptions({
|
|
461
|
+
ariaLabel
|
|
462
|
+
});
|
|
463
|
+
}));
|
|
464
|
+
updatePlaceholderText();
|
|
465
|
+
let commitTemplate = "";
|
|
466
|
+
this.repositoryDisposables.add(autorun(reader => {
|
|
467
|
+
if (!input.visible) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const oldCommitTemplate = commitTemplate;
|
|
471
|
+
commitTemplate = input.repository.provider.commitTemplate.read(reader);
|
|
472
|
+
const value = textModel.getValue();
|
|
473
|
+
if (value && value !== oldCommitTemplate) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
textModel.setValue(commitTemplate);
|
|
477
|
+
}));
|
|
478
|
+
const updateEnablement = enabled => {
|
|
479
|
+
this.inputEditor.updateOptions({
|
|
480
|
+
readOnly: !enabled
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
this.repositoryDisposables.add(input.onDidChangeEnablement(enabled => updateEnablement(enabled)));
|
|
484
|
+
updateEnablement(input.enabled);
|
|
485
|
+
this.toolbar.setInput(input);
|
|
486
|
+
this.model = {
|
|
487
|
+
input,
|
|
488
|
+
textModel
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
get selections() {
|
|
492
|
+
return this.inputEditor.getSelections();
|
|
493
|
+
}
|
|
494
|
+
set selections(selections) {
|
|
495
|
+
if (selections) {
|
|
496
|
+
this.inputEditor.setSelections(selections);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
setValidation(validation, options) {
|
|
500
|
+
if (this._validationTimer) {
|
|
501
|
+
clearTimeout(this._validationTimer);
|
|
502
|
+
this._validationTimer = undefined;
|
|
503
|
+
}
|
|
504
|
+
this.validation = validation;
|
|
505
|
+
this.renderValidation();
|
|
506
|
+
if (options?.focus && !this.hasFocus()) {
|
|
507
|
+
this.focus();
|
|
508
|
+
}
|
|
509
|
+
if (validation && options?.timeout) {
|
|
510
|
+
this._validationTimer = setTimeout(
|
|
511
|
+
() => this.setValidation(undefined),
|
|
512
|
+
SCMInputWidget_1.ValidationTimeouts[validation.type]
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
constructor(
|
|
517
|
+
container,
|
|
518
|
+
overflowWidgetsDomNode,
|
|
519
|
+
contextKeyService,
|
|
520
|
+
instantiationService,
|
|
521
|
+
modelService,
|
|
522
|
+
keybindingService,
|
|
523
|
+
configurationService,
|
|
524
|
+
scmViewService,
|
|
525
|
+
contextViewService,
|
|
526
|
+
openerService,
|
|
527
|
+
accessibilityService,
|
|
528
|
+
markdownRendererService
|
|
529
|
+
) {
|
|
530
|
+
this.modelService = modelService;
|
|
531
|
+
this.keybindingService = keybindingService;
|
|
532
|
+
this.configurationService = configurationService;
|
|
533
|
+
this.scmViewService = scmViewService;
|
|
534
|
+
this.contextViewService = contextViewService;
|
|
535
|
+
this.openerService = openerService;
|
|
536
|
+
this.accessibilityService = accessibilityService;
|
|
537
|
+
this.markdownRendererService = markdownRendererService;
|
|
538
|
+
this.disposables = ( new DisposableStore());
|
|
539
|
+
this.repositoryDisposables = ( new DisposableStore());
|
|
540
|
+
this.validationHasFocus = false;
|
|
541
|
+
this.lastLayoutWasTrash = false;
|
|
542
|
+
this.shouldFocusAfterLayout = false;
|
|
543
|
+
this.element = append(container, $(".scm-editor"));
|
|
544
|
+
this.editorContainer = append(this.element, $(".scm-editor-container"));
|
|
545
|
+
this.toolbarContainer = append(this.element, $(".scm-editor-toolbar"));
|
|
546
|
+
this.contextKeyService = this.disposables.add(contextKeyService.createScoped(this.element));
|
|
547
|
+
this.repositoryIdContextKey = this.contextKeyService.createKey("scmRepository", undefined);
|
|
548
|
+
this.validationMessageContextKey = SCMInputContextKeys.SCMInputHasValidationMessage.bindTo(this.contextKeyService);
|
|
549
|
+
this.inputEditorOptions = ( new SCMInputWidgetEditorOptions(overflowWidgetsDomNode, this.configurationService));
|
|
550
|
+
this.disposables.add(this.inputEditorOptions.onDidChange(this.onDidChangeEditorOptions, this));
|
|
551
|
+
this.disposables.add(this.inputEditorOptions);
|
|
552
|
+
const codeEditorWidgetOptions = {
|
|
553
|
+
contributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
|
554
|
+
CodeActionController.ID,
|
|
555
|
+
ColorDetector.ID,
|
|
556
|
+
ContextMenuController.ID,
|
|
557
|
+
CopyPasteController.ID,
|
|
558
|
+
DragAndDropController.ID,
|
|
559
|
+
DropIntoEditorController.ID,
|
|
560
|
+
EditorDictation.ID,
|
|
561
|
+
FormatOnType.ID,
|
|
562
|
+
ContentHoverController.ID,
|
|
563
|
+
GlyphHoverController.ID,
|
|
564
|
+
InlineCompletionsController.ID,
|
|
565
|
+
LinkDetector.ID,
|
|
566
|
+
MenuPreventer.ID,
|
|
567
|
+
MessageController.ID,
|
|
568
|
+
PlaceholderTextContribution.ID,
|
|
569
|
+
SelectionClipboardContributionID,
|
|
570
|
+
SnippetController2.ID,
|
|
571
|
+
SuggestController.ID
|
|
572
|
+
]),
|
|
573
|
+
isSimpleWidget: true
|
|
574
|
+
};
|
|
575
|
+
const services = ( new ServiceCollection([IContextKeyService, this.contextKeyService]));
|
|
576
|
+
const instantiationService2 = instantiationService.createChild(services, this.disposables);
|
|
577
|
+
const editorConstructionOptions = this.inputEditorOptions.getEditorConstructionOptions();
|
|
578
|
+
this.inputEditor = instantiationService2.createInstance(
|
|
579
|
+
CodeEditorWidget,
|
|
580
|
+
this.editorContainer,
|
|
581
|
+
editorConstructionOptions,
|
|
582
|
+
codeEditorWidgetOptions
|
|
583
|
+
);
|
|
584
|
+
this.disposables.add(this.inputEditor);
|
|
585
|
+
this.disposables.add(this.inputEditor.onDidFocusEditorText(() => {
|
|
586
|
+
if (this.input?.repository) {
|
|
587
|
+
this.scmViewService.focus(this.input.repository);
|
|
588
|
+
}
|
|
589
|
+
this.element.classList.add("synthetic-focus");
|
|
590
|
+
this.renderValidation();
|
|
591
|
+
}));
|
|
592
|
+
this.disposables.add(this.inputEditor.onDidBlurEditorText(() => {
|
|
593
|
+
this.element.classList.remove("synthetic-focus");
|
|
594
|
+
setTimeout(() => {
|
|
595
|
+
if (!this.validation || !this.validationHasFocus) {
|
|
596
|
+
this.clearValidation();
|
|
597
|
+
}
|
|
598
|
+
}, 0);
|
|
599
|
+
}));
|
|
600
|
+
this.disposables.add(this.inputEditor.onDidBlurEditorWidget(() => {
|
|
601
|
+
CopyPasteController.get(this.inputEditor)?.clearWidgets();
|
|
602
|
+
DropIntoEditorController.get(this.inputEditor)?.clearWidgets();
|
|
603
|
+
}));
|
|
604
|
+
const firstLineKey = this.contextKeyService.createKey("scmInputIsInFirstPosition", false);
|
|
605
|
+
const lastLineKey = this.contextKeyService.createKey("scmInputIsInLastPosition", false);
|
|
606
|
+
this.disposables.add(this.inputEditor.onDidChangeCursorPosition((
|
|
607
|
+
{
|
|
608
|
+
position
|
|
609
|
+
}
|
|
610
|
+
) => {
|
|
611
|
+
const viewModel = this.inputEditor._getViewModel();
|
|
612
|
+
const lastLineNumber = viewModel.getLineCount();
|
|
613
|
+
const lastLineCol = viewModel.getLineLength(lastLineNumber) + 1;
|
|
614
|
+
const viewPosition = viewModel.coordinatesConverter.convertModelPositionToViewPosition(position);
|
|
615
|
+
firstLineKey.set(viewPosition.lineNumber === 1 && viewPosition.column === 1);
|
|
616
|
+
lastLineKey.set(
|
|
617
|
+
viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol
|
|
618
|
+
);
|
|
619
|
+
}));
|
|
620
|
+
this.disposables.add(this.inputEditor.onDidScrollChange(e => {
|
|
621
|
+
this.toolbarContainer.classList.toggle("scroll-decoration", e.scrollTop > 0);
|
|
622
|
+
}));
|
|
623
|
+
Event.filter(
|
|
624
|
+
this.configurationService.onDidChangeConfiguration,
|
|
625
|
+
e => e.affectsConfiguration("scm.showInputActionButton")
|
|
626
|
+
)(() => this.layout(), this, this.disposables);
|
|
627
|
+
this.onDidChangeContentHeight = Event.signal(Event.filter(
|
|
628
|
+
this.inputEditor.onDidContentSizeChange,
|
|
629
|
+
e => e.contentHeightChanged,
|
|
630
|
+
this.disposables
|
|
631
|
+
));
|
|
632
|
+
this.toolbar = instantiationService2.createInstance(SCMInputWidgetToolbar, this.toolbarContainer, {
|
|
633
|
+
actionViewItemProvider: (action, options) => {
|
|
634
|
+
if (action instanceof MenuItemAction && this.toolbar.dropdownActions.length > 1) {
|
|
635
|
+
return instantiationService.createInstance(
|
|
636
|
+
DropdownWithPrimaryActionViewItem,
|
|
637
|
+
action,
|
|
638
|
+
this.toolbar.dropdownAction,
|
|
639
|
+
this.toolbar.dropdownActions,
|
|
640
|
+
"",
|
|
641
|
+
{
|
|
642
|
+
actionRunner: this.toolbar.actionRunner,
|
|
643
|
+
hoverDelegate: options.hoverDelegate
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
return createActionViewItem(instantiationService, action, options);
|
|
648
|
+
},
|
|
649
|
+
hiddenItemStrategy: HiddenItemStrategy.NoHide,
|
|
650
|
+
menuOptions: {
|
|
651
|
+
shouldForwardArgs: true
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
this.disposables.add(this.toolbar.onDidChange(() => this.layout()));
|
|
655
|
+
this.disposables.add(this.toolbar);
|
|
656
|
+
}
|
|
657
|
+
getContentHeight() {
|
|
658
|
+
const lineHeight = this.inputEditor.getOption(EditorOption.lineHeight);
|
|
659
|
+
const {
|
|
660
|
+
top,
|
|
661
|
+
bottom
|
|
662
|
+
} = this.inputEditor.getOption(EditorOption.padding);
|
|
663
|
+
const inputMinLinesConfig = this.configurationService.getValue("scm.inputMinLineCount");
|
|
664
|
+
const inputMinLines = typeof inputMinLinesConfig === "number" ? clamp(inputMinLinesConfig, 1, 50) : 1;
|
|
665
|
+
const editorMinHeight = inputMinLines * lineHeight + top + bottom;
|
|
666
|
+
const inputMaxLinesConfig = this.configurationService.getValue("scm.inputMaxLineCount");
|
|
667
|
+
const inputMaxLines = typeof inputMaxLinesConfig === "number" ? clamp(inputMaxLinesConfig, 1, 50) : 10;
|
|
668
|
+
const editorMaxHeight = inputMaxLines * lineHeight + top + bottom;
|
|
669
|
+
return clamp(this.inputEditor.getContentHeight(), editorMinHeight, editorMaxHeight);
|
|
670
|
+
}
|
|
671
|
+
layout() {
|
|
672
|
+
const editorHeight = this.getContentHeight();
|
|
673
|
+
const toolbarWidth = this.getToolbarWidth();
|
|
674
|
+
const dimension = ( new Dimension(this.element.clientWidth - toolbarWidth, editorHeight));
|
|
675
|
+
if (dimension.width < 0) {
|
|
676
|
+
this.lastLayoutWasTrash = true;
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
this.lastLayoutWasTrash = false;
|
|
680
|
+
this.inputEditor.layout(dimension);
|
|
681
|
+
this.renderValidation();
|
|
682
|
+
const showInputActionButton = this.configurationService.getValue("scm.showInputActionButton") === true;
|
|
683
|
+
this.toolbarContainer.classList.toggle("hidden", !showInputActionButton || this.toolbar?.isEmpty() === true);
|
|
684
|
+
if (this.shouldFocusAfterLayout) {
|
|
685
|
+
this.shouldFocusAfterLayout = false;
|
|
686
|
+
this.focus();
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
focus() {
|
|
690
|
+
if (this.lastLayoutWasTrash) {
|
|
691
|
+
this.lastLayoutWasTrash = false;
|
|
692
|
+
this.shouldFocusAfterLayout = true;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
this.inputEditor.focus();
|
|
696
|
+
this.element.classList.add("synthetic-focus");
|
|
697
|
+
}
|
|
698
|
+
hasFocus() {
|
|
699
|
+
return this.inputEditor.hasTextFocus();
|
|
700
|
+
}
|
|
701
|
+
onDidChangeEditorOptions() {
|
|
702
|
+
this.inputEditor.updateOptions(this.inputEditorOptions.getEditorOptions());
|
|
703
|
+
}
|
|
704
|
+
renderValidation() {
|
|
705
|
+
this.clearValidation();
|
|
706
|
+
this.element.classList.toggle(
|
|
707
|
+
"validation-info",
|
|
708
|
+
this.validation?.type === InputValidationType.Information
|
|
709
|
+
);
|
|
710
|
+
this.element.classList.toggle(
|
|
711
|
+
"validation-warning",
|
|
712
|
+
this.validation?.type === InputValidationType.Warning
|
|
713
|
+
);
|
|
714
|
+
this.element.classList.toggle("validation-error", this.validation?.type === InputValidationType.Error);
|
|
715
|
+
if (!this.validation || !this.inputEditor.hasTextFocus()) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
this.validationMessageContextKey.set(true);
|
|
719
|
+
const disposables = ( new DisposableStore());
|
|
720
|
+
this.validationContextView = this.contextViewService.showContextView({
|
|
721
|
+
getAnchor: () => this.element,
|
|
722
|
+
render: container => {
|
|
723
|
+
this.element.style.borderBottomLeftRadius = "0";
|
|
724
|
+
this.element.style.borderBottomRightRadius = "0";
|
|
725
|
+
const validationContainer = append(container, $(".scm-editor-validation-container"));
|
|
726
|
+
validationContainer.classList.toggle(
|
|
727
|
+
"validation-info",
|
|
728
|
+
this.validation.type === InputValidationType.Information
|
|
729
|
+
);
|
|
730
|
+
validationContainer.classList.toggle("validation-warning", this.validation.type === InputValidationType.Warning);
|
|
731
|
+
validationContainer.classList.toggle("validation-error", this.validation.type === InputValidationType.Error);
|
|
732
|
+
validationContainer.style.width = `${this.element.clientWidth + 2}px`;
|
|
733
|
+
const element = append(validationContainer, $(".scm-editor-validation"));
|
|
734
|
+
const message = this.validation.message;
|
|
735
|
+
if (typeof message === "string") {
|
|
736
|
+
element.textContent = message;
|
|
737
|
+
} else {
|
|
738
|
+
const tracker = trackFocus(element);
|
|
739
|
+
disposables.add(tracker);
|
|
740
|
+
disposables.add(tracker.onDidFocus(() => (this.validationHasFocus = true)));
|
|
741
|
+
disposables.add(tracker.onDidBlur(() => {
|
|
742
|
+
this.validationHasFocus = false;
|
|
743
|
+
this.element.style.borderBottomLeftRadius = "2px";
|
|
744
|
+
this.element.style.borderBottomRightRadius = "2px";
|
|
745
|
+
this.contextViewService.hideContextView();
|
|
746
|
+
}));
|
|
747
|
+
const renderedMarkdown = this.markdownRendererService.render(message, {
|
|
748
|
+
actionHandler: (link, mdStr) => {
|
|
749
|
+
openLinkFromMarkdown(this.openerService, link, mdStr.isTrusted);
|
|
750
|
+
this.element.style.borderBottomLeftRadius = "2px";
|
|
751
|
+
this.element.style.borderBottomRightRadius = "2px";
|
|
752
|
+
this.contextViewService.hideContextView();
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
disposables.add(renderedMarkdown);
|
|
756
|
+
element.appendChild(renderedMarkdown.element);
|
|
757
|
+
}
|
|
758
|
+
const actionsContainer = append(validationContainer, $(".scm-editor-validation-actions"));
|
|
759
|
+
const actionbar = ( new ActionBar(actionsContainer));
|
|
760
|
+
const action = ( new Action("scmInputWidget.validationMessage.close", ( localize(12074, "Close")), ThemeIcon.asClassName(Codicon.close), true, () => {
|
|
761
|
+
this.contextViewService.hideContextView();
|
|
762
|
+
this.element.style.borderBottomLeftRadius = "2px";
|
|
763
|
+
this.element.style.borderBottomRightRadius = "2px";
|
|
764
|
+
}));
|
|
765
|
+
disposables.add(actionbar);
|
|
766
|
+
actionbar.push(action, {
|
|
767
|
+
icon: true,
|
|
768
|
+
label: false
|
|
769
|
+
});
|
|
770
|
+
return Disposable.None;
|
|
771
|
+
},
|
|
772
|
+
onHide: () => {
|
|
773
|
+
this.validationHasFocus = false;
|
|
774
|
+
this.element.style.borderBottomLeftRadius = "2px";
|
|
775
|
+
this.element.style.borderBottomRightRadius = "2px";
|
|
776
|
+
disposables.dispose();
|
|
777
|
+
},
|
|
778
|
+
anchorAlignment: AnchorAlignment.LEFT
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
getToolbarWidth() {
|
|
782
|
+
const showInputActionButton = this.configurationService.getValue("scm.showInputActionButton");
|
|
783
|
+
if (!this.toolbar || !showInputActionButton || this.toolbar?.isEmpty() === true) {
|
|
784
|
+
return 0;
|
|
785
|
+
}
|
|
786
|
+
return this.toolbar.dropdownActions.length === 0 ? 26 : 39 ;
|
|
787
|
+
}
|
|
788
|
+
clearValidation() {
|
|
789
|
+
this.validationContextView?.close();
|
|
790
|
+
this.validationContextView = undefined;
|
|
791
|
+
this.validationHasFocus = false;
|
|
792
|
+
this.validationMessageContextKey.set(false);
|
|
793
|
+
}
|
|
794
|
+
dispose() {
|
|
795
|
+
this.input = undefined;
|
|
796
|
+
this.repositoryDisposables.dispose();
|
|
797
|
+
this.clearValidation();
|
|
798
|
+
this.disposables.dispose();
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
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));
|
|
802
|
+
registerAction2(class extends Action2 {
|
|
803
|
+
constructor() {
|
|
804
|
+
super({
|
|
805
|
+
id: SCMInputWidgetCommandId.SetupAction,
|
|
806
|
+
title: ( localize(12075, "Generate Commit Message")),
|
|
807
|
+
icon: Codicon.sparkle,
|
|
808
|
+
f1: false,
|
|
809
|
+
menu: {
|
|
810
|
+
id: MenuId.SCMInputBox,
|
|
811
|
+
when: ( ContextKeyExpr.and(( ChatContextKeys.Setup.hidden.negate()), ( ChatContextKeys.Setup.disabled.negate()), ( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.equals("scmProvider", "git"))))
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
async run(accessor, ...args) {
|
|
816
|
+
const commandService = accessor.get(ICommandService);
|
|
817
|
+
const result = await commandService.executeCommand(CHAT_SETUP_SUPPORT_ANONYMOUS_ACTION_ID);
|
|
818
|
+
if (!result) {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
const command = product.defaultChatAgent?.generateCommitMessageCommand;
|
|
822
|
+
if (!command) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
await commandService.executeCommand(command, ...args);
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
setupSimpleEditorSelectionStyling(".scm-view .scm-editor-container");
|
|
829
|
+
|
|
830
|
+
export { SCMInputContextKeys, SCMInputWidget };
|