@theia/editor 1.40.1 → 1.41.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.
- package/lib/browser/editor-frontend-module.d.ts.map +1 -1
- package/lib/browser/editor-frontend-module.js +2 -0
- package/lib/browser/editor-frontend-module.js.map +1 -1
- package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
- package/lib/browser/editor-linenumber-contribution.js +3 -2
- package/lib/browser/editor-linenumber-contribution.js.map +1 -1
- package/lib/browser/editor-widget-factory.js +1 -1
- package/lib/browser/undo-redo-service.d.ts +24 -0
- package/lib/browser/undo-redo-service.d.ts.map +1 -0
- package/lib/browser/undo-redo-service.js +111 -0
- package/lib/browser/undo-redo-service.js.map +1 -0
- package/package.json +5 -5
- package/src/browser/editor-frontend-module.ts +3 -0
- package/src/browser/editor-linenumber-contribution.ts +3 -2
- package/src/browser/editor-widget-factory.ts +1 -1
- package/src/browser/undo-redo-service.ts +120 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/editor-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8DAA8D,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;
|
|
1
|
+
{"version":3,"file":"editor-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/editor-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8DAA8D,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAuB/D,wBAiDG"}
|
|
@@ -38,6 +38,7 @@ const quick_access_1 = require("@theia/core/lib/browser/quick-input/quick-access
|
|
|
38
38
|
const quick_editor_service_1 = require("./quick-editor-service");
|
|
39
39
|
const editor_language_status_service_1 = require("./language-status/editor-language-status-service");
|
|
40
40
|
const editor_linenumber_contribution_1 = require("./editor-linenumber-contribution");
|
|
41
|
+
const undo_redo_service_1 = require("./undo-redo-service");
|
|
41
42
|
exports.default = new inversify_1.ContainerModule(bind => {
|
|
42
43
|
(0, editor_preferences_1.bindEditorPreferences)(bind);
|
|
43
44
|
bind(editor_widget_factory_1.EditorWidgetFactory).toSelf().inSingletonScope();
|
|
@@ -74,5 +75,6 @@ exports.default = new inversify_1.ContainerModule(bind => {
|
|
|
74
75
|
bind(editor_manager_1.ActiveEditorAccess).toSelf().inSingletonScope();
|
|
75
76
|
bind(editor_manager_1.EditorAccess).to(editor_manager_1.CurrentEditorAccess).inSingletonScope().whenTargetNamed(editor_manager_1.EditorAccess.CURRENT);
|
|
76
77
|
bind(editor_manager_1.EditorAccess).to(editor_manager_1.ActiveEditorAccess).inSingletonScope().whenTargetNamed(editor_manager_1.EditorAccess.ACTIVE);
|
|
78
|
+
bind(undo_redo_service_1.UndoRedoService).toSelf().inSingletonScope();
|
|
77
79
|
});
|
|
78
80
|
//# sourceMappingURL=editor-frontend-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-frontend-module.js","sourceRoot":"","sources":["../../src/browser/editor-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,6CAA2C;AAC3C,wEAAsE;AAEtE,4DAA+D;AAC/D,mDAA+E;AAC/E,qDAAiJ;AACjJ,kEAA4E;AAC5E,qDAAwG;AACxG,+DAA2D;AAC3D,+CAAuD;AACvD,qDAA6D;AAC7D,6EAAgI;AAChI,2DAAmE;AACnE,6DAA6D;AAC7D,mEAA8D;AAC9D,qFAAgF;AAChF,0FAAqF;AACrF,0FAAqF;A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or-linenumber-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/editor-linenumber-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAA6B,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAoC,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,eAAO,MAAM,8BAA8B,EAAE,QAA6C,CAAC;AAE3F,qBACa,4BAA6B,YAAW,+BAA+B;IAGhF,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAG5D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEhD,OAAO,IAAI,IAAI;IAIf,SAAS,CAAC,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAWpE,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"editor-linenumber-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/editor-linenumber-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAA6B,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAoC,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,eAAO,MAAM,8BAA8B,EAAE,QAA6C,CAAC;AAE3F,qBACa,4BAA6B,YAAW,+BAA+B;IAGhF,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAG5D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEhD,OAAO,IAAI,IAAI;IAIf,SAAS,CAAC,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAWpE,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;CA0BjF"}
|
|
@@ -47,7 +47,7 @@ let EditorLineNumberContribution = class EditorLineNumberContribution {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
handleContextMenu(editor, event) {
|
|
50
|
-
if (event.target && event.target.type === editor_1.MouseTargetType.GUTTER_LINE_NUMBERS) {
|
|
50
|
+
if (event.target && (event.target.type === editor_1.MouseTargetType.GUTTER_LINE_NUMBERS || event.target.type === editor_1.MouseTargetType.GUTTER_GLYPH_MARGIN)) {
|
|
51
51
|
if (event.event.button === 2) {
|
|
52
52
|
editor.focus();
|
|
53
53
|
const lineNumber = lineNumberFromPosition(event.target.position);
|
|
@@ -55,7 +55,8 @@ let EditorLineNumberContribution = class EditorLineNumberContribution {
|
|
|
55
55
|
const uri = editor.getResourceUri();
|
|
56
56
|
const args = [{
|
|
57
57
|
lineNumber: lineNumber,
|
|
58
|
-
|
|
58
|
+
column: 1,
|
|
59
|
+
uri: uri['codeUri'],
|
|
59
60
|
}];
|
|
60
61
|
setTimeout(() => {
|
|
61
62
|
this.contextMenuRenderer.render({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-linenumber-contribution.js","source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QACnE,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,wBAAe,CAAC,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"editor-linenumber-contribution.js","sourceRoot":"","sources":["../../src/browser/editor-linenumber-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;AAEhF,qDAAiD;AACjD,qCAAmF;AACnF,4DAAkE;AAClE,qDAA+F;AAC/F,qFAAgF;AAChF,sCAAyE;AAG5D,QAAA,8BAA8B,GAAa,CAAC,gCAAgC,CAAC,CAAC;AAG3F,IAAa,4BAA4B,GAAzC,MAAa,4BAA4B;IAWrC,OAAO;QACH,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,CAAC;IAES,wBAAwB,CAAC,YAA0B;QACzD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QACnC,IAAI,MAAM,EAAE;YACR,MAAM,WAAW,GAAG,IAAI,2BAAoB,EAAE,CAAC;YAC/C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACrF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5C,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACvC,WAAW,CAAC,IAAI,CAAC,iBAAU,CAAC,MAAM,CA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B,CAAC;8BACY,6BAAmB;yEAAC;AAG5D;IADC,IAAA,kBAAM,EAAC,8BAAa,CAAC;8BACY,8BAAa;mEAAC;AATvC,4BAA4B;IADxC,IAAA,sBAAU,GAAE;GACA,4BAA4B,CAoDxC;AApDY,oEAA4B;AAsDzC,SAAS,sBAAsB,CAAC,QAA8B;IAC1D,4FAA4F;IAC5F,IAAI,QAAQ,EAAE;QACV,OAAO,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;KAC5B;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -65,7 +65,7 @@ let EditorWidgetFactory = EditorWidgetFactory_1 = class EditorWidgetFactory {
|
|
|
65
65
|
setLabels(editor, uri) {
|
|
66
66
|
editor.title.caption = uri.path.fsPath();
|
|
67
67
|
if (editor.editor.isReadonly) {
|
|
68
|
-
editor.title.caption += ` • ${common_1.nls.localizeByDefault('Read
|
|
68
|
+
editor.title.caption += ` • ${common_1.nls.localizeByDefault('Read-only')}`;
|
|
69
69
|
}
|
|
70
70
|
const icon = this.labelProvider.getIcon(uri);
|
|
71
71
|
editor.title.label = this.labelProvider.getName(uri);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
export declare class UndoRedoService {
|
|
3
|
+
private readonly editStacks;
|
|
4
|
+
pushElement(resource: URI, undo: () => Promise<void>, redo: () => Promise<void>): void;
|
|
5
|
+
removeElements(resource: URI): void;
|
|
6
|
+
undo(resource: URI): void;
|
|
7
|
+
redo(resource: URI): void;
|
|
8
|
+
}
|
|
9
|
+
interface StackElement {
|
|
10
|
+
undo(): Promise<void> | void;
|
|
11
|
+
redo(): Promise<void> | void;
|
|
12
|
+
}
|
|
13
|
+
export declare class ResourceEditStack {
|
|
14
|
+
private past;
|
|
15
|
+
private future;
|
|
16
|
+
constructor();
|
|
17
|
+
pushElement(element: StackElement): void;
|
|
18
|
+
getClosestPastElement(): StackElement | undefined;
|
|
19
|
+
getClosestFutureElement(): StackElement | undefined;
|
|
20
|
+
moveBackward(element: StackElement): void;
|
|
21
|
+
moveForward(element: StackElement): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=undo-redo-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undo-redo-service.d.ts","sourceRoot":"","sources":["../../src/browser/undo-redo-service.ts"],"names":[],"mappings":"AAsBA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,qBACa,eAAe;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwC;IAEnE,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAYtF,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAMnC,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAezB,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;CAc5B;AAED,UAAU,YAAY;IAClB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChC;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,MAAM,CAAiB;;IAO/B,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKxC,qBAAqB,IAAI,YAAY,GAAG,SAAS;IAOjD,uBAAuB,IAAI,YAAY,GAAG,SAAS;IAOnD,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKzC,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;CAI3C"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
/*---------------------------------------------------------------------------------------------
|
|
18
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
20
|
+
*--------------------------------------------------------------------------------------------*/
|
|
21
|
+
// copied and modified from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/platform/undoRedo/common/undoRedoService.ts#
|
|
22
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
23
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ResourceEditStack = exports.UndoRedoService = void 0;
|
|
30
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
31
|
+
let UndoRedoService = class UndoRedoService {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.editStacks = new Map();
|
|
34
|
+
}
|
|
35
|
+
pushElement(resource, undo, redo) {
|
|
36
|
+
let editStack;
|
|
37
|
+
if (this.editStacks.has(resource.toString())) {
|
|
38
|
+
editStack = this.editStacks.get(resource.toString());
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
editStack = new ResourceEditStack();
|
|
42
|
+
this.editStacks.set(resource.toString(), editStack);
|
|
43
|
+
}
|
|
44
|
+
editStack.pushElement({ undo, redo });
|
|
45
|
+
}
|
|
46
|
+
removeElements(resource) {
|
|
47
|
+
if (this.editStacks.has(resource.toString())) {
|
|
48
|
+
this.editStacks.delete(resource.toString());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
undo(resource) {
|
|
52
|
+
if (!this.editStacks.has(resource.toString())) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const editStack = this.editStacks.get(resource.toString());
|
|
56
|
+
const element = editStack.getClosestPastElement();
|
|
57
|
+
if (!element) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
editStack.moveBackward(element);
|
|
61
|
+
element.undo();
|
|
62
|
+
}
|
|
63
|
+
redo(resource) {
|
|
64
|
+
if (!this.editStacks.has(resource.toString())) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const editStack = this.editStacks.get(resource.toString());
|
|
68
|
+
const element = editStack.getClosestFutureElement();
|
|
69
|
+
if (!element) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
editStack.moveForward(element);
|
|
73
|
+
element.redo();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
UndoRedoService = __decorate([
|
|
77
|
+
(0, inversify_1.injectable)()
|
|
78
|
+
], UndoRedoService);
|
|
79
|
+
exports.UndoRedoService = UndoRedoService;
|
|
80
|
+
class ResourceEditStack {
|
|
81
|
+
constructor() {
|
|
82
|
+
this.past = [];
|
|
83
|
+
this.future = [];
|
|
84
|
+
}
|
|
85
|
+
pushElement(element) {
|
|
86
|
+
this.future = [];
|
|
87
|
+
this.past.push(element);
|
|
88
|
+
}
|
|
89
|
+
getClosestPastElement() {
|
|
90
|
+
if (this.past.length === 0) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return this.past[this.past.length - 1];
|
|
94
|
+
}
|
|
95
|
+
getClosestFutureElement() {
|
|
96
|
+
if (this.future.length === 0) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return this.future[this.future.length - 1];
|
|
100
|
+
}
|
|
101
|
+
moveBackward(element) {
|
|
102
|
+
this.past.pop();
|
|
103
|
+
this.future.push(element);
|
|
104
|
+
}
|
|
105
|
+
moveForward(element) {
|
|
106
|
+
this.future.pop();
|
|
107
|
+
this.past.push(element);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.ResourceEditStack = ResourceEditStack;
|
|
111
|
+
//# sourceMappingURL=undo-redo-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undo-redo-service.js","sourceRoot":"","sources":["../../src/browser/undo-redo-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF;;;gGAGgG;AAChG,iKAAiK;;;;;;;;;AAEjK,4DAA0D;AAI1D,IAAa,eAAe,GAA5B,MAAa,eAAe;IAA5B;QACqB,eAAU,GAAG,IAAI,GAAG,EAA6B,CAAC;IAiDvE,CAAC;IA/CG,WAAW,CAAC,QAAa,EAAE,IAAyB,EAAE,IAAyB;QAC3E,IAAI,SAA4B,CAAC;QACjC,IAAI,IAAI,CAAC,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AAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ;AArCD,8CAqCC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Theia - Editor Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.
|
|
7
|
-
"@theia/variable-resolver": "1.
|
|
6
|
+
"@theia/core": "1.41.0",
|
|
7
|
+
"@theia/variable-resolver": "1.41.0"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"watch": "theiaext watch"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@theia/ext-scripts": "1.
|
|
42
|
+
"@theia/ext-scripts": "1.41.0"
|
|
43
43
|
},
|
|
44
44
|
"nyc": {
|
|
45
45
|
"extends": "../../configs/nyc.json"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "180103ad086fc0a5e4e5fc01b5fcb43f06019eb1"
|
|
48
48
|
}
|
|
@@ -38,6 +38,7 @@ import { QuickAccessContribution } from '@theia/core/lib/browser/quick-input/qui
|
|
|
38
38
|
import { QuickEditorService } from './quick-editor-service';
|
|
39
39
|
import { EditorLanguageStatusService } from './language-status/editor-language-status-service';
|
|
40
40
|
import { EditorLineNumberContribution } from './editor-linenumber-contribution';
|
|
41
|
+
import { UndoRedoService } from './undo-redo-service';
|
|
41
42
|
|
|
42
43
|
export default new ContainerModule(bind => {
|
|
43
44
|
bindEditorPreferences(bind);
|
|
@@ -86,4 +87,6 @@ export default new ContainerModule(bind => {
|
|
|
86
87
|
bind(ActiveEditorAccess).toSelf().inSingletonScope();
|
|
87
88
|
bind(EditorAccess).to(CurrentEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.CURRENT);
|
|
88
89
|
bind(EditorAccess).to(ActiveEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.ACTIVE);
|
|
90
|
+
|
|
91
|
+
bind(UndoRedoService).toSelf().inSingletonScope();
|
|
89
92
|
});
|
|
@@ -52,7 +52,7 @@ export class EditorLineNumberContribution implements FrontendApplicationContribu
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
protected handleContextMenu(editor: TextEditor, event: EditorMouseEvent): void {
|
|
55
|
-
if (event.target && event.target.type === MouseTargetType.GUTTER_LINE_NUMBERS) {
|
|
55
|
+
if (event.target && (event.target.type === MouseTargetType.GUTTER_LINE_NUMBERS || event.target.type === MouseTargetType.GUTTER_GLYPH_MARGIN)) {
|
|
56
56
|
if (event.event.button === 2) {
|
|
57
57
|
editor.focus();
|
|
58
58
|
const lineNumber = lineNumberFromPosition(event.target.position);
|
|
@@ -60,7 +60,8 @@ export class EditorLineNumberContribution implements FrontendApplicationContribu
|
|
|
60
60
|
const uri = editor.getResourceUri()!;
|
|
61
61
|
const args = [{
|
|
62
62
|
lineNumber: lineNumber,
|
|
63
|
-
|
|
63
|
+
column: 1, // Compatible with Monaco editor IPosition API
|
|
64
|
+
uri: uri['codeUri'],
|
|
64
65
|
}];
|
|
65
66
|
|
|
66
67
|
setTimeout(() => {
|
|
@@ -73,7 +73,7 @@ export class EditorWidgetFactory implements WidgetFactory {
|
|
|
73
73
|
private setLabels(editor: EditorWidget, uri: URI): void {
|
|
74
74
|
editor.title.caption = uri.path.fsPath();
|
|
75
75
|
if (editor.editor.isReadonly) {
|
|
76
|
-
editor.title.caption += ` • ${nls.localizeByDefault('Read
|
|
76
|
+
editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
|
|
77
77
|
}
|
|
78
78
|
const icon = this.labelProvider.getIcon(uri);
|
|
79
79
|
editor.title.label = this.labelProvider.getName(uri);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/*---------------------------------------------------------------------------------------------
|
|
17
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
19
|
+
*--------------------------------------------------------------------------------------------*/
|
|
20
|
+
// copied and modified from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/platform/undoRedo/common/undoRedoService.ts#
|
|
21
|
+
|
|
22
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
23
|
+
import URI from '@theia/core/lib/common/uri';
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class UndoRedoService {
|
|
27
|
+
private readonly editStacks = new Map<string, ResourceEditStack>();
|
|
28
|
+
|
|
29
|
+
pushElement(resource: URI, undo: () => Promise<void>, redo: () => Promise<void>): void {
|
|
30
|
+
let editStack: ResourceEditStack;
|
|
31
|
+
if (this.editStacks.has(resource.toString())) {
|
|
32
|
+
editStack = this.editStacks.get(resource.toString())!;
|
|
33
|
+
} else {
|
|
34
|
+
editStack = new ResourceEditStack();
|
|
35
|
+
this.editStacks.set(resource.toString(), editStack);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
editStack.pushElement({ undo, redo });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
removeElements(resource: URI): void {
|
|
42
|
+
if (this.editStacks.has(resource.toString())) {
|
|
43
|
+
this.editStacks.delete(resource.toString());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
undo(resource: URI): void {
|
|
48
|
+
if (!this.editStacks.has(resource.toString())) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const editStack = this.editStacks.get(resource.toString())!;
|
|
53
|
+
const element = editStack.getClosestPastElement();
|
|
54
|
+
if (!element) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
editStack.moveBackward(element);
|
|
59
|
+
element.undo();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
redo(resource: URI): void {
|
|
63
|
+
if (!this.editStacks.has(resource.toString())) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const editStack = this.editStacks.get(resource.toString())!;
|
|
68
|
+
const element = editStack.getClosestFutureElement();
|
|
69
|
+
if (!element) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
editStack.moveForward(element);
|
|
74
|
+
element.redo();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface StackElement {
|
|
79
|
+
undo(): Promise<void> | void;
|
|
80
|
+
redo(): Promise<void> | void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class ResourceEditStack {
|
|
84
|
+
private past: StackElement[];
|
|
85
|
+
private future: StackElement[];
|
|
86
|
+
|
|
87
|
+
constructor() {
|
|
88
|
+
this.past = [];
|
|
89
|
+
this.future = [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
pushElement(element: StackElement): void {
|
|
93
|
+
this.future = [];
|
|
94
|
+
this.past.push(element);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getClosestPastElement(): StackElement | undefined {
|
|
98
|
+
if (this.past.length === 0) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return this.past[this.past.length - 1];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getClosestFutureElement(): StackElement | undefined {
|
|
105
|
+
if (this.future.length === 0) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
return this.future[this.future.length - 1];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
moveBackward(element: StackElement): void {
|
|
112
|
+
this.past.pop();
|
|
113
|
+
this.future.push(element);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
moveForward(element: StackElement): void {
|
|
117
|
+
this.future.pop();
|
|
118
|
+
this.past.push(element);
|
|
119
|
+
}
|
|
120
|
+
}
|