@theia/editor 1.45.0 → 1.46.0-next.72
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/README.md +30 -30
- package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
- package/lib/browser/decorations/editor-decoration-style.js +36 -36
- package/lib/browser/decorations/editor-decoration.d.ts +106 -106
- package/lib/browser/decorations/editor-decoration.js +37 -37
- package/lib/browser/decorations/editor-decorator.d.ts +6 -6
- package/lib/browser/decorations/editor-decorator.js +43 -43
- package/lib/browser/decorations/index.d.ts +3 -3
- package/lib/browser/decorations/index.js +30 -30
- package/lib/browser/diff-navigator.d.ts +9 -10
- package/lib/browser/diff-navigator.d.ts.map +1 -1
- package/lib/browser/diff-navigator.js +19 -19
- package/lib/browser/diff-navigator.js.map +1 -1
- package/lib/browser/editor-command.d.ts +102 -102
- package/lib/browser/editor-command.js +426 -426
- package/lib/browser/editor-contribution.d.ts +26 -26
- package/lib/browser/editor-contribution.js +198 -198
- package/lib/browser/editor-frontend-module.d.ts +5 -5
- package/lib/browser/editor-frontend-module.js +74 -74
- package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
- package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
- package/lib/browser/editor-generated-preference-schema.js +2451 -2316
- package/lib/browser/editor-generated-preference-schema.js.map +1 -1
- package/lib/browser/editor-keybinding.d.ts +5 -5
- package/lib/browser/editor-keybinding.js +55 -55
- package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
- package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
- package/lib/browser/editor-linenumber-contribution.js +95 -96
- package/lib/browser/editor-linenumber-contribution.js.map +1 -1
- package/lib/browser/editor-manager.d.ts +115 -115
- package/lib/browser/editor-manager.js +428 -428
- package/lib/browser/editor-menu.d.ts +48 -48
- package/lib/browser/editor-menu.js +210 -210
- package/lib/browser/editor-navigation-contribution.d.ts +67 -67
- package/lib/browser/editor-navigation-contribution.js +343 -343
- package/lib/browser/editor-preferences.d.ts +41 -41
- package/lib/browser/editor-preferences.js +176 -176
- package/lib/browser/editor-variable-contribution.d.ts +8 -8
- package/lib/browser/editor-variable-contribution.js +64 -64
- package/lib/browser/editor-widget-factory.d.ts +17 -17
- package/lib/browser/editor-widget-factory.js +91 -91
- package/lib/browser/editor-widget.d.ts +24 -24
- package/lib/browser/editor-widget.d.ts.map +1 -1
- package/lib/browser/editor-widget.js +122 -114
- package/lib/browser/editor-widget.js.map +1 -1
- package/lib/browser/editor.d.ts +295 -293
- package/lib/browser/editor.d.ts.map +1 -1
- package/lib/browser/editor.js +103 -103
- package/lib/browser/editor.js.map +1 -1
- package/lib/browser/index.d.ts +10 -10
- package/lib/browser/index.js +37 -37
- package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
- package/lib/browser/language-status/editor-language-status-service.js +251 -251
- package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
- package/lib/browser/navigation/navigation-location-service.js +281 -281
- package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
- package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
- package/lib/browser/navigation/navigation-location-similarity.js +62 -62
- package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
- package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
- package/lib/browser/navigation/navigation-location-updater.js +210 -210
- package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
- package/lib/browser/navigation/navigation-location.d.ts +191 -191
- package/lib/browser/navigation/navigation-location.js +300 -300
- package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
- package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
- package/lib/browser/quick-editor-service.d.ts +16 -16
- package/lib/browser/quick-editor-service.js +109 -109
- package/lib/browser/undo-redo-service.d.ts +23 -23
- package/lib/browser/undo-redo-service.js +110 -110
- package/lib/common/language-selector.d.ts +13 -13
- package/lib/common/language-selector.js +90 -90
- package/lib/package.spec.js +25 -25
- package/package.json +5 -5
- package/src/browser/decorations/editor-decoration-style.ts +41 -41
- package/src/browser/decorations/editor-decoration.ts +127 -127
- package/src/browser/decorations/editor-decorator.ts +36 -36
- package/src/browser/decorations/index.ts +19 -19
- package/src/browser/diff-navigator.ts +27 -28
- package/src/browser/editor-command.ts +414 -414
- package/src/browser/editor-contribution.ts +185 -185
- package/src/browser/editor-frontend-module.ts +87 -87
- package/src/browser/editor-generated-preference-schema.ts +2707 -2539
- package/src/browser/editor-keybinding.ts +55 -55
- package/src/browser/editor-linenumber-contribution.ts +88 -89
- package/src/browser/editor-manager.ts +442 -442
- package/src/browser/editor-menu.ts +224 -224
- package/src/browser/editor-navigation-contribution.ts +343 -343
- package/src/browser/editor-preferences.ts +226 -226
- package/src/browser/editor-variable-contribution.ts +54 -54
- package/src/browser/editor-widget-factory.ts +82 -82
- package/src/browser/editor-widget.ts +137 -130
- package/src/browser/editor.ts +360 -358
- package/src/browser/index.ts +26 -26
- package/src/browser/language-status/editor-language-status-service.ts +271 -271
- package/src/browser/language-status/editor-language-status.css +101 -101
- package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
- package/src/browser/navigation/navigation-location-service.ts +284 -284
- package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
- package/src/browser/navigation/navigation-location-similarity.ts +58 -58
- package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
- package/src/browser/navigation/navigation-location-updater.ts +220 -220
- package/src/browser/navigation/navigation-location.ts +418 -418
- package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
- package/src/browser/quick-editor-service.ts +94 -94
- package/src/browser/style/index.css +19 -19
- package/src/browser/undo-redo-service.ts +120 -120
- package/src/common/language-selector.ts +104 -104
- package/src/package.spec.ts +28 -28
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox 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
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import URI from '@theia/core/lib/common/uri';
|
|
19
|
-
import { nls, SelectionService } from '@theia/core/lib/common';
|
|
20
|
-
import { NavigatableWidgetOptions, WidgetFactory, LabelProvider } from '@theia/core/lib/browser';
|
|
21
|
-
import { EditorWidget } from './editor-widget';
|
|
22
|
-
import { TextEditorProvider } from './editor';
|
|
23
|
-
|
|
24
|
-
@injectable()
|
|
25
|
-
export class EditorWidgetFactory implements WidgetFactory {
|
|
26
|
-
|
|
27
|
-
static createID(uri: URI, counter?: number): string {
|
|
28
|
-
return EditorWidgetFactory.ID
|
|
29
|
-
+ `:${uri.toString()}`
|
|
30
|
-
+ (counter !== undefined ? `:${counter}` : '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static ID = 'code-editor-opener';
|
|
34
|
-
|
|
35
|
-
readonly id = EditorWidgetFactory.ID;
|
|
36
|
-
|
|
37
|
-
@inject(LabelProvider)
|
|
38
|
-
protected readonly labelProvider: LabelProvider;
|
|
39
|
-
|
|
40
|
-
@inject(TextEditorProvider)
|
|
41
|
-
protected readonly editorProvider: TextEditorProvider;
|
|
42
|
-
|
|
43
|
-
@inject(SelectionService)
|
|
44
|
-
protected readonly selectionService: SelectionService;
|
|
45
|
-
|
|
46
|
-
createWidget(options: NavigatableWidgetOptions): Promise<EditorWidget> {
|
|
47
|
-
const uri = new URI(options.uri);
|
|
48
|
-
return this.createEditor(uri, options);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected async createEditor(uri: URI, options?: NavigatableWidgetOptions): Promise<EditorWidget> {
|
|
52
|
-
const newEditor = await this.constructEditor(uri);
|
|
53
|
-
|
|
54
|
-
this.setLabels(newEditor, uri);
|
|
55
|
-
const labelListener = this.labelProvider.onDidChange(event => {
|
|
56
|
-
if (event.affects(uri)) {
|
|
57
|
-
this.setLabels(newEditor, uri);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
newEditor.onDispose(() => labelListener.dispose());
|
|
61
|
-
|
|
62
|
-
newEditor.id = EditorWidgetFactory.createID(uri, options?.counter);
|
|
63
|
-
|
|
64
|
-
newEditor.title.closable = true;
|
|
65
|
-
return newEditor;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
protected async constructEditor(uri: URI): Promise<EditorWidget> {
|
|
69
|
-
const textEditor = await this.editorProvider(uri);
|
|
70
|
-
return new EditorWidget(textEditor, this.selectionService);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private setLabels(editor: EditorWidget, uri: URI): void {
|
|
74
|
-
editor.title.caption = uri.path.fsPath();
|
|
75
|
-
if (editor.editor.isReadonly) {
|
|
76
|
-
editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
|
|
77
|
-
}
|
|
78
|
-
const icon = this.labelProvider.getIcon(uri);
|
|
79
|
-
editor.title.label = this.labelProvider.getName(uri);
|
|
80
|
-
editor.title.iconClass = icon + ' file-icon';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox 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
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import URI from '@theia/core/lib/common/uri';
|
|
19
|
+
import { nls, SelectionService } from '@theia/core/lib/common';
|
|
20
|
+
import { NavigatableWidgetOptions, WidgetFactory, LabelProvider } from '@theia/core/lib/browser';
|
|
21
|
+
import { EditorWidget } from './editor-widget';
|
|
22
|
+
import { TextEditorProvider } from './editor';
|
|
23
|
+
|
|
24
|
+
@injectable()
|
|
25
|
+
export class EditorWidgetFactory implements WidgetFactory {
|
|
26
|
+
|
|
27
|
+
static createID(uri: URI, counter?: number): string {
|
|
28
|
+
return EditorWidgetFactory.ID
|
|
29
|
+
+ `:${uri.toString()}`
|
|
30
|
+
+ (counter !== undefined ? `:${counter}` : '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static ID = 'code-editor-opener';
|
|
34
|
+
|
|
35
|
+
readonly id = EditorWidgetFactory.ID;
|
|
36
|
+
|
|
37
|
+
@inject(LabelProvider)
|
|
38
|
+
protected readonly labelProvider: LabelProvider;
|
|
39
|
+
|
|
40
|
+
@inject(TextEditorProvider)
|
|
41
|
+
protected readonly editorProvider: TextEditorProvider;
|
|
42
|
+
|
|
43
|
+
@inject(SelectionService)
|
|
44
|
+
protected readonly selectionService: SelectionService;
|
|
45
|
+
|
|
46
|
+
createWidget(options: NavigatableWidgetOptions): Promise<EditorWidget> {
|
|
47
|
+
const uri = new URI(options.uri);
|
|
48
|
+
return this.createEditor(uri, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected async createEditor(uri: URI, options?: NavigatableWidgetOptions): Promise<EditorWidget> {
|
|
52
|
+
const newEditor = await this.constructEditor(uri);
|
|
53
|
+
|
|
54
|
+
this.setLabels(newEditor, uri);
|
|
55
|
+
const labelListener = this.labelProvider.onDidChange(event => {
|
|
56
|
+
if (event.affects(uri)) {
|
|
57
|
+
this.setLabels(newEditor, uri);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
newEditor.onDispose(() => labelListener.dispose());
|
|
61
|
+
|
|
62
|
+
newEditor.id = EditorWidgetFactory.createID(uri, options?.counter);
|
|
63
|
+
|
|
64
|
+
newEditor.title.closable = true;
|
|
65
|
+
return newEditor;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected async constructEditor(uri: URI): Promise<EditorWidget> {
|
|
69
|
+
const textEditor = await this.editorProvider(uri);
|
|
70
|
+
return new EditorWidget(textEditor, this.selectionService);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private setLabels(editor: EditorWidget, uri: URI): void {
|
|
74
|
+
editor.title.caption = uri.path.fsPath();
|
|
75
|
+
if (editor.editor.isReadonly) {
|
|
76
|
+
editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
|
|
77
|
+
}
|
|
78
|
+
const icon = this.labelProvider.getIcon(uri);
|
|
79
|
+
editor.title.label = this.labelProvider.getName(uri);
|
|
80
|
+
editor.title.iconClass = icon + ' file-icon';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,130 +1,137 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 TypeFox 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
|
-
import { Disposable, SelectionService, Event, UNTITLED_SCHEME, DisposableCollection } from '@theia/core/lib/common';
|
|
18
|
-
import { Widget, BaseWidget, Message, Saveable, SaveableSource, Navigatable, StatefulWidget, lock, TabBar, DockPanel } from '@theia/core/lib/browser';
|
|
19
|
-
import URI from '@theia/core/lib/common/uri';
|
|
20
|
-
import { find } from '@theia/core/shared/@phosphor/algorithm';
|
|
21
|
-
import { TextEditor } from './editor';
|
|
22
|
-
|
|
23
|
-
export class EditorWidget extends BaseWidget implements SaveableSource, Navigatable, StatefulWidget {
|
|
24
|
-
|
|
25
|
-
protected toDisposeOnTabbarChange = new DisposableCollection();
|
|
26
|
-
protected currentTabbar: TabBar<Widget> | undefined;
|
|
27
|
-
|
|
28
|
-
constructor(
|
|
29
|
-
readonly editor: TextEditor,
|
|
30
|
-
protected readonly selectionService: SelectionService
|
|
31
|
-
) {
|
|
32
|
-
super(editor);
|
|
33
|
-
this.addClass('theia-editor');
|
|
34
|
-
if (editor.isReadonly) {
|
|
35
|
-
lock(this.title);
|
|
36
|
-
}
|
|
37
|
-
this.toDispose.push(this.editor);
|
|
38
|
-
this.toDispose.push(this.toDisposeOnTabbarChange);
|
|
39
|
-
this.toDispose.push(this.editor.onSelectionChanged(() => this.setSelection()));
|
|
40
|
-
this.toDispose.push(this.editor.onFocusChanged(() => this.setSelection()));
|
|
41
|
-
this.toDispose.push(
|
|
42
|
-
if (
|
|
43
|
-
this.
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return this.editor.
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 TypeFox 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
|
+
import { Disposable, SelectionService, Event, UNTITLED_SCHEME, DisposableCollection } from '@theia/core/lib/common';
|
|
18
|
+
import { Widget, BaseWidget, Message, Saveable, SaveableSource, Navigatable, StatefulWidget, lock, TabBar, DockPanel, unlock } from '@theia/core/lib/browser';
|
|
19
|
+
import URI from '@theia/core/lib/common/uri';
|
|
20
|
+
import { find } from '@theia/core/shared/@phosphor/algorithm';
|
|
21
|
+
import { TextEditor } from './editor';
|
|
22
|
+
|
|
23
|
+
export class EditorWidget extends BaseWidget implements SaveableSource, Navigatable, StatefulWidget {
|
|
24
|
+
|
|
25
|
+
protected toDisposeOnTabbarChange = new DisposableCollection();
|
|
26
|
+
protected currentTabbar: TabBar<Widget> | undefined;
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
readonly editor: TextEditor,
|
|
30
|
+
protected readonly selectionService: SelectionService
|
|
31
|
+
) {
|
|
32
|
+
super(editor);
|
|
33
|
+
this.addClass('theia-editor');
|
|
34
|
+
if (editor.isReadonly) {
|
|
35
|
+
lock(this.title);
|
|
36
|
+
}
|
|
37
|
+
this.toDispose.push(this.editor);
|
|
38
|
+
this.toDispose.push(this.toDisposeOnTabbarChange);
|
|
39
|
+
this.toDispose.push(this.editor.onSelectionChanged(() => this.setSelection()));
|
|
40
|
+
this.toDispose.push(this.editor.onFocusChanged(() => this.setSelection()));
|
|
41
|
+
this.toDispose.push(this.editor.onDidChangeReadOnly(isReadonly => {
|
|
42
|
+
if (isReadonly) {
|
|
43
|
+
lock(this.title);
|
|
44
|
+
} else {
|
|
45
|
+
unlock(this.title);
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
this.toDispose.push(Disposable.create(() => {
|
|
49
|
+
if (this.selectionService.selection === this.editor) {
|
|
50
|
+
this.selectionService.selection = undefined;
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setSelection(): void {
|
|
56
|
+
if (this.editor.isFocused() && this.selectionService.selection !== this.editor) {
|
|
57
|
+
this.selectionService.selection = this.editor;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get saveable(): Saveable {
|
|
62
|
+
return this.editor.document;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getResourceUri(): URI | undefined {
|
|
66
|
+
return this.editor.getResourceUri();
|
|
67
|
+
}
|
|
68
|
+
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
69
|
+
return this.editor.createMoveToUri(resourceUri);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected override onActivateRequest(msg: Message): void {
|
|
73
|
+
super.onActivateRequest(msg);
|
|
74
|
+
this.editor.focus();
|
|
75
|
+
this.selectionService.selection = this.editor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected override onAfterAttach(msg: Message): void {
|
|
79
|
+
super.onAfterAttach(msg);
|
|
80
|
+
if (this.isVisible) {
|
|
81
|
+
this.editor.refresh();
|
|
82
|
+
}
|
|
83
|
+
this.checkForTabbarChange();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected checkForTabbarChange(): void {
|
|
87
|
+
const { parent } = this;
|
|
88
|
+
if (parent instanceof DockPanel) {
|
|
89
|
+
const newTabbar = find(parent.tabBars(), tabbar => !!tabbar.titles.find(title => title === this.title));
|
|
90
|
+
if (this.currentTabbar !== newTabbar) {
|
|
91
|
+
this.toDisposeOnTabbarChange.dispose();
|
|
92
|
+
const listener = () => this.checkForTabbarChange();
|
|
93
|
+
parent.layoutModified.connect(listener);
|
|
94
|
+
this.toDisposeOnTabbarChange.push(Disposable.create(() => parent.layoutModified.disconnect(listener)));
|
|
95
|
+
const last = this.currentTabbar;
|
|
96
|
+
this.currentTabbar = newTabbar;
|
|
97
|
+
this.handleTabBarChange(last, newTabbar);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected handleTabBarChange(oldTabBar?: TabBar<Widget>, newTabBar?: TabBar<Widget>): void {
|
|
103
|
+
const ownSaveable = Saveable.get(this);
|
|
104
|
+
const competingEditors = ownSaveable && newTabBar?.titles.filter(title => title !== this.title
|
|
105
|
+
&& (title.owner instanceof EditorWidget)
|
|
106
|
+
&& title.owner.editor.uri.isEqual(this.editor.uri)
|
|
107
|
+
&& Saveable.get(title.owner) === ownSaveable
|
|
108
|
+
);
|
|
109
|
+
competingEditors?.forEach(title => title.owner.close());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
protected override onAfterShow(msg: Message): void {
|
|
113
|
+
super.onAfterShow(msg);
|
|
114
|
+
this.editor.refresh();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
protected override onResize(msg: Widget.ResizeMessage): void {
|
|
118
|
+
if (msg.width < 0 || msg.height < 0) {
|
|
119
|
+
this.editor.resizeToFit();
|
|
120
|
+
} else {
|
|
121
|
+
this.editor.setSize(msg);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
storeState(): object | undefined {
|
|
126
|
+
return this.getResourceUri()?.scheme === UNTITLED_SCHEME ? undefined : this.editor.storeViewState();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
restoreState(oldState: object): void {
|
|
130
|
+
this.editor.restoreViewState(oldState);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get onDispose(): Event<void> {
|
|
134
|
+
return this.toDispose.onDispose;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|