undoRedo.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*---------------------------------------------------------------------------------------------
  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. import { createDecorator } from '../../instantiation/common/instantiation.js';
  6. export const IUndoRedoService = createDecorator('undoRedoService');
  7. export class ResourceEditStackSnapshot {
  8. constructor(resource, elements) {
  9. this.resource = resource;
  10. this.elements = elements;
  11. }
  12. }
  13. export class UndoRedoGroup {
  14. constructor() {
  15. this.id = UndoRedoGroup._ID++;
  16. this.order = 1;
  17. }
  18. nextOrder() {
  19. if (this.id === 0) {
  20. return 0;
  21. }
  22. return this.order++;
  23. }
  24. }
  25. UndoRedoGroup._ID = 0;
  26. UndoRedoGroup.None = new UndoRedoGroup();
  27. export class UndoRedoSource {
  28. constructor() {
  29. this.id = UndoRedoSource._ID++;
  30. this.order = 1;
  31. }
  32. nextOrder() {
  33. if (this.id === 0) {
  34. return 0;
  35. }
  36. return this.order++;
  37. }
  38. }
  39. UndoRedoSource._ID = 0;
  40. UndoRedoSource.None = new UndoRedoSource();