@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
package/empty.js ADDED
@@ -0,0 +1 @@
1
+ export {}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@codingame/monaco-vscode-ac93482b-2178-52df-a200-ba0d1a4963fb-common",
3
+ "version": "20.0.0",
4
+ "private": false,
5
+ "description": "VSCode public API plugged on the monaco editor - common package (chat, editor, explorer, interactive, notebook, output, search, view-common)",
6
+ "keywords": [],
7
+ "author": {
8
+ "name": "CodinGame",
9
+ "url": "http://www.codingame.com"
10
+ },
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
15
+ },
16
+ "type": "module",
17
+ "dependencies": {
18
+ "@codingame/monaco-vscode-615ce609-8555-545a-a549-47bd9f80e9f8-common": "20.0.0",
19
+ "@codingame/monaco-vscode-670aae94-7f88-54d7-90ea-6fcbef423557-common": "20.0.0",
20
+ "@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common": "20.0.0",
21
+ "@codingame/monaco-vscode-api": "20.0.0",
22
+ "@codingame/monaco-vscode-bd0792ac-6043-5ec3-a41a-54ccb922a1f4-common": "20.0.0",
23
+ "@codingame/monaco-vscode-caeb744c-8e3f-5c11-80fb-0f057d24d544-common": "20.0.0",
24
+ "@codingame/monaco-vscode-dbfe5f85-b426-55ed-a79b-5f811b395762-common": "20.0.0",
25
+ "@codingame/monaco-vscode-f24e325c-2ce0-5bba-8236-bfc4f53180ab-common": "20.0.0"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "default": "./empty.js"
30
+ },
31
+ "./vscode/*.css": {
32
+ "default": "./vscode/src/*.css"
33
+ },
34
+ "./vscode/*": {
35
+ "types": "./vscode/src/*.d.ts",
36
+ "default": "./vscode/src/*.js"
37
+ },
38
+ "./*": {
39
+ "types": "./*.d.ts",
40
+ "default": "./*.js"
41
+ }
42
+ },
43
+ "typesVersions": {
44
+ "*": {
45
+ "vscode/*": [
46
+ "./vscode/src/*.d.ts"
47
+ ]
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,23 @@
1
+ import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
2
+ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
3
+ import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
4
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
5
+ import { IEditorOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor";
6
+ import { EditorPlaceholder, IEditorPlaceholderContents } from "@codingame/monaco-vscode-615ce609-8555-545a-a549-47bd9f80e9f8-common/vscode/vs/workbench/browser/parts/editor/editorPlaceholder";
7
+ import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
8
+ export interface IOpenCallbacks {
9
+ openInternal: (input: EditorInput, options: IEditorOptions | undefined) => Promise<void>;
10
+ }
11
+ export declare abstract class BaseBinaryResourceEditor extends EditorPlaceholder {
12
+ private readonly callbacks;
13
+ private readonly _onDidChangeMetadata;
14
+ readonly onDidChangeMetadata: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
15
+ private readonly _onDidOpenInPlace;
16
+ readonly onDidOpenInPlace: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
17
+ private metadata;
18
+ constructor(id: string, group: IEditorGroup, callbacks: IOpenCallbacks, telemetryService: ITelemetryService, themeService: IThemeService, storageService: IStorageService);
19
+ getTitle(): string;
20
+ protected getContents(input: EditorInput, options: IEditorOptions): Promise<IEditorPlaceholderContents>;
21
+ private handleMetadataChanged;
22
+ getMetadata(): string | undefined;
23
+ }
@@ -0,0 +1,58 @@
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 { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
5
+ import { BinaryEditorModel } from '@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common/vscode/vs/workbench/common/editor/binaryEditorModel';
6
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
7
+ import { ByteSize } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
8
+ import { EditorPlaceholder } from '@codingame/monaco-vscode-615ce609-8555-545a-a549-47bd9f80e9f8-common/vscode/vs/workbench/browser/parts/editor/editorPlaceholder';
9
+
10
+ let BaseBinaryResourceEditor = class BaseBinaryResourceEditor extends EditorPlaceholder {
11
+ constructor(id, group, callbacks, telemetryService, themeService, storageService) {
12
+ super(id, group, telemetryService, themeService, storageService);
13
+ this.callbacks = callbacks;
14
+ this._onDidChangeMetadata = this._register(( new Emitter()));
15
+ this.onDidChangeMetadata = this._onDidChangeMetadata.event;
16
+ this._onDidOpenInPlace = this._register(( new Emitter()));
17
+ this.onDidOpenInPlace = this._onDidOpenInPlace.event;
18
+ }
19
+ getTitle() {
20
+ return this.input ? this.input.getName() : ( localize(2963, "Binary Viewer"));
21
+ }
22
+ async getContents(input, options) {
23
+ const model = await input.resolve();
24
+ if (!(model instanceof BinaryEditorModel)) {
25
+ throw ( new Error('Unable to open file as binary'));
26
+ }
27
+ const size = model.getSize();
28
+ this.handleMetadataChanged(typeof size === 'number' ? ByteSize.formatSize(size) : '');
29
+ return {
30
+ icon: '$(warning)',
31
+ label: ( localize(
32
+ 2964,
33
+ "The file is not displayed in the text editor because it is either binary or uses an unsupported text encoding."
34
+ )),
35
+ actions: [
36
+ {
37
+ label: ( localize(2965, "Open Anyway")),
38
+ run: async () => {
39
+ await this.callbacks.openInternal(input, options);
40
+ this._onDidOpenInPlace.fire();
41
+ }
42
+ }
43
+ ]
44
+ };
45
+ }
46
+ handleMetadataChanged(meta) {
47
+ this.metadata = meta;
48
+ this._onDidChangeMetadata.fire();
49
+ }
50
+ getMetadata() {
51
+ return this.metadata;
52
+ }
53
+ };
54
+ BaseBinaryResourceEditor = ( __decorate([
55
+ ( __param(5, IStorageService))
56
+ ], BaseBinaryResourceEditor));
57
+
58
+ export { BaseBinaryResourceEditor };
@@ -0,0 +1,5 @@
1
+
2
+ import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
3
+ import { EditorAutoSave } from './editorAutoSave.js';
4
+
5
+ registerWorkbenchContribution2(EditorAutoSave.ID, EditorAutoSave, WorkbenchPhase.BlockRestore);
@@ -0,0 +1,42 @@
1
+ import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
2
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
+ import { IFilesConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service";
4
+ import { IHostService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service";
5
+ import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
6
+ import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
7
+ import { IWorkingCopyService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service";
8
+ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
9
+ import { IMarkerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service";
10
+ import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
11
+ export declare class EditorAutoSave extends Disposable implements IWorkbenchContribution {
12
+ private readonly filesConfigurationService;
13
+ private readonly hostService;
14
+ private readonly editorService;
15
+ private readonly editorGroupService;
16
+ private readonly workingCopyService;
17
+ private readonly logService;
18
+ private readonly markerService;
19
+ private readonly uriIdentityService;
20
+ static readonly ID = "workbench.contrib.editorAutoSave";
21
+ private readonly scheduledAutoSavesAfterDelay;
22
+ private lastActiveEditor;
23
+ private lastActiveGroupId;
24
+ private readonly lastActiveEditorControlDisposable;
25
+ private readonly waitingOnConditionAutoSaveWorkingCopies;
26
+ private readonly waitingOnConditionAutoSaveEditors;
27
+ constructor(filesConfigurationService: IFilesConfigurationService, hostService: IHostService, editorService: IEditorService, editorGroupService: IEditorGroupsService, workingCopyService: IWorkingCopyService, logService: ILogService, markerService: IMarkerService, uriIdentityService: IUriIdentityService);
28
+ private registerListeners;
29
+ private onConditionChanged;
30
+ private onWindowFocusChange;
31
+ private onActiveWindowChange;
32
+ private onDidActiveEditorChange;
33
+ private maybeTriggerAutoSave;
34
+ private onDidChangeAutoSaveConfiguration;
35
+ private saveAllDirtyAutoSaveables;
36
+ private onDidRegister;
37
+ private onDidUnregister;
38
+ private onDidChangeDirty;
39
+ private onDidChangeContent;
40
+ private scheduleAutoSave;
41
+ private discardAutoSave;
42
+ }
@@ -0,0 +1,222 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { Disposable, DisposableStore, toDisposable, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import { AutoSaveDisabledReason, AutoSaveMode } from '@codingame/monaco-vscode-caeb744c-8e3f-5c11-80fb-0f057d24d544-common/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
5
+ import { IFilesConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
6
+ import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
7
+ import { SaveReason, EditorInputCapabilities } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
8
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
9
+ import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
10
+ import { IWorkingCopyService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service';
11
+ import { WorkingCopyCapabilities } from '@codingame/monaco-vscode-caeb744c-8e3f-5c11-80fb-0f057d24d544-common/vscode/vs/workbench/services/workingCopy/common/workingCopy';
12
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
13
+ import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
14
+ import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
15
+ import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
16
+
17
+ let EditorAutoSave = class EditorAutoSave extends Disposable {
18
+ static { this.ID = 'workbench.contrib.editorAutoSave'; }
19
+ constructor(filesConfigurationService, hostService, editorService, editorGroupService, workingCopyService, logService, markerService, uriIdentityService) {
20
+ super();
21
+ this.filesConfigurationService = filesConfigurationService;
22
+ this.hostService = hostService;
23
+ this.editorService = editorService;
24
+ this.editorGroupService = editorGroupService;
25
+ this.workingCopyService = workingCopyService;
26
+ this.logService = logService;
27
+ this.markerService = markerService;
28
+ this.uriIdentityService = uriIdentityService;
29
+ this.scheduledAutoSavesAfterDelay = ( new Map());
30
+ this.lastActiveEditor = undefined;
31
+ this.lastActiveGroupId = undefined;
32
+ this.lastActiveEditorControlDisposable = this._register(( new DisposableStore()));
33
+ this.waitingOnConditionAutoSaveWorkingCopies = ( new ResourceMap(resource => this.uriIdentityService.extUri.getComparisonKey(resource)));
34
+ this.waitingOnConditionAutoSaveEditors = ( new ResourceMap(resource => this.uriIdentityService.extUri.getComparisonKey(resource)));
35
+ for (const dirtyWorkingCopy of this.workingCopyService.dirtyWorkingCopies) {
36
+ this.onDidRegister(dirtyWorkingCopy);
37
+ }
38
+ this.registerListeners();
39
+ }
40
+ registerListeners() {
41
+ this._register(this.hostService.onDidChangeFocus(focused => this.onWindowFocusChange(focused)));
42
+ this._register(this.hostService.onDidChangeActiveWindow(() => this.onActiveWindowChange()));
43
+ this._register(this.editorService.onDidActiveEditorChange(() => this.onDidActiveEditorChange()));
44
+ this._register(this.filesConfigurationService.onDidChangeAutoSaveConfiguration(() => this.onDidChangeAutoSaveConfiguration()));
45
+ this._register(this.workingCopyService.onDidRegister(workingCopy => this.onDidRegister(workingCopy)));
46
+ this._register(this.workingCopyService.onDidUnregister(workingCopy => this.onDidUnregister(workingCopy)));
47
+ this._register(this.workingCopyService.onDidChangeDirty(workingCopy => this.onDidChangeDirty(workingCopy)));
48
+ this._register(this.workingCopyService.onDidChangeContent(workingCopy => this.onDidChangeContent(workingCopy)));
49
+ this._register(this.markerService.onMarkerChanged(e => this.onConditionChanged(e, AutoSaveDisabledReason.ERRORS)));
50
+ this._register(this.filesConfigurationService.onDidChangeAutoSaveDisabled(resource => this.onConditionChanged([resource], AutoSaveDisabledReason.DISABLED)));
51
+ }
52
+ onConditionChanged(resources, condition) {
53
+ for (const resource of resources) {
54
+ const workingCopyResult = this.waitingOnConditionAutoSaveWorkingCopies.get(resource);
55
+ if (workingCopyResult?.condition === condition) {
56
+ if (workingCopyResult.workingCopy.isDirty() &&
57
+ this.filesConfigurationService.getAutoSaveMode(workingCopyResult.workingCopy.resource, workingCopyResult.reason).mode !== AutoSaveMode.OFF) {
58
+ this.discardAutoSave(workingCopyResult.workingCopy);
59
+ this.logService.trace(`[editor auto save] running auto save from condition change event`, ( workingCopyResult.workingCopy.resource.toString()), workingCopyResult.workingCopy.typeId);
60
+ workingCopyResult.workingCopy.save({ reason: workingCopyResult.reason });
61
+ }
62
+ }
63
+ else {
64
+ const editorResult = this.waitingOnConditionAutoSaveEditors.get(resource);
65
+ if (editorResult?.condition === condition &&
66
+ !editorResult.editor.editor.isDisposed() &&
67
+ editorResult.editor.editor.isDirty() &&
68
+ this.filesConfigurationService.getAutoSaveMode(editorResult.editor.editor, editorResult.reason).mode !== AutoSaveMode.OFF) {
69
+ this.waitingOnConditionAutoSaveEditors.delete(resource);
70
+ this.logService.trace(`[editor auto save] running auto save from condition change event with reason ${editorResult.reason}`);
71
+ this.editorService.save(editorResult.editor, { reason: editorResult.reason });
72
+ }
73
+ }
74
+ }
75
+ }
76
+ onWindowFocusChange(focused) {
77
+ if (!focused) {
78
+ this.maybeTriggerAutoSave(SaveReason.WINDOW_CHANGE);
79
+ }
80
+ }
81
+ onActiveWindowChange() {
82
+ this.maybeTriggerAutoSave(SaveReason.WINDOW_CHANGE);
83
+ }
84
+ onDidActiveEditorChange() {
85
+ if (this.lastActiveEditor && typeof this.lastActiveGroupId === 'number') {
86
+ this.maybeTriggerAutoSave(SaveReason.FOCUS_CHANGE, { groupId: this.lastActiveGroupId, editor: this.lastActiveEditor });
87
+ }
88
+ const activeGroup = this.editorGroupService.activeGroup;
89
+ const activeEditor = this.lastActiveEditor = activeGroup.activeEditor ?? undefined;
90
+ this.lastActiveGroupId = activeGroup.id;
91
+ this.lastActiveEditorControlDisposable.clear();
92
+ const activeEditorPane = this.editorService.activeEditorPane;
93
+ if (activeEditor && activeEditorPane) {
94
+ this.lastActiveEditorControlDisposable.add(activeEditorPane.onDidBlur(() => {
95
+ this.maybeTriggerAutoSave(SaveReason.FOCUS_CHANGE, { groupId: activeGroup.id, editor: activeEditor });
96
+ }));
97
+ }
98
+ }
99
+ maybeTriggerAutoSave(reason, editorIdentifier) {
100
+ if (editorIdentifier) {
101
+ if (!editorIdentifier.editor.isDirty() ||
102
+ editorIdentifier.editor.isReadonly() ||
103
+ editorIdentifier.editor.hasCapability(EditorInputCapabilities.Untitled)) {
104
+ return;
105
+ }
106
+ const autoSaveMode = this.filesConfigurationService.getAutoSaveMode(editorIdentifier.editor, reason);
107
+ if (autoSaveMode.mode !== AutoSaveMode.OFF) {
108
+ if ((reason === SaveReason.WINDOW_CHANGE && (autoSaveMode.mode === AutoSaveMode.ON_FOCUS_CHANGE || autoSaveMode.mode === AutoSaveMode.ON_WINDOW_CHANGE)) ||
109
+ (reason === SaveReason.FOCUS_CHANGE && autoSaveMode.mode === AutoSaveMode.ON_FOCUS_CHANGE)) {
110
+ this.logService.trace(`[editor auto save] triggering auto save with reason ${reason}`);
111
+ this.editorService.save(editorIdentifier, { reason });
112
+ }
113
+ }
114
+ else if (editorIdentifier.editor.resource && (autoSaveMode.reason === AutoSaveDisabledReason.ERRORS || autoSaveMode.reason === AutoSaveDisabledReason.DISABLED)) {
115
+ this.waitingOnConditionAutoSaveEditors.set(editorIdentifier.editor.resource, { editor: editorIdentifier, reason, condition: autoSaveMode.reason });
116
+ }
117
+ }
118
+ else {
119
+ this.saveAllDirtyAutoSaveables(reason);
120
+ }
121
+ }
122
+ onDidChangeAutoSaveConfiguration() {
123
+ let reason = undefined;
124
+ switch (this.filesConfigurationService.getAutoSaveMode(undefined).mode) {
125
+ case AutoSaveMode.ON_FOCUS_CHANGE:
126
+ reason = SaveReason.FOCUS_CHANGE;
127
+ break;
128
+ case AutoSaveMode.ON_WINDOW_CHANGE:
129
+ reason = SaveReason.WINDOW_CHANGE;
130
+ break;
131
+ case AutoSaveMode.AFTER_SHORT_DELAY:
132
+ case AutoSaveMode.AFTER_LONG_DELAY:
133
+ reason = SaveReason.AUTO;
134
+ break;
135
+ }
136
+ if (reason) {
137
+ this.saveAllDirtyAutoSaveables(reason);
138
+ }
139
+ }
140
+ saveAllDirtyAutoSaveables(reason) {
141
+ for (const workingCopy of this.workingCopyService.dirtyWorkingCopies) {
142
+ if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
143
+ continue;
144
+ }
145
+ const autoSaveMode = this.filesConfigurationService.getAutoSaveMode(workingCopy.resource, reason);
146
+ if (autoSaveMode.mode !== AutoSaveMode.OFF) {
147
+ workingCopy.save({ reason });
148
+ }
149
+ else if (autoSaveMode.reason === AutoSaveDisabledReason.ERRORS || autoSaveMode.reason === AutoSaveDisabledReason.DISABLED) {
150
+ this.waitingOnConditionAutoSaveWorkingCopies.set(workingCopy.resource, { workingCopy, reason, condition: autoSaveMode.reason });
151
+ }
152
+ }
153
+ }
154
+ onDidRegister(workingCopy) {
155
+ if (workingCopy.isDirty()) {
156
+ this.scheduleAutoSave(workingCopy);
157
+ }
158
+ }
159
+ onDidUnregister(workingCopy) {
160
+ this.discardAutoSave(workingCopy);
161
+ }
162
+ onDidChangeDirty(workingCopy) {
163
+ if (workingCopy.isDirty()) {
164
+ this.scheduleAutoSave(workingCopy);
165
+ }
166
+ else {
167
+ this.discardAutoSave(workingCopy);
168
+ }
169
+ }
170
+ onDidChangeContent(workingCopy) {
171
+ if (workingCopy.isDirty()) {
172
+ this.scheduleAutoSave(workingCopy);
173
+ }
174
+ }
175
+ scheduleAutoSave(workingCopy) {
176
+ if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
177
+ return;
178
+ }
179
+ const autoSaveAfterDelay = this.filesConfigurationService.getAutoSaveConfiguration(workingCopy.resource).autoSaveDelay;
180
+ if (typeof autoSaveAfterDelay !== 'number') {
181
+ return;
182
+ }
183
+ this.discardAutoSave(workingCopy);
184
+ this.logService.trace(`[editor auto save] scheduling auto save after ${autoSaveAfterDelay}ms`, ( workingCopy.resource.toString()), workingCopy.typeId);
185
+ const handle = setTimeout(() => {
186
+ this.discardAutoSave(workingCopy);
187
+ if (workingCopy.isDirty()) {
188
+ const reason = SaveReason.AUTO;
189
+ const autoSaveMode = this.filesConfigurationService.getAutoSaveMode(workingCopy.resource, reason);
190
+ if (autoSaveMode.mode !== AutoSaveMode.OFF) {
191
+ this.logService.trace(`[editor auto save] running auto save`, ( workingCopy.resource.toString()), workingCopy.typeId);
192
+ workingCopy.save({ reason });
193
+ }
194
+ else if (autoSaveMode.reason === AutoSaveDisabledReason.ERRORS || autoSaveMode.reason === AutoSaveDisabledReason.DISABLED) {
195
+ this.waitingOnConditionAutoSaveWorkingCopies.set(workingCopy.resource, { workingCopy, reason, condition: autoSaveMode.reason });
196
+ }
197
+ }
198
+ }, autoSaveAfterDelay);
199
+ this.scheduledAutoSavesAfterDelay.set(workingCopy, toDisposable(() => {
200
+ this.logService.trace(`[editor auto save] clearing pending auto save`, ( workingCopy.resource.toString()), workingCopy.typeId);
201
+ clearTimeout(handle);
202
+ }));
203
+ }
204
+ discardAutoSave(workingCopy) {
205
+ dispose(this.scheduledAutoSavesAfterDelay.get(workingCopy));
206
+ this.scheduledAutoSavesAfterDelay.delete(workingCopy);
207
+ this.waitingOnConditionAutoSaveWorkingCopies.delete(workingCopy.resource);
208
+ this.waitingOnConditionAutoSaveEditors.delete(workingCopy.resource);
209
+ }
210
+ };
211
+ EditorAutoSave = ( __decorate([
212
+ ( __param(0, IFilesConfigurationService)),
213
+ ( __param(1, IHostService)),
214
+ ( __param(2, IEditorService)),
215
+ ( __param(3, IEditorGroupsService)),
216
+ ( __param(4, IWorkingCopyService)),
217
+ ( __param(5, ILogService)),
218
+ ( __param(6, IMarkerService)),
219
+ ( __param(7, IUriIdentityService))
220
+ ], EditorAutoSave));
221
+
222
+ export { EditorAutoSave };
@@ -0,0 +1,32 @@
1
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
+ import { ISaveErrorHandler, ITextFileEditorModel, ITextFileSaveOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles";
3
+ import { ITextFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service";
4
+ import { ServicesAccessor, IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
5
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
6
+ import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
7
+ import { ITextModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service";
8
+ import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
9
+ import { INotificationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service";
10
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
11
+ import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
12
+ export declare const CONFLICT_RESOLUTION_CONTEXT = "saveConflictResolutionContext";
13
+ export declare const CONFLICT_RESOLUTION_SCHEME = "conflictResolution";
14
+ export declare class TextFileSaveErrorHandler extends Disposable implements ISaveErrorHandler, IWorkbenchContribution {
15
+ private readonly notificationService;
16
+ private readonly textFileService;
17
+ private readonly editorService;
18
+ private readonly instantiationService;
19
+ private readonly storageService;
20
+ static readonly ID = "workbench.contrib.textFileSaveErrorHandler";
21
+ private readonly messages;
22
+ private readonly conflictResolutionContext;
23
+ private activeConflictResolutionResource;
24
+ constructor(notificationService: INotificationService, textFileService: ITextFileService, contextKeyService: IContextKeyService, editorService: IEditorService, textModelService: ITextModelService, instantiationService: IInstantiationService, storageService: IStorageService);
25
+ private registerListeners;
26
+ private onActiveEditorChanged;
27
+ private onFileSavedOrReverted;
28
+ onSaveError(error: unknown, model: ITextFileEditorModel, options: ITextFileSaveOptions): void;
29
+ dispose(): void;
30
+ }
31
+ export declare const acceptLocalChangesCommand: (accessor: ServicesAccessor, resource: URI) => Promise<boolean | undefined>;
32
+ export declare const revertLocalChangesCommand: (accessor: ServicesAccessor, resource: URI) => Promise<boolean | undefined>;