@codingame/monaco-vscode-bulk-edit-service-override 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
3
+ import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
4
+ import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
5
+ import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
7
+ import { ResourceTextEdit, ResourceFileEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
8
+ import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
9
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
10
+
11
+ let ConflictDetector = class ConflictDetector {
12
+ constructor(edits, fileService, modelService, logService) {
13
+ this._conflicts = ( new ResourceMap());
14
+ this._disposables = ( new DisposableStore());
15
+ this._onDidConflict = ( new Emitter());
16
+ this.onDidConflict = this._onDidConflict.event;
17
+ const _workspaceEditResources = ( new ResourceMap());
18
+ for (const edit of edits) {
19
+ if (edit instanceof ResourceTextEdit) {
20
+ _workspaceEditResources.set(edit.resource, true);
21
+ if (typeof edit.versionId === 'number') {
22
+ const model = modelService.getModel(edit.resource);
23
+ if (model && model.getVersionId() !== edit.versionId) {
24
+ this._conflicts.set(edit.resource, true);
25
+ this._onDidConflict.fire(this);
26
+ }
27
+ }
28
+ }
29
+ else if (edit instanceof ResourceFileEdit) {
30
+ if (edit.newResource) {
31
+ _workspaceEditResources.set(edit.newResource, true);
32
+ }
33
+ else if (edit.oldResource) {
34
+ _workspaceEditResources.set(edit.oldResource, true);
35
+ }
36
+ }
37
+ else if (edit instanceof ResourceNotebookCellEdit) {
38
+ _workspaceEditResources.set(edit.resource, true);
39
+ }
40
+ else {
41
+ logService.warn('UNKNOWN edit type', edit);
42
+ }
43
+ }
44
+ this._disposables.add(fileService.onDidFilesChange(e => {
45
+ for (const uri of ( _workspaceEditResources.keys())) {
46
+ if (!modelService.getModel(uri) && e.contains(uri)) {
47
+ this._conflicts.set(uri, true);
48
+ this._onDidConflict.fire(this);
49
+ break;
50
+ }
51
+ }
52
+ }));
53
+ const onDidChangeModel = (model) => {
54
+ if (( _workspaceEditResources.has(model.uri))) {
55
+ this._conflicts.set(model.uri, true);
56
+ this._onDidConflict.fire(this);
57
+ }
58
+ };
59
+ for (const model of modelService.getModels()) {
60
+ this._disposables.add(model.onDidChangeContent(() => onDidChangeModel(model)));
61
+ }
62
+ }
63
+ dispose() {
64
+ this._disposables.dispose();
65
+ this._onDidConflict.dispose();
66
+ }
67
+ list() {
68
+ return [...( this._conflicts.keys())];
69
+ }
70
+ hasConflicts() {
71
+ return this._conflicts.size > 0;
72
+ }
73
+ };
74
+ ConflictDetector = ( __decorate([
75
+ ( __param(1, IFileService)),
76
+ ( __param(2, IModelService)),
77
+ ( __param(3, ILogService))
78
+ ], ConflictDetector));
79
+
80
+ export { ConflictDetector };
@@ -0,0 +1,365 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
3
+ import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
4
+ import { IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
5
+ import { BulkEditPane } from './bulkEditPane.js';
6
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
7
+ import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
8
+ import { FocusedViewContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
9
+ import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
10
+ import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
11
+ import { RawContextKey, ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
12
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
13
+ import { WorkbenchListFocusContextKey } from 'vscode/vscode/vs/platform/list/browser/listService';
14
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
15
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
16
+ import { EditorResourceAccessor, SideBySideEditor } from 'vscode/vscode/vs/workbench/common/editor';
17
+ import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
18
+ import '../../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
19
+ import Severity$1 from 'vscode/vscode/vs/base/common/severity';
20
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
21
+ import { registerIcon } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
22
+ import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite';
23
+ import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
24
+
25
+ var BulkEditPreviewContribution_1;
26
+ async function getBulkEditPane(viewsService) {
27
+ const view = await viewsService.openView(BulkEditPane.ID, true);
28
+ if (view instanceof BulkEditPane) {
29
+ return view;
30
+ }
31
+ return undefined;
32
+ }
33
+ let UXState = class UXState {
34
+ constructor(_paneCompositeService, _editorGroupsService) {
35
+ this._paneCompositeService = _paneCompositeService;
36
+ this._editorGroupsService = _editorGroupsService;
37
+ this._activePanel = _paneCompositeService.getActivePaneComposite(1 )?.getId();
38
+ }
39
+ async restore(panels, editors) {
40
+ if (panels) {
41
+ if (typeof this._activePanel === 'string') {
42
+ await this._paneCompositeService.openPaneComposite(this._activePanel, 1 );
43
+ }
44
+ else {
45
+ this._paneCompositeService.hideActivePaneComposite(1 );
46
+ }
47
+ }
48
+ if (editors) {
49
+ for (const group of this._editorGroupsService.groups) {
50
+ const previewEditors = [];
51
+ for (const input of group.editors) {
52
+ const resource = EditorResourceAccessor.getCanonicalUri(input, { supportSideBySide: SideBySideEditor.PRIMARY });
53
+ if (resource?.scheme === BulkEditPane.Schema) {
54
+ previewEditors.push(input);
55
+ }
56
+ }
57
+ if (previewEditors.length) {
58
+ group.closeEditors(previewEditors, { preserveFocus: true });
59
+ }
60
+ }
61
+ }
62
+ }
63
+ };
64
+ UXState = ( __decorate([
65
+ ( __param(0, IPaneCompositePartService)),
66
+ ( __param(1, IEditorGroupsService))
67
+ ], UXState));
68
+ class PreviewSession {
69
+ constructor(uxState, cts = ( new CancellationTokenSource())) {
70
+ this.uxState = uxState;
71
+ this.cts = cts;
72
+ }
73
+ }
74
+ let BulkEditPreviewContribution = class BulkEditPreviewContribution {
75
+ static { BulkEditPreviewContribution_1 = this; }
76
+ static { this.ID = 'workbench.contrib.bulkEditPreview'; }
77
+ static { this.ctxEnabled = ( new RawContextKey('refactorPreview.enabled', false)); }
78
+ constructor(_paneCompositeService, _viewsService, _editorGroupsService, _dialogService, bulkEditService, contextKeyService) {
79
+ this._paneCompositeService = _paneCompositeService;
80
+ this._viewsService = _viewsService;
81
+ this._editorGroupsService = _editorGroupsService;
82
+ this._dialogService = _dialogService;
83
+ bulkEditService.setPreviewHandler(edits => this._previewEdit(edits));
84
+ this._ctxEnabled = BulkEditPreviewContribution_1.ctxEnabled.bindTo(contextKeyService);
85
+ }
86
+ async _previewEdit(edits) {
87
+ this._ctxEnabled.set(true);
88
+ const uxState = this._activeSession?.uxState ?? ( new UXState(this._paneCompositeService, this._editorGroupsService));
89
+ const view = await getBulkEditPane(this._viewsService);
90
+ if (!view) {
91
+ this._ctxEnabled.set(false);
92
+ return edits;
93
+ }
94
+ if (view.hasInput()) {
95
+ const { confirmed } = await this._dialogService.confirm({
96
+ type: Severity$1.Info,
97
+ message: ( localizeWithPath(
98
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
99
+ 'overlap',
100
+ "Another refactoring is being previewed."
101
+ )),
102
+ detail: ( localizeWithPath(
103
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
104
+ 'detail',
105
+ "Press 'Continue' to discard the previous refactoring and continue with the current refactoring."
106
+ )),
107
+ primaryButton: ( localizeWithPath(
108
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
109
+ { key: 'continue', comment: ['&& denotes a mnemonic'] },
110
+ "&&Continue"
111
+ ))
112
+ });
113
+ if (!confirmed) {
114
+ return [];
115
+ }
116
+ }
117
+ let session;
118
+ if (this._activeSession) {
119
+ await this._activeSession.uxState.restore(false, true);
120
+ this._activeSession.cts.dispose(true);
121
+ session = ( new PreviewSession(uxState));
122
+ }
123
+ else {
124
+ session = ( new PreviewSession(uxState));
125
+ }
126
+ this._activeSession = session;
127
+ try {
128
+ return (await view.setInput(edits, session.cts.token)) ?? [];
129
+ }
130
+ finally {
131
+ if (this._activeSession === session) {
132
+ await this._activeSession.uxState.restore(true, true);
133
+ this._activeSession.cts.dispose();
134
+ this._ctxEnabled.set(false);
135
+ this._activeSession = undefined;
136
+ }
137
+ }
138
+ }
139
+ };
140
+ BulkEditPreviewContribution = BulkEditPreviewContribution_1 = ( __decorate([
141
+ ( __param(0, IPaneCompositePartService)),
142
+ ( __param(1, IViewsService)),
143
+ ( __param(2, IEditorGroupsService)),
144
+ ( __param(3, IDialogService)),
145
+ ( __param(4, IBulkEditService)),
146
+ ( __param(5, IContextKeyService))
147
+ ], BulkEditPreviewContribution));
148
+ registerAction2(class ApplyAction extends Action2 {
149
+ constructor() {
150
+ super({
151
+ id: 'refactorPreview.apply',
152
+ title: ( localize2WithPath(
153
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
154
+ 'apply',
155
+ "Apply Refactoring"
156
+ )),
157
+ category: ( localize2WithPath(
158
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
159
+ 'cat',
160
+ "Refactor Preview"
161
+ )),
162
+ icon: Codicon.check,
163
+ precondition: ( ContextKeyExpr.and(BulkEditPreviewContribution.ctxEnabled, BulkEditPane.ctxHasCheckedChanges)),
164
+ menu: [{
165
+ id: MenuId.BulkEditContext,
166
+ order: 1
167
+ }],
168
+ keybinding: {
169
+ weight: 100 - 10,
170
+ when: ( ContextKeyExpr.and(BulkEditPreviewContribution.ctxEnabled, ( FocusedViewContext.isEqualTo(BulkEditPane.ID)))),
171
+ primary: 2048 + 3 ,
172
+ }
173
+ });
174
+ }
175
+ async run(accessor) {
176
+ const viewsService = accessor.get(IViewsService);
177
+ const view = await getBulkEditPane(viewsService);
178
+ view?.accept();
179
+ }
180
+ });
181
+ registerAction2(class DiscardAction extends Action2 {
182
+ constructor() {
183
+ super({
184
+ id: 'refactorPreview.discard',
185
+ title: ( localize2WithPath(
186
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
187
+ 'Discard',
188
+ "Discard Refactoring"
189
+ )),
190
+ category: ( localize2WithPath(
191
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
192
+ 'cat',
193
+ "Refactor Preview"
194
+ )),
195
+ icon: Codicon.clearAll,
196
+ precondition: BulkEditPreviewContribution.ctxEnabled,
197
+ menu: [{
198
+ id: MenuId.BulkEditContext,
199
+ order: 2
200
+ }]
201
+ });
202
+ }
203
+ async run(accessor) {
204
+ const viewsService = accessor.get(IViewsService);
205
+ const view = await getBulkEditPane(viewsService);
206
+ view?.discard();
207
+ }
208
+ });
209
+ registerAction2(class ToggleAction extends Action2 {
210
+ constructor() {
211
+ super({
212
+ id: 'refactorPreview.toggleCheckedState',
213
+ title: ( localize2WithPath(
214
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
215
+ 'toogleSelection',
216
+ "Toggle Change"
217
+ )),
218
+ category: ( localize2WithPath(
219
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
220
+ 'cat',
221
+ "Refactor Preview"
222
+ )),
223
+ precondition: BulkEditPreviewContribution.ctxEnabled,
224
+ keybinding: {
225
+ weight: 200 ,
226
+ when: WorkbenchListFocusContextKey,
227
+ primary: 10 ,
228
+ },
229
+ menu: {
230
+ id: MenuId.BulkEditContext,
231
+ group: 'navigation'
232
+ }
233
+ });
234
+ }
235
+ async run(accessor) {
236
+ const viewsService = accessor.get(IViewsService);
237
+ const view = await getBulkEditPane(viewsService);
238
+ view?.toggleChecked();
239
+ }
240
+ });
241
+ registerAction2(class GroupByFile extends Action2 {
242
+ constructor() {
243
+ super({
244
+ id: 'refactorPreview.groupByFile',
245
+ title: ( localize2WithPath(
246
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
247
+ 'groupByFile',
248
+ "Group Changes By File"
249
+ )),
250
+ category: ( localize2WithPath(
251
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
252
+ 'cat',
253
+ "Refactor Preview"
254
+ )),
255
+ icon: Codicon.ungroupByRefType,
256
+ precondition: ( ContextKeyExpr.and(BulkEditPane.ctxHasCategories, ( BulkEditPane.ctxGroupByFile.negate()), BulkEditPreviewContribution.ctxEnabled)),
257
+ menu: [{
258
+ id: MenuId.BulkEditTitle,
259
+ when: ( ContextKeyExpr.and(BulkEditPane.ctxHasCategories, ( BulkEditPane.ctxGroupByFile.negate()))),
260
+ group: 'navigation',
261
+ order: 3,
262
+ }]
263
+ });
264
+ }
265
+ async run(accessor) {
266
+ const viewsService = accessor.get(IViewsService);
267
+ const view = await getBulkEditPane(viewsService);
268
+ view?.groupByFile();
269
+ }
270
+ });
271
+ registerAction2(class GroupByType extends Action2 {
272
+ constructor() {
273
+ super({
274
+ id: 'refactorPreview.groupByType',
275
+ title: ( localize2WithPath(
276
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
277
+ 'groupByType',
278
+ "Group Changes By Type"
279
+ )),
280
+ category: ( localize2WithPath(
281
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
282
+ 'cat',
283
+ "Refactor Preview"
284
+ )),
285
+ icon: Codicon.groupByRefType,
286
+ precondition: ( ContextKeyExpr.and(
287
+ BulkEditPane.ctxHasCategories,
288
+ BulkEditPane.ctxGroupByFile,
289
+ BulkEditPreviewContribution.ctxEnabled
290
+ )),
291
+ menu: [{
292
+ id: MenuId.BulkEditTitle,
293
+ when: ( ContextKeyExpr.and(BulkEditPane.ctxHasCategories, BulkEditPane.ctxGroupByFile)),
294
+ group: 'navigation',
295
+ order: 3
296
+ }]
297
+ });
298
+ }
299
+ async run(accessor) {
300
+ const viewsService = accessor.get(IViewsService);
301
+ const view = await getBulkEditPane(viewsService);
302
+ view?.groupByType();
303
+ }
304
+ });
305
+ registerAction2(class ToggleGrouping extends Action2 {
306
+ constructor() {
307
+ super({
308
+ id: 'refactorPreview.toggleGrouping',
309
+ title: ( localize2WithPath(
310
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
311
+ 'groupByType',
312
+ "Group Changes By Type"
313
+ )),
314
+ category: ( localize2WithPath(
315
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
316
+ 'cat',
317
+ "Refactor Preview"
318
+ )),
319
+ icon: Codicon.listTree,
320
+ toggled: ( BulkEditPane.ctxGroupByFile.negate()),
321
+ precondition: ( ContextKeyExpr.and(BulkEditPane.ctxHasCategories, BulkEditPreviewContribution.ctxEnabled)),
322
+ menu: [{
323
+ id: MenuId.BulkEditContext,
324
+ order: 3
325
+ }]
326
+ });
327
+ }
328
+ async run(accessor) {
329
+ const viewsService = accessor.get(IViewsService);
330
+ const view = await getBulkEditPane(viewsService);
331
+ view?.toggleGrouping();
332
+ }
333
+ });
334
+ registerWorkbenchContribution2(BulkEditPreviewContribution.ID, BulkEditPreviewContribution, 2 );
335
+ const refactorPreviewViewIcon = registerIcon('refactor-preview-view-icon', Codicon.lightbulb, ( localizeWithPath(
336
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
337
+ 'refactorPreviewViewIcon',
338
+ 'View icon of the refactor preview view.'
339
+ )));
340
+ const container = ( Registry.as(Extensions.ViewContainersRegistry)).registerViewContainer({
341
+ id: BulkEditPane.ID,
342
+ title: ( localize2WithPath(
343
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
344
+ 'panel',
345
+ "Refactor Preview"
346
+ )),
347
+ hideIfEmpty: true,
348
+ ctorDescriptor: ( new SyncDescriptor(
349
+ ViewPaneContainer,
350
+ [BulkEditPane.ID, { mergeViewWithContainerWhenSingleView: true }]
351
+ )),
352
+ icon: refactorPreviewViewIcon,
353
+ storageId: BulkEditPane.ID
354
+ }, 1 );
355
+ ( Registry.as(Extensions.ViewsRegistry)).registerViews([{
356
+ id: BulkEditPane.ID,
357
+ name: ( localize2WithPath(
358
+ 'vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution',
359
+ 'panel',
360
+ "Refactor Preview"
361
+ )),
362
+ when: BulkEditPreviewContribution.ctxEnabled,
363
+ ctorDescriptor: ( new SyncDescriptor(BulkEditPane)),
364
+ containerIcon: refactorPreviewViewIcon,
365
+ }], container);
@@ -0,0 +1,6 @@
1
+ import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
+
3
+ var css = ".monaco-workbench .bulk-edit-panel .highlight.insert{background-color:var(--vscode-diffEditor-insertedTextBackground)}.monaco-workbench .bulk-edit-panel .highlight.remove{background-color:var(--vscode-diffEditor-removedTextBackground);text-decoration:line-through}.monaco-workbench .bulk-edit-panel .message{padding:10px 20px}.monaco-workbench .bulk-edit-panel[data-state=data] .content,.monaco-workbench .bulk-edit-panel[data-state=message] .message{display:flex}.monaco-workbench .bulk-edit-panel[data-state=data] .message,.monaco-workbench .bulk-edit-panel[data-state=message] .content{display:none}.monaco-workbench .bulk-edit-panel .content{display:flex;flex-direction:column;justify-content:space-between}.monaco-workbench .bulk-edit-panel .content .buttons{padding-left:20px;padding-top:10px}.monaco-workbench .bulk-edit-panel .content .buttons .monaco-button{display:inline-flex;margin:0 4px;padding:4px 8px;width:inherit}.monaco-workbench .bulk-edit-panel .monaco-tl-contents{display:flex}.monaco-workbench .bulk-edit-panel .monaco-tl-contents .edit-checkbox{align-self:center}.monaco-workbench .bulk-edit-panel .monaco-tl-contents .edit-checkbox.disabled{opacity:.5}.monaco-workbench .bulk-edit-panel .monaco-tl-contents .monaco-icon-label.delete .monaco-icon-label-container{text-decoration:line-through}.monaco-workbench .bulk-edit-panel .monaco-tl-contents .details{font-size:.9em;margin-left:.5em;opacity:.7;white-space:pre}.monaco-workbench .bulk-edit-panel .monaco-tl-contents.category{align-items:center;display:flex;flex:1;flex-flow:row nowrap}.monaco-workbench .bulk-edit-panel .monaco-tl-contents.category .theme-icon,.monaco-workbench .bulk-edit-panel .monaco-tl-contents.textedit .theme-icon{margin-right:4px}.monaco-workbench .bulk-edit-panel .monaco-tl-contents.category .uri-icon,.monaco-workbench .bulk-edit-panel .monaco-tl-contents.textedit .uri-icon,.monaco-workbench.hc-light .bulk-edit-panel .monaco-tl-contents.category .uri-icon,.monaco-workbench.hc-light .bulk-edit-panel .monaco-tl-contents.textedit .uri-icon{background-image:var(--background-light);background-position:0;background-repeat:no-repeat;background-size:contain;height:100%;margin-right:4px;min-width:16px;width:16px}.monaco-workbench.hc-black .bulk-edit-panel .monaco-tl-contents.category .uri-icon,.monaco-workbench.hc-black .bulk-edit-panel .monaco-tl-contents.textedit .uri-icon,.monaco-workbench.vs-dark .bulk-edit-panel .monaco-tl-contents.category .uri-icon,.monaco-workbench.vs-dark .bulk-edit-panel .monaco-tl-contents.textedit .uri-icon{background-image:var(--background-dark)}.monaco-workbench .bulk-edit-panel .monaco-tl-contents.textedit .monaco-highlighted-label{overflow:hidden;text-overflow:ellipsis}";
4
+ n(css,{});
5
+
6
+ export { css, css as default };