@codingame/monaco-vscode-ac93482b-2178-52df-a200-ba0d1a4963fb-common 20.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.
Files changed (22) hide show
  1. package/empty.js +1 -0
  2. package/package.json +50 -0
  3. package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.d.ts +23 -0
  4. package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.js +58 -0
  5. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution._autosave.d.ts +1 -0
  6. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution._autosave.js +5 -0
  7. package/vscode/src/vs/workbench/browser/parts/editor/editorAutoSave.d.ts +42 -0
  8. package/vscode/src/vs/workbench/browser/parts/editor/editorAutoSave.js +222 -0
  9. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.d.ts +32 -0
  10. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +398 -0
  11. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.d.ts +8 -0
  12. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +700 -0
  13. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.d.ts +4 -0
  14. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +474 -0
  15. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._fileEditorFactory.d.ts +1 -0
  16. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._fileEditorFactory.js +15 -0
  17. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.d.ts +1 -0
  18. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +72 -0
  19. package/vscode/src/vs/workbench/services/textfile/common/textEditorService.d.ts +32 -0
  20. package/vscode/src/vs/workbench/services/textfile/common/textEditorService.js +194 -0
  21. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorInput.d.ts +45 -0
  22. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorInput.js +159 -0
@@ -0,0 +1,398 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
4
+ import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
5
+ import { isEqual, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
6
+ import { Action } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
7
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
8
+ import { FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
9
+ import { ITextFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service';
10
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
11
+ import { Disposable, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
12
+ import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
13
+ import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
14
+ import { DiffEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/diffEditorInput';
15
+ import { RawContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
16
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
17
+ import { TextFileContentProvider } from '@codingame/monaco-vscode-f24e325c-2ce0-5bba-8236-bfc4f53180ab-common/vscode/vs/workbench/contrib/files/common/files';
18
+ import { FileEditorInput } from '@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common/vscode/vs/workbench/contrib/files/browser/editors/fileEditorInput';
19
+ import { SAVE_FILE_AS_LABEL } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/files/browser/fileConstants';
20
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
21
+ import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
22
+ import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
23
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
24
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
25
+ import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
26
+ import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
27
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
28
+ import { isWindows } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
29
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
30
+ import { IPreferencesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/preferences/common/preferences.service';
31
+ import { SaveReason, SideBySideEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
32
+ import { hash } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
33
+ import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
34
+
35
+ const CONFLICT_RESOLUTION_CONTEXT = 'saveConflictResolutionContext';
36
+ const CONFLICT_RESOLUTION_SCHEME = 'conflictResolution';
37
+ const LEARN_MORE_DIRTY_WRITE_IGNORE_KEY = 'learnMoreDirtyWriteError';
38
+ const conflictEditorHelp = ( localize(
39
+ 7243,
40
+ "Use the actions in the editor tool bar to either undo your changes or overwrite the content of the file with your changes."
41
+ ));
42
+ let TextFileSaveErrorHandler = class TextFileSaveErrorHandler extends Disposable {
43
+ static { this.ID = 'workbench.contrib.textFileSaveErrorHandler'; }
44
+ constructor(notificationService, textFileService, contextKeyService, editorService, textModelService, instantiationService, storageService) {
45
+ super();
46
+ this.notificationService = notificationService;
47
+ this.textFileService = textFileService;
48
+ this.editorService = editorService;
49
+ this.instantiationService = instantiationService;
50
+ this.storageService = storageService;
51
+ this.messages = ( new ResourceMap());
52
+ this.activeConflictResolutionResource = undefined;
53
+ this.conflictResolutionContext = ( new RawContextKey(CONFLICT_RESOLUTION_CONTEXT, false, true)).bindTo(contextKeyService);
54
+ const provider = this._register(instantiationService.createInstance(TextFileContentProvider));
55
+ this._register(textModelService.registerTextModelContentProvider(CONFLICT_RESOLUTION_SCHEME, provider));
56
+ this.textFileService.files.saveErrorHandler = this;
57
+ this.registerListeners();
58
+ }
59
+ registerListeners() {
60
+ this._register(this.textFileService.files.onDidSave(e => this.onFileSavedOrReverted(e.model.resource)));
61
+ this._register(this.textFileService.files.onDidRevert(model => this.onFileSavedOrReverted(model.resource)));
62
+ this._register(this.editorService.onDidActiveEditorChange(() => this.onActiveEditorChanged()));
63
+ }
64
+ onActiveEditorChanged() {
65
+ let isActiveEditorSaveConflictResolution = false;
66
+ let activeConflictResolutionResource;
67
+ const activeInput = this.editorService.activeEditor;
68
+ if (activeInput instanceof DiffEditorInput) {
69
+ const resource = activeInput.original.resource;
70
+ if (resource?.scheme === CONFLICT_RESOLUTION_SCHEME) {
71
+ isActiveEditorSaveConflictResolution = true;
72
+ activeConflictResolutionResource = activeInput.modified.resource;
73
+ }
74
+ }
75
+ this.conflictResolutionContext.set(isActiveEditorSaveConflictResolution);
76
+ this.activeConflictResolutionResource = activeConflictResolutionResource;
77
+ }
78
+ onFileSavedOrReverted(resource) {
79
+ const messageHandle = this.messages.get(resource);
80
+ if (messageHandle) {
81
+ messageHandle.close();
82
+ this.messages.delete(resource);
83
+ }
84
+ }
85
+ onSaveError(error, model, options) {
86
+ const fileOperationError = error;
87
+ const resource = model.resource;
88
+ let message;
89
+ const primaryActions = [];
90
+ const secondaryActions = [];
91
+ if (fileOperationError.fileOperationResult === FileOperationResult.FILE_MODIFIED_SINCE) {
92
+ if (this.activeConflictResolutionResource && isEqual(this.activeConflictResolutionResource, model.resource)) {
93
+ if (this.storageService.getBoolean(LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, StorageScope.APPLICATION)) {
94
+ return;
95
+ }
96
+ message = conflictEditorHelp;
97
+ primaryActions.push(this.instantiationService.createInstance(ResolveConflictLearnMoreAction));
98
+ secondaryActions.push(this.instantiationService.createInstance(DoNotShowResolveConflictLearnMoreAction));
99
+ }
100
+ else {
101
+ message = ( localize(
102
+ 7244,
103
+ "Failed to save '{0}': The content of the file is newer. Please compare your version with the file contents or overwrite the content of the file with your changes.",
104
+ basename(resource)
105
+ ));
106
+ primaryActions.push(this.instantiationService.createInstance(ResolveSaveConflictAction, model));
107
+ primaryActions.push(this.instantiationService.createInstance(SaveModelIgnoreModifiedSinceAction, model, options));
108
+ secondaryActions.push(this.instantiationService.createInstance(ConfigureSaveConflictAction));
109
+ }
110
+ }
111
+ else {
112
+ const isWriteLocked = fileOperationError.fileOperationResult === FileOperationResult.FILE_WRITE_LOCKED;
113
+ const triedToUnlock = isWriteLocked && fileOperationError.options?.unlock;
114
+ const isPermissionDenied = fileOperationError.fileOperationResult === FileOperationResult.FILE_PERMISSION_DENIED;
115
+ const canSaveElevated = resource.scheme === Schemas.file;
116
+ if (canSaveElevated && (isPermissionDenied || triedToUnlock)) {
117
+ primaryActions.push(this.instantiationService.createInstance(SaveModelElevatedAction, model, options, !!triedToUnlock));
118
+ }
119
+ else if (isWriteLocked) {
120
+ primaryActions.push(this.instantiationService.createInstance(UnlockModelAction, model, options));
121
+ }
122
+ else {
123
+ primaryActions.push(this.instantiationService.createInstance(RetrySaveModelAction, model, options));
124
+ }
125
+ primaryActions.push(this.instantiationService.createInstance(SaveModelAsAction, model));
126
+ primaryActions.push(this.instantiationService.createInstance(RevertModelAction, model));
127
+ if (isWriteLocked) {
128
+ if (triedToUnlock && canSaveElevated) {
129
+ message = isWindows ? ( localize(
130
+ 7245,
131
+ "Failed to save '{0}': File is read-only. Select 'Overwrite as Admin' to retry as administrator.",
132
+ basename(resource)
133
+ )) : ( localize(
134
+ 7246,
135
+ "Failed to save '{0}': File is read-only. Select 'Overwrite as Sudo' to retry as superuser.",
136
+ basename(resource)
137
+ ));
138
+ }
139
+ else {
140
+ message = ( localize(
141
+ 7247,
142
+ "Failed to save '{0}': File is read-only. Select 'Overwrite' to attempt to make it writeable.",
143
+ basename(resource)
144
+ ));
145
+ }
146
+ }
147
+ else if (canSaveElevated && isPermissionDenied) {
148
+ message = isWindows ? ( localize(
149
+ 7248,
150
+ "Failed to save '{0}': Insufficient permissions. Select 'Retry as Admin' to retry as administrator.",
151
+ basename(resource)
152
+ )) : ( localize(
153
+ 7249,
154
+ "Failed to save '{0}': Insufficient permissions. Select 'Retry as Sudo' to retry as superuser.",
155
+ basename(resource)
156
+ ));
157
+ }
158
+ else {
159
+ message = ( localize(
160
+ 7250,
161
+ "Failed to save '{0}': {1}",
162
+ basename(resource),
163
+ toErrorMessage(error, false)
164
+ ));
165
+ }
166
+ }
167
+ const actions = { primary: primaryActions, secondary: secondaryActions };
168
+ const handle = this.notificationService.notify({
169
+ id: `${hash(( model.resource.toString()))}`,
170
+ severity: Severity.Error,
171
+ message,
172
+ actions
173
+ });
174
+ Event.once(handle.onDidClose)(() => { dispose(primaryActions); dispose(secondaryActions); });
175
+ this.messages.set(model.resource, handle);
176
+ }
177
+ dispose() {
178
+ super.dispose();
179
+ this.messages.clear();
180
+ }
181
+ };
182
+ TextFileSaveErrorHandler = ( __decorate([
183
+ ( __param(0, INotificationService)),
184
+ ( __param(1, ITextFileService)),
185
+ ( __param(2, IContextKeyService)),
186
+ ( __param(3, IEditorService)),
187
+ ( __param(4, ITextModelService)),
188
+ ( __param(5, IInstantiationService)),
189
+ ( __param(6, IStorageService))
190
+ ], TextFileSaveErrorHandler));
191
+ const pendingResolveSaveConflictMessages = [];
192
+ function clearPendingResolveSaveConflictMessages() {
193
+ while (pendingResolveSaveConflictMessages.length > 0) {
194
+ const item = pendingResolveSaveConflictMessages.pop();
195
+ item?.close();
196
+ }
197
+ }
198
+ let ResolveConflictLearnMoreAction = class ResolveConflictLearnMoreAction extends Action {
199
+ constructor(openerService) {
200
+ super('workbench.files.action.resolveConflictLearnMore', ( localize(7251, "Learn More")));
201
+ this.openerService = openerService;
202
+ }
203
+ async run() {
204
+ await this.openerService.open(( URI.parse('https://go.microsoft.com/fwlink/?linkid=868264')));
205
+ }
206
+ };
207
+ ResolveConflictLearnMoreAction = ( __decorate([
208
+ ( __param(0, IOpenerService))
209
+ ], ResolveConflictLearnMoreAction));
210
+ let DoNotShowResolveConflictLearnMoreAction = class DoNotShowResolveConflictLearnMoreAction extends Action {
211
+ constructor(storageService) {
212
+ super('workbench.files.action.resolveConflictLearnMoreDoNotShowAgain', ( localize(7252, "Don't Show Again")));
213
+ this.storageService = storageService;
214
+ }
215
+ async run(notification) {
216
+ this.storageService.store(LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
217
+ notification.dispose();
218
+ }
219
+ };
220
+ DoNotShowResolveConflictLearnMoreAction = ( __decorate([
221
+ ( __param(0, IStorageService))
222
+ ], DoNotShowResolveConflictLearnMoreAction));
223
+ let ResolveSaveConflictAction = class ResolveSaveConflictAction extends Action {
224
+ constructor(model, editorService, notificationService, instantiationService, productService) {
225
+ super('workbench.files.action.resolveConflict', ( localize(7253, "Compare")));
226
+ this.model = model;
227
+ this.editorService = editorService;
228
+ this.notificationService = notificationService;
229
+ this.instantiationService = instantiationService;
230
+ this.productService = productService;
231
+ }
232
+ async run() {
233
+ if (!this.model.isDisposed()) {
234
+ const resource = this.model.resource;
235
+ const name = basename(resource);
236
+ const editorLabel = ( localize(
237
+ 7254,
238
+ "{0} (in file) ↔ {1} (in {2}) - Resolve save conflict",
239
+ name,
240
+ name,
241
+ this.productService.nameLong
242
+ ));
243
+ await TextFileContentProvider.open(resource, CONFLICT_RESOLUTION_SCHEME, editorLabel, this.editorService, { pinned: true });
244
+ const actions = { primary: [this.instantiationService.createInstance(ResolveConflictLearnMoreAction)] };
245
+ const handle = this.notificationService.notify({
246
+ id: `${hash(( resource.toString()))}`,
247
+ severity: Severity.Info,
248
+ message: conflictEditorHelp,
249
+ actions,
250
+ neverShowAgain: { id: LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, isSecondary: true }
251
+ });
252
+ Event.once(handle.onDidClose)(() => dispose(actions.primary));
253
+ pendingResolveSaveConflictMessages.push(handle);
254
+ }
255
+ }
256
+ };
257
+ ResolveSaveConflictAction = ( __decorate([
258
+ ( __param(1, IEditorService)),
259
+ ( __param(2, INotificationService)),
260
+ ( __param(3, IInstantiationService)),
261
+ ( __param(4, IProductService))
262
+ ], ResolveSaveConflictAction));
263
+ class SaveModelElevatedAction extends Action {
264
+ constructor(model, options, triedToUnlock) {
265
+ super('workbench.files.action.saveModelElevated', triedToUnlock ? isWindows ? ( localize(7255, "Overwrite as Admin...")) : ( localize(7256, "Overwrite as Sudo...")) : isWindows ? ( localize(7257, "Retry as Admin...")) : ( localize(7258, "Retry as Sudo...")));
266
+ this.model = model;
267
+ this.options = options;
268
+ this.triedToUnlock = triedToUnlock;
269
+ }
270
+ async run() {
271
+ if (!this.model.isDisposed()) {
272
+ await this.model.save({
273
+ ...this.options,
274
+ writeElevated: true,
275
+ writeUnlock: this.triedToUnlock,
276
+ reason: SaveReason.EXPLICIT
277
+ });
278
+ }
279
+ }
280
+ }
281
+ class RetrySaveModelAction extends Action {
282
+ constructor(model, options) {
283
+ super('workbench.files.action.saveModel', ( localize(7259, "Retry")));
284
+ this.model = model;
285
+ this.options = options;
286
+ }
287
+ async run() {
288
+ if (!this.model.isDisposed()) {
289
+ await this.model.save({ ...this.options, reason: SaveReason.EXPLICIT });
290
+ }
291
+ }
292
+ }
293
+ class RevertModelAction extends Action {
294
+ constructor(model) {
295
+ super('workbench.files.action.revertModel', ( localize(7260, "Revert")));
296
+ this.model = model;
297
+ }
298
+ async run() {
299
+ if (!this.model.isDisposed()) {
300
+ await this.model.revert();
301
+ }
302
+ }
303
+ }
304
+ let SaveModelAsAction = class SaveModelAsAction extends Action {
305
+ constructor(model, editorService) {
306
+ super('workbench.files.action.saveModelAs', SAVE_FILE_AS_LABEL.value);
307
+ this.model = model;
308
+ this.editorService = editorService;
309
+ }
310
+ async run() {
311
+ if (!this.model.isDisposed()) {
312
+ const editor = this.findEditor();
313
+ if (editor) {
314
+ await this.editorService.save(editor, { saveAs: true, reason: SaveReason.EXPLICIT });
315
+ }
316
+ }
317
+ }
318
+ findEditor() {
319
+ let preferredMatchingEditor;
320
+ const editors = this.editorService.findEditors(this.model.resource, { supportSideBySide: SideBySideEditor.PRIMARY });
321
+ for (const identifier of editors) {
322
+ if (identifier.editor instanceof FileEditorInput) {
323
+ preferredMatchingEditor = identifier;
324
+ break;
325
+ }
326
+ else if (!preferredMatchingEditor) {
327
+ preferredMatchingEditor = identifier;
328
+ }
329
+ }
330
+ return preferredMatchingEditor;
331
+ }
332
+ };
333
+ SaveModelAsAction = ( __decorate([
334
+ ( __param(1, IEditorService))
335
+ ], SaveModelAsAction));
336
+ class UnlockModelAction extends Action {
337
+ constructor(model, options) {
338
+ super('workbench.files.action.unlock', ( localize(7261, "Overwrite")));
339
+ this.model = model;
340
+ this.options = options;
341
+ }
342
+ async run() {
343
+ if (!this.model.isDisposed()) {
344
+ await this.model.save({ ...this.options, writeUnlock: true, reason: SaveReason.EXPLICIT });
345
+ }
346
+ }
347
+ }
348
+ class SaveModelIgnoreModifiedSinceAction extends Action {
349
+ constructor(model, options) {
350
+ super('workbench.files.action.saveIgnoreModifiedSince', ( localize(7261, "Overwrite")));
351
+ this.model = model;
352
+ this.options = options;
353
+ }
354
+ async run() {
355
+ if (!this.model.isDisposed()) {
356
+ await this.model.save({ ...this.options, ignoreModifiedSince: true, reason: SaveReason.EXPLICIT });
357
+ }
358
+ }
359
+ }
360
+ let ConfigureSaveConflictAction = class ConfigureSaveConflictAction extends Action {
361
+ constructor(preferencesService) {
362
+ super('workbench.files.action.configureSaveConflict', ( localize(7262, "Configure")));
363
+ this.preferencesService = preferencesService;
364
+ }
365
+ async run() {
366
+ this.preferencesService.openSettings({ query: 'files.saveConflictResolution' });
367
+ }
368
+ };
369
+ ConfigureSaveConflictAction = ( __decorate([
370
+ ( __param(0, IPreferencesService))
371
+ ], ConfigureSaveConflictAction));
372
+ const acceptLocalChangesCommand = (accessor, resource) => {
373
+ return acceptOrRevertLocalChangesCommand(accessor, resource, true);
374
+ };
375
+ const revertLocalChangesCommand = (accessor, resource) => {
376
+ return acceptOrRevertLocalChangesCommand(accessor, resource, false);
377
+ };
378
+ async function acceptOrRevertLocalChangesCommand(accessor, resource, accept) {
379
+ const editorService = accessor.get(IEditorService);
380
+ const editorPane = editorService.activeEditorPane;
381
+ if (!editorPane) {
382
+ return;
383
+ }
384
+ const editor = editorPane.input;
385
+ const group = editorPane.group;
386
+ clearPendingResolveSaveConflictMessages();
387
+ if (accept) {
388
+ const options = { ignoreModifiedSince: true, reason: SaveReason.EXPLICIT };
389
+ await editorService.save({ editor, groupId: group.id }, options);
390
+ }
391
+ else {
392
+ await editorService.revert({ editor, groupId: group.id });
393
+ }
394
+ await editorService.openEditor({ resource }, group);
395
+ return group.closeEditor(editor);
396
+ }
397
+
398
+ export { CONFLICT_RESOLUTION_CONTEXT, CONFLICT_RESOLUTION_SCHEME, TextFileSaveErrorHandler, acceptLocalChangesCommand, revertLocalChangesCommand };
@@ -0,0 +1,8 @@
1
+ import { ICommandAction } from "@codingame/monaco-vscode-api/vscode/vs/platform/action/common/action";
2
+ import { ContextKeyExpression } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
3
+ export declare const revealInSideBarCommand: {
4
+ id: string;
5
+ title: string;
6
+ };
7
+ export declare function appendEditorTitleContextMenuItem(id: string, title: string, when: ContextKeyExpression | undefined, group: string, supportsMultiSelect: boolean, order?: number): void;
8
+ export declare function appendToCommandPalette({ id, title, category, metadata }: ICommandAction, when?: ContextKeyExpression): void;