1
>
/*---------------------------------------------------------------------------------------------
undoRedoService.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { onUnexpectedError } from '../../../base/common/errors.js';
7
>
import { Disposable, IDisposable, isDisposable } from '../../../base/common/lifecycle.js';
8
>
import { Schemas } from '../../../base/common/network.js';
9
>
import Severity from '../../../base/common/severity.js';
10
>
import { URI } from '../../../base/common/uri.js';
11
>
import * as nls from '../../../nls.js';
12
>
import { IDialogService } from '../../dialogs/common/dialogs.js';
13
>
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
14
>
import { INotificationService } from '../../notification/common/notification.js';
15
>
import { IPastFutureElements, IResourceUndoRedoElement, IUndoRedoElement, IUndoRedoService, IWorkspaceUndoRedoElement, ResourceEditStackSnapshot, UndoRedoElementType, UndoRedoGroup, UndoRedoSource, UriComparisonKeyComputer } from './undoRedo.js';
16
>
17
>
const DEBUG = false;
18
>
19
function getResourceLabel(resource: URI): string {
20
return resource.scheme === Schemas.file ? resource.fsPath : resource.path;
21
}
23
>
let stackElementCounter = 0;
24
>
25
>
class ResourceStackElement {
26
>
public readonly id = (++stackElementCounter);
27
>
public readonly type = UndoRedoElementType.Resource;
28
>
public readonly actual: IUndoRedoElement;
29
>
public readonly label: string;
30
>
public readonly confirmBeforeUndo: boolean;
31
>
32
>
public readonly resourceLabel: string;
33
>
public readonly strResource: string;
34
>
public readonly resourceLabels: string[];
35
>
public readonly strResources: string[];
36
>
public readonly groupId: number;
37
>
public readonly groupOrder: number;
38
>
public readonly sourceId: number;
39
>
public readonly sourceOrder: number;
40
>
public isValid: boolean;
41
>
42
>
constructor(actual: IUndoRedoElement, resourceLabel: string, strResource: string, groupId: number, groupOrder: number, sourceId: number, sourceOrder: number) {
43
this.actual = actual;
44
this.label = actual.label;