@theia/editor 1.53.0-next.55 → 1.53.0-next.64

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.
Files changed (42) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/editor-manager.d.ts.map +1 -1
  3. package/lib/browser/editor-manager.js +2 -4
  4. package/lib/browser/editor-manager.js.map +1 -1
  5. package/lib/browser/navigation/navigation-location-service.js +3 -3
  6. package/package.json +4 -4
  7. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  8. package/src/browser/decorations/editor-decoration.ts +127 -127
  9. package/src/browser/decorations/editor-decorator.ts +36 -36
  10. package/src/browser/decorations/index.ts +19 -19
  11. package/src/browser/diff-navigator.ts +27 -27
  12. package/src/browser/editor-command.ts +393 -393
  13. package/src/browser/editor-contribution.ts +185 -185
  14. package/src/browser/editor-frontend-module.ts +90 -90
  15. package/src/browser/editor-generated-preference-schema.ts +2956 -2956
  16. package/src/browser/editor-keybinding.ts +55 -55
  17. package/src/browser/editor-language-quick-pick-service.ts +68 -68
  18. package/src/browser/editor-linenumber-contribution.ts +88 -88
  19. package/src/browser/editor-manager.ts +460 -462
  20. package/src/browser/editor-menu.ts +224 -224
  21. package/src/browser/editor-navigation-contribution.ts +343 -343
  22. package/src/browser/editor-preferences.ts +226 -226
  23. package/src/browser/editor-variable-contribution.ts +62 -62
  24. package/src/browser/editor-widget-factory.ts +82 -82
  25. package/src/browser/editor-widget.ts +139 -139
  26. package/src/browser/editor.ts +366 -366
  27. package/src/browser/index.ts +26 -26
  28. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  29. package/src/browser/language-status/editor-language-status.css +101 -101
  30. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  31. package/src/browser/navigation/navigation-location-service.ts +284 -284
  32. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  33. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  34. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  35. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  36. package/src/browser/navigation/navigation-location.ts +418 -418
  37. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  38. package/src/browser/quick-editor-service.ts +94 -94
  39. package/src/browser/style/index.css +19 -19
  40. package/src/browser/undo-redo-service.ts +120 -120
  41. package/src/common/language-selector.ts +104 -104
  42. 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,139 +1,139 @@
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, ExtractableWidget } 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, ExtractableWidget {
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
- isExtractable: boolean = true;
55
- secondaryWindow: Window | undefined;
56
-
57
- setSelection(): void {
58
- if (this.editor.isFocused() && this.selectionService.selection !== this.editor) {
59
- this.selectionService.selection = this.editor;
60
- }
61
- }
62
-
63
- get saveable(): Saveable {
64
- return this.editor.document;
65
- }
66
-
67
- getResourceUri(): URI | undefined {
68
- return this.editor.getResourceUri();
69
- }
70
- createMoveToUri(resourceUri: URI): URI | undefined {
71
- return this.editor.createMoveToUri(resourceUri);
72
- }
73
-
74
- protected override onActivateRequest(msg: Message): void {
75
- super.onActivateRequest(msg);
76
- this.editor.focus();
77
- this.selectionService.selection = this.editor;
78
- }
79
-
80
- protected override onAfterAttach(msg: Message): void {
81
- super.onAfterAttach(msg);
82
- if (this.isVisible) {
83
- this.editor.refresh();
84
- }
85
- this.checkForTabbarChange();
86
- }
87
-
88
- protected checkForTabbarChange(): void {
89
- const { parent } = this;
90
- if (parent instanceof DockPanel) {
91
- const newTabbar = find(parent.tabBars(), tabbar => !!tabbar.titles.find(title => title === this.title));
92
- if (this.currentTabbar !== newTabbar) {
93
- this.toDisposeOnTabbarChange.dispose();
94
- const listener = () => this.checkForTabbarChange();
95
- parent.layoutModified.connect(listener);
96
- this.toDisposeOnTabbarChange.push(Disposable.create(() => parent.layoutModified.disconnect(listener)));
97
- const last = this.currentTabbar;
98
- this.currentTabbar = newTabbar;
99
- this.handleTabBarChange(last, newTabbar);
100
- }
101
- }
102
- }
103
-
104
- protected handleTabBarChange(oldTabBar?: TabBar<Widget>, newTabBar?: TabBar<Widget>): void {
105
- const ownSaveable = Saveable.get(this);
106
- const competingEditors = ownSaveable && newTabBar?.titles.filter(title => title !== this.title
107
- && (title.owner instanceof EditorWidget)
108
- && title.owner.editor.uri.isEqual(this.editor.uri)
109
- && Saveable.get(title.owner) === ownSaveable
110
- );
111
- competingEditors?.forEach(title => title.owner.close());
112
- }
113
-
114
- protected override onAfterShow(msg: Message): void {
115
- super.onAfterShow(msg);
116
- this.editor.refresh();
117
- }
118
-
119
- protected override onResize(msg: Widget.ResizeMessage): void {
120
- if (msg.width < 0 || msg.height < 0) {
121
- this.editor.resizeToFit();
122
- } else {
123
- this.editor.setSize(msg);
124
- }
125
- }
126
-
127
- storeState(): object | undefined {
128
- return this.getResourceUri()?.scheme === UNTITLED_SCHEME ? undefined : this.editor.storeViewState();
129
- }
130
-
131
- restoreState(oldState: object): void {
132
- this.editor.restoreViewState(oldState);
133
- }
134
-
135
- get onDispose(): Event<void> {
136
- return this.toDispose.onDispose;
137
- }
138
-
139
- }
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, ExtractableWidget } 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, ExtractableWidget {
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
+ isExtractable: boolean = true;
55
+ secondaryWindow: Window | undefined;
56
+
57
+ setSelection(): void {
58
+ if (this.editor.isFocused() && this.selectionService.selection !== this.editor) {
59
+ this.selectionService.selection = this.editor;
60
+ }
61
+ }
62
+
63
+ get saveable(): Saveable {
64
+ return this.editor.document;
65
+ }
66
+
67
+ getResourceUri(): URI | undefined {
68
+ return this.editor.getResourceUri();
69
+ }
70
+ createMoveToUri(resourceUri: URI): URI | undefined {
71
+ return this.editor.createMoveToUri(resourceUri);
72
+ }
73
+
74
+ protected override onActivateRequest(msg: Message): void {
75
+ super.onActivateRequest(msg);
76
+ this.editor.focus();
77
+ this.selectionService.selection = this.editor;
78
+ }
79
+
80
+ protected override onAfterAttach(msg: Message): void {
81
+ super.onAfterAttach(msg);
82
+ if (this.isVisible) {
83
+ this.editor.refresh();
84
+ }
85
+ this.checkForTabbarChange();
86
+ }
87
+
88
+ protected checkForTabbarChange(): void {
89
+ const { parent } = this;
90
+ if (parent instanceof DockPanel) {
91
+ const newTabbar = find(parent.tabBars(), tabbar => !!tabbar.titles.find(title => title === this.title));
92
+ if (this.currentTabbar !== newTabbar) {
93
+ this.toDisposeOnTabbarChange.dispose();
94
+ const listener = () => this.checkForTabbarChange();
95
+ parent.layoutModified.connect(listener);
96
+ this.toDisposeOnTabbarChange.push(Disposable.create(() => parent.layoutModified.disconnect(listener)));
97
+ const last = this.currentTabbar;
98
+ this.currentTabbar = newTabbar;
99
+ this.handleTabBarChange(last, newTabbar);
100
+ }
101
+ }
102
+ }
103
+
104
+ protected handleTabBarChange(oldTabBar?: TabBar<Widget>, newTabBar?: TabBar<Widget>): void {
105
+ const ownSaveable = Saveable.get(this);
106
+ const competingEditors = ownSaveable && newTabBar?.titles.filter(title => title !== this.title
107
+ && (title.owner instanceof EditorWidget)
108
+ && title.owner.editor.uri.isEqual(this.editor.uri)
109
+ && Saveable.get(title.owner) === ownSaveable
110
+ );
111
+ competingEditors?.forEach(title => title.owner.close());
112
+ }
113
+
114
+ protected override onAfterShow(msg: Message): void {
115
+ super.onAfterShow(msg);
116
+ this.editor.refresh();
117
+ }
118
+
119
+ protected override onResize(msg: Widget.ResizeMessage): void {
120
+ if (msg.width < 0 || msg.height < 0) {
121
+ this.editor.resizeToFit();
122
+ } else {
123
+ this.editor.setSize(msg);
124
+ }
125
+ }
126
+
127
+ storeState(): object | undefined {
128
+ return this.getResourceUri()?.scheme === UNTITLED_SCHEME ? undefined : this.editor.storeViewState();
129
+ }
130
+
131
+ restoreState(oldState: object): void {
132
+ this.editor.restoreViewState(oldState);
133
+ }
134
+
135
+ get onDispose(): Event<void> {
136
+ return this.toDispose.onDispose;
137
+ }
138
+
139
+ }